From wdouglass at carnegierobotics.com Wed Sep 1 12:13:06 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Wed, 1 Sep 2021 19:13:06 +0000 Subject: [CM] s7_load_c_string Message-ID: Hi all, I'm experimenting with compressing a long s7 .scm file. My program takes in a gzipped file, uncompresses it, and feeds it to s7 `s7_load_c_string`. while loading, the script loads other scripts, as well as calls several C extensions to s7. If i run the script directly `(load "script.scm")', it works fine. But if i use my "gzip loader", i get some unresolved symbols, etc... it looks like a GC issue short of turning off the GC while i'm loading my C string, how can i debug this? Thanks, Woody Douglass From bil at ccrma.Stanford.EDU Wed Sep 1 12:43:59 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 01 Sep 2021 12:43:59 -0700 Subject: [CM] =?utf-8?q?s7=5Fload=5Fc=5Fstring?= In-Reply-To: References: Message-ID: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> I'd expect a free cell complaint if it was the GC. Didn't Christos run into a similar problem in early July (unbound variable from s7_load_c_string)? -- I think it turned out to be a missing null at the end of the string (and maybe off-by-1 length?). I believe a file might not end in 0, so gzip/unzip might produce an unterminated string. s7_load_c_string should check for the 0. From chris.actondev at gmail.com Wed Sep 1 12:58:21 2021 From: chris.actondev at gmail.com (Christos Vagias) Date: Wed, 1 Sep 2021 22:58:21 +0300 Subject: [CM] s7_load_c_string In-Reply-To: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> References: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> Message-ID: Hi all, Indeed the problem in my case was unterminated x string but I was passing raw bytes there. Bil if I recall correctly the load_c_string also needs the string length as a parameter. Couldn't this help skipping the null termination? If so, then the function could be called load_bytes. On Wed, Sep 1, 2021, 10:44 PM wrote: > I'd expect a free cell complaint if it was the GC. Didn't > Christos run into a similar problem in early July (unbound > variable from s7_load_c_string)? -- I think it turned out > to be a missing null at the end of the string (and maybe > off-by-1 length?). I believe a file might not end in > 0, so gzip/unzip might produce an unterminated string. > s7_load_c_string should check for the 0. > > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Wed Sep 1 13:09:35 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 01 Sep 2021 13:09:35 -0700 Subject: [CM] =?utf-8?q?s7=5Fload=5Fc=5Fstring?= In-Reply-To: References: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> Message-ID: Yes, s7 could null-terminate the string, but it would need to make room for the string + the null, copy the string, etc. s7_load does this (actually it adds 2 nulls -- I wonder what that's about...). I was hoping to avoid the copy and eventual free. I added an error check to s7_load_c_string -- maybe it should warn about the missing 0, then go ahead and copy the string, etc. From elronnd at elronnd.net Wed Sep 1 14:33:34 2021 From: elronnd at elronnd.net (Elijah Stone) Date: Wed, 1 Sep 2021 14:33:34 -0700 (PDT) Subject: [CM] s7_load_c_string In-Reply-To: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> References: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> Message-ID: On Wed, 1 Sep 2021, bil at ccrma.Stanford.EDU wrote: > I'd expect a free cell complaint if it was the GC FWIW, the GC bug I reported last month also manifested itself with bogus errors about unbound variables. So it's certainly within the realm of possibility (even if it wasn't the problem in this case). From bil at ccrma.Stanford.EDU Thu Sep 2 03:20:28 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Thu, 02 Sep 2021 03:20:28 -0700 Subject: [CM] =?utf-8?q?s7=5Fload=5Fc=5Fstring?= In-Reply-To: References: Message-ID: <1709362799c3dc585b8194ac4580221a@ccrma.stanford.edu> > short of turning off the GC while i'm loading my C string, how can i > debug this? GC bugs can be hard to track down, but I always start by running with S7_DEBUGGING=1. This adds tons of checks (s7 will run 5 to 10 times slower), and save GC info about every cell (see the end of the s7_cell declaration). That might provide enough info to find/fix the problem. From wdouglass at carnegierobotics.com Thu Sep 2 04:58:43 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Thu, 2 Sep 2021 11:58:43 +0000 Subject: [CM] s7_load_c_string In-Reply-To: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> References: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> Message-ID: <2b397b8ad9b053d488ea67b1d28cb42e2b33235a.camel@carnegierobotics.com> My string wasn't null-terminated -- i assumed that it didn't need to be, because of the length argument. Should the length include the null byte or not? Thanks, Woody On Wed, 2021-09-01 at 12:43 -0700, bil at ccrma.Stanford.EDU wrote: > I'd expect a free cell complaint if it was the GC. Didn't > Christos run into a similar problem in early July (unbound > variable from s7_load_c_string)? -- I think it turned out > to be a missing null at the end of the string (and maybe > off-by-1 length?). I believe a file might not end in > 0, so gzip/unzip might produce an unterminated string. > s7_load_c_string should check for the 0. > > From wdouglass at carnegierobotics.com Thu Sep 2 04:59:24 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Thu, 2 Sep 2021 11:59:24 +0000 Subject: [CM] s7_load_c_string In-Reply-To: <1709362799c3dc585b8194ac4580221a@ccrma.stanford.edu> References: <1709362799c3dc585b8194ac4580221a@ccrma.stanford.edu> Message-ID: <41e385dc1ce278ee946d80a37128875a6f84e25a.camel@carnegierobotics.com> I really need to add this variable to my debug-build infrastructure. Thanks! On Thu, 2021-09-02 at 03:20 -0700, bil at ccrma.Stanford.EDU wrote: > > short of turning off the GC while i'm loading my C string, how can > > i > > debug this? > > GC bugs can be hard to track down, but I always start by > running with S7_DEBUGGING=1. This adds tons of checks > (s7 will run 5 to 10 times slower), and save GC info > about every cell (see the end of the s7_cell declaration). > That might provide enough info to find/fix the problem. > From bil at ccrma.Stanford.EDU Thu Sep 2 05:53:53 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Thu, 02 Sep 2021 05:53:53 -0700 Subject: [CM] =?utf-8?q?s7=5Fload=5Fc=5Fstring?= In-Reply-To: <2b397b8ad9b053d488ea67b1d28cb42e2b33235a.camel@carnegierobotics.com> References: <55fedb1c257251247ebb34a71ab6a9be@ccrma.stanford.edu> <2b397b8ad9b053d488ea67b1d28cb42e2b33235a.camel@carnegierobotics.com> Message-ID: <63da6a253b6d76e129dfdfeb0ea26054@ccrma.stanford.edu> > Should the length include the null byte or not? not. It's the C string length (strlen etc). There are some simple examples in ffitest.c. From bil at ccrma.Stanford.EDU Sun Sep 5 14:56:06 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Sun, 05 Sep 2021 14:56:06 -0700 Subject: [CM] Snd 21.7 Message-ID: <42a82a277e98ff48a0adf832bc254f0c@ccrma.stanford.edu> Snd 21.7 s7: added (*s7* 'muffle-warnings?) and s7_output_string bool s7_flush_output_port (was void) checked: notcurses 2.3.13, sbcl 2.1.8 notcurses 2.3.17 behaves very strangely in row 0, so I've covered row 0 with a header box. It's probably some new notcurses configuration option. Thanks!: Brad Christensen, Woody Douglass, JGM, Anders Vinjar From bil at ccrma.Stanford.EDU Mon Sep 6 11:13:24 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 06 Sep 2021 11:13:24 -0700 Subject: [CM] Snd 21.7 In-Reply-To: <42a82a277e98ff48a0adf832bc254f0c@ccrma.stanford.edu> References: <42a82a277e98ff48a0adf832bc254f0c@ccrma.stanford.edu> Message-ID: One reason for the early release was that I wanted to use __has_include to make mus-config.h optional (that is you don't have to make an empty file anymore). It works in gcc and clang, and I think it works in MS C++ from after 2017 (it's in the C20 standard, or is it C23?). It will be in-place by tomorrow; let me know if anything goes wrong. From iainduncanlists at gmail.com Wed Sep 8 09:38:40 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Wed, 8 Sep 2021 09:38:40 -0700 Subject: [CM] need macro help! Message-ID: I am apparently in over my head, I'm pretty darned new to defmacro'ing. If anyone can help with this, it would help me add a very nice ability to scheme for max! thanks! ; desired behaviour ; (s4m-run-expr "(+ %1 %2 %3)") ; should run as (+1 (expr-ins 1) (expr-ins 2) (expr-ins 3)) ; error i get: ;make-iterator argument, input-sexp, is a symbol but should be a sequence ; (cons 'eval (list (map (lambda... ; these get set elsewhere and represent values that ; will expand %1 %2 etc (define s4m-expr-inputs (vector '() 11 22 33)) (define (string->sexp text) "convert a string of an sexp to an sexp" (read (open-input-string text))) (define-macro (run-expr sexp) (cons 'eval (list (map (lambda(token) (if (and (symbol? token) (eq? ((symbol->string token) 0) #\%)) `(s4m-expr-inputs ,(string->number (list->string (cdr (string->list (symbol->string token)))))) token)) sexp)))) (define (s4m-run-expr sexp-str) (let ((input-sexp (string->sexp sexp-str))) (run-expr input-sexp))) -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Wed Sep 8 10:09:07 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 08 Sep 2021 10:09:07 -0700 Subject: [CM] need macro help! In-Reply-To: References: Message-ID: I think the "sexp" argument to map is just the macro argument name 'sexp, so map can't figure out what to do, and asks make-iterator to do something (hence the make-iterator error). I would write the macro: (define-macro (run-expr sexp) `(eval (map (lambda(token) (if (and (symbol? token) (eq? ((symbol->string token) 0) #\%)) `(s4m-expr-inputs ,(string->number (substring (symbol->string token) 1))) token)) ,sexp)) so (s4m-run-expr "(+ %1 %2 %3)") returns 66. If you omit the eval (to see what code is being generated), (s4m-run-expr "(+ %1 %2 %3)") returns (+ (s4m-expr-inputs 1) (s4m-expr-inputs 2) (s4m-expr-inputs 3)) From j_hearon at hotmail.com Wed Sep 8 10:37:32 2021 From: j_hearon at hotmail.com (James Hearon) Date: Wed, 8 Sep 2021 17:37:32 +0000 Subject: [CM] OT a few pieces Message-ID: Hi, I have so enjoyed working with Snd to create instruments, and sounds. I've found it very flexible and useful. Also have enjoyed utilizing R. Taube's patterns too. Posting a link to some older pieces I did using snd as an ex. of creative work using Snd. I believe these were from 2019. https://5minutemasterpieces.com/steel/ Regards, Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From iainduncanlists at gmail.com Wed Sep 8 10:38:00 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Wed, 8 Sep 2021 10:38:00 -0700 Subject: [CM] need macro help! In-Reply-To: References: Message-ID: Thanks Bill, yes that was it. I had figured out that was the (first!) error before you replied, but my solution was much more rube-goldbergish than yours, so much appreciated. Of course now I've realized it needs to be recursive, silly me. (+ %1 %2) works, but not (+ (+ %1 %2) %3). gah! iain On Wed, Sep 8, 2021 at 10:09 AM wrote: > I think the "sexp" argument to map is just the > macro argument name 'sexp, so map can't figure > out what to do, and asks make-iterator to do > something (hence the make-iterator error). I > would write the macro: > > (define-macro (run-expr sexp) > `(eval (map > (lambda(token) > (if (and (symbol? token) > (eq? ((symbol->string token) 0) #\%)) > `(s4m-expr-inputs ,(string->number (substring > (symbol->string token) > 1))) > token)) > ,sexp)) > > so (s4m-run-expr "(+ %1 %2 %3)") returns 66. > > If you omit the eval (to see what code is being generated), > > (s4m-run-expr "(+ %1 %2 %3)") > > returns > > (+ (s4m-expr-inputs 1) (s4m-expr-inputs 2) (s4m-expr-inputs 3)) > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Wed Sep 8 11:03:25 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 08 Sep 2021 11:03:25 -0700 Subject: [CM] need macro help! In-Reply-To: References: Message-ID: <7d052ed935b64955f2e2db0043e33806@ccrma.stanford.edu> This isn't helpful, in fact it's ugly, but I can't resist mentioning: (set! *#readers* (cons (cons #\% (lambda (str) (list 's4m-expr-inputs (string->number (substring str 1))))) *#readers*)) > (+ #%1 (+ #%2 #%3)) which returns 66 after expanding at read time to: (+ (s4m-expr-inputs 1) (+ (s4m-expr-inputs 2) (s4m-expr-inputs 3))) From iainduncanlists at gmail.com Wed Sep 8 11:17:41 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Wed, 8 Sep 2021 11:17:41 -0700 Subject: [CM] need macro help! In-Reply-To: <7d052ed935b64955f2e2db0043e33806@ccrma.stanford.edu> References: <7d052ed935b64955f2e2db0043e33806@ccrma.stanford.edu> Message-ID: oh wow, ok I will chew on that. In the meantime, I got it working as this, but feedback for style (or bugs I can't see) would be lovely. ;building on the example from Bill: (define s4m-expr-inputs (vector '() 11 22 33)) (define (string->sexp text) "convert a string of an sexp to an sexp" (read (open-input-string text))) ; recursive iterator for processing an sexp for %X args (define (s4m-process-sexp sexp) (map (lambda(token) (cond ((and (symbol? token) (eq? ((symbol->string token) 0) #\%)) `(s4m-expr-inputs ,(string->number (substring (symbol->string token) 1)))) ((list? token) (s4m-process-sexp token)) (else token))) sexp)) (define-macro (s4m-run-sexp-macro sexp) `(eval (s4m-process-sexp ,sexp))) (define (s4m-run-expr sexp-str) (let ((input-sexp (string->sexp sexp-str))) (s4m-run-sexp-macro input-sexp))) I also noticed I could thus dispense with the oneline macro all together now by doing: (define (s4m-run-expr sexp-str) (let ((input-sexp (string->sexp sexp-str))) (eval '(eval (s4m-process-sexp input-sexp))))) Feedback on which is considered better style welcome! iain On Wed, Sep 8, 2021 at 11:03 AM wrote: > This isn't helpful, in fact it's ugly, but I can't > resist mentioning: > > (set! *#readers* > (cons (cons #\% (lambda (str) > (list 's4m-expr-inputs > (string->number (substring str 1))))) > *#readers*)) > > > (+ #%1 (+ #%2 #%3)) > > which returns 66 after expanding at read time to: > > (+ (s4m-expr-inputs 1) (+ (s4m-expr-inputs 2) (s4m-expr-inputs 3))) > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Wed Sep 8 11:19:04 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 08 Sep 2021 11:19:04 -0700 Subject: [CM] OT a few pieces In-Reply-To: References: Message-ID: <63489522693ea7122ab73bcd9c0b8ffa@ccrma.stanford.edu> Thanks for the pieces! I'm glad Snd has been useful. Took me back to the days when people were trying out new sounds. Does this happen much anymore? From elronnd at elronnd.net Wed Sep 8 13:16:40 2021 From: elronnd at elronnd.net (Elijah Stone) Date: Wed, 8 Sep 2021 13:16:40 -0700 (PDT) Subject: [CM] need macro help! In-Reply-To: References: <7d052ed935b64955f2e2db0043e33806@ccrma.stanford.edu> Message-ID: <7cf15196-c396-f9dd-23a4-6ff6024a1f9@elronnd.net> On Wed, 8 Sep 2021, Iain Duncan wrote: > (define (s4m-process-sexp sexp) It is entirely a point of style, but I think I would rather make a 'deepmap' helper function. Untested, but something like: (define (deepmap f x) (if (not (list? x)) (f x) (cons (deepmap f (car x)) (deepmap f (cdr x))))) This also has the convenient side effect of allowing you to e.g. avoid the contents of quotes. > I also noticed I could thus dispense with the oneline macro all together now by doing: > > (define (s4m-run-expr sexp-str) > ? (let ((input-sexp (string->sexp sexp-str))) > ? ? (eval '(eval (s4m-process-sexp input-sexp))))) The problem with this is that, since the eval runs in the s4m-run-expr's environment, you lose the lexical scope of the caller. It would be nice to be able to say (let ((x 5)) (s4m-run-expr "something with x")) I think you can evaluate things in the calling environment with a bacro, but that's hardly simpler than a regular macro. > (define-macro (s4m-run-sexp-macro sexp) > ? `(eval (s4m-process-sexp ,sexp))) Can just be: (define-macro (s4m-run-sexp-macro sexp) ? (s4m-process-sexp sexp)) -E From elronnd at elronnd.net Wed Sep 8 13:18:24 2021 From: elronnd at elronnd.net (Elijah Stone) Date: Wed, 8 Sep 2021 13:18:24 -0700 (PDT) Subject: [CM] need macro help! In-Reply-To: <7cf15196-c396-f9dd-23a4-6ff6024a1f9@elronnd.net> References: <7d052ed935b64955f2e2db0043e33806@ccrma.stanford.edu> <7cf15196-c396-f9dd-23a4-6ff6024a1f9@elronnd.net> Message-ID: On Wed, 8 Sep 2021, Elijah Stone wrote: > (if (not (list? x)) Erratum: should be pair? From iainduncanlists at gmail.com Wed Sep 8 14:16:23 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Wed, 8 Sep 2021 14:16:23 -0700 Subject: [CM] need macro help! In-Reply-To: References: <7d052ed935b64955f2e2db0043e33806@ccrma.stanford.edu> <7cf15196-c396-f9dd-23a4-6ff6024a1f9@elronnd.net> Message-ID: thanks Elijah, much appreciated. And thanks for catching that! iain On Wed, Sep 8, 2021 at 1:18 PM Elijah Stone wrote: > On Wed, 8 Sep 2021, Elijah Stone wrote: > > (if (not (list? x)) > > Erratum: should be pair? > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iainduncanlists at gmail.com Thu Sep 9 21:29:31 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Thu, 9 Sep 2021 21:29:31 -0700 Subject: [CM] setting heap size preemptively at startup? Message-ID: Hi folks, I'm doing more experimenting with tweaking s4m for real time use, and have yet more gc related questions. Is there a way to pre-emptively make the heap big from c or scheme, aside from compiling in a default size? It appears from my recent tests like quite a feasible approach for some use cases is to just lock the gc out for the duration of a song. I ran a pretty heavy (by my standards, it's all note rate stuff) ensemble with the gc turned off, and got bored after 15 minutes so turned it back on. The only downside I noticed was that when I turned it back on it took 0.2 seconds to run, which would be a catastrophe normally, but is quite reasonable to do between pieces. That said, I wasn't recording, so it's conceivable that heap resizing is also causing an underrun that I didn't notice. So I'm wondering if it would be reasonable to give users an option to trade size for speed by allocating a big hunk of memory and cleaning up when it doesn't matter. Of course, I'm in way over my head here, so if there are other Bad Things about this approach I'd love to hear them. Like, does a heap resize take a long time? Is there a way to see how long it took? Do they take progressively more time (ie does the heap double or somesuch thing) thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From elronnd at elronnd.net Thu Sep 9 21:41:57 2021 From: elronnd at elronnd.net (Elijah Stone) Date: Thu, 9 Sep 2021 21:41:57 -0700 (PDT) Subject: [CM] setting heap size preemptively at startup? In-Reply-To: References: Message-ID: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> On Thu, 9 Sep 2021, Iain Duncan wrote: > Is there a way to pre-emptively make the heap big from c or scheme, > aside from compiling in a default size? (set! (*s7* 'heap-size) ...) > So I'm wondering if it would be reasonable to give users an option to > trade size for speed by allocating a big hunk of memory and cleaning up > when it doesn't matter. That is very reasonable, but note that you cannot shrink the heap. > does a heap resize take a long time? It requires copying the entire heap. Probably not something you would want to do in real-time. > Do they take progressively more time (ie does the heap double or > somesuch thing) Yes, it doubles. (Obviously this also means you're asymptotically less likely to need a resize as time goes on...) -E From iainduncanlists at gmail.com Thu Sep 9 21:52:14 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Thu, 9 Sep 2021 21:52:14 -0700 Subject: [CM] setting heap size preemptively at startup? In-Reply-To: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: Thanks Elijah, that's very helpful. So this is what I'm taking away from what you said, if you don't mind correcting me anywhere I'm wrong, that would be lovely - we can lock out the gc for the duration of a piece, this is reasonable - but to do so, we should definitely establish the upper bound of the heap size you need and pre-allocate it - we really don't want to get this wrong, because doubling the heap part way through will be (probably) an underrun, as everything in the old heap gets copied to the new one - once the heap is big, only a reboot of the interpreter will bring it back down again. One thing I'm not clear on: is it necessarily a lot slower for the gc to do a run with a large heap, even if the heap is not in use? Or is the bottleneck the number of objects the gc goes trawling through? I guess another way of putting that is: is there any real disadvantage to over-allocating the heap size aside from using up RAM? Thanks so much! iain On Thu, Sep 9, 2021 at 9:42 PM Elijah Stone wrote: > On Thu, 9 Sep 2021, Iain Duncan wrote: > > > Is there a way to pre-emptively make the heap big from c or scheme, > > aside from compiling in a default size? > (set! (*s7* 'heap-size) ...) > > > So I'm wondering if it would be reasonable to give users an option to > > trade size for speed by allocating a big hunk of memory and cleaning up > > when it doesn't matter. > That is very reasonable, but note that you cannot shrink the heap. > > > does a heap resize take a long time? > It requires copying the entire heap. Probably not something you would > want to do in real-time. > > > Do they take progressively more time (ie does the heap double or > > somesuch thing) > Yes, it doubles. (Obviously this also means you're asymptotically less > likely to need a resize as time goes on...) > > -E > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > -------------- next part -------------- An HTML attachment was scrubbed... URL: From elronnd at elronnd.net Thu Sep 9 23:33:05 2021 From: elronnd at elronnd.net (Elijah Stone) Date: Thu, 9 Sep 2021 23:33:05 -0700 (PDT) Subject: [CM] [SPAM:##] Re: setting heap size preemptively at startup? In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: On Thu, 9 Sep 2021, Iain Duncan wrote: > Thanks Elijah, that's very helpful. So this is what I'm taking away from what you said, if you don't mind correcting me anywhere I'm wrong, that would be lovely > - we can lock out the gc for the duration of a piece, this is reasonable > - but to do so, we should definitely establish the upper bound of the heap size you need and pre-allocate it > - we really don't want to get this wrong, because doubling the heap part way through will be (probably) an underrun, as everything in the old heap gets copied to the new one > -? once the heap is big, only a reboot of the interpreter will bring it back down again. Yes > One thing I'm not clear on: is it necessarily a lot slower for the gc to do a run with a large heap, even if the heap is not in use? Or is the?bottleneck the number of objects the?gc goes trawling through? > I guess another way of putting that is: is there any real disadvantage to over-allocating the heap size aside from using up RAM? This is where my GC knowledge is showing its limits! I think that it is proportional to the amount of heap space that you actually use. But this depends not only on how much you cons, but also on how fragmented the heap is (since s7 gc is non-compacting), which is application-dependent. -E From bil at ccrma.Stanford.EDU Fri Sep 10 06:32:28 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Fri, 10 Sep 2021 06:32:28 -0700 Subject: [CM] =?utf-8?q?setting_heap_size_preemptively_at_startup=3F?= In-Reply-To: References: Message-ID: <8d21473a73b9dcc9087ac755a8f1ab28@ccrma.stanford.edu> Elijah is correct, but I/m worried there might be some ambiguity. The s7_cells (the s7 objects) are allocated permanently (except s7_free frees them), and the heap itself is an array of pointers to those objects. The objects themselves are not copied or moved by the GC. In normal use the GC frees 90% or so of the heap, and puts the pointers to the newly free objects in the heap free list, clearing the type of the freed object. This clear requires access to each free object, thus forcing the GC to bring it into memory -- I think that is where the cache misses are. The GC mark process appears to take only a small part of the time. When the heap has to grow, realloc makes the new heap array of pointers, so the old pointers might be copied, but most the heap resize time is spent allocating the new permanent block of s7_cells, then placing pointers to them into the heap and free_heap arrays. You can see what the GC is doing via (set! (*s7* 'gc-stats) 1). I don't think there's any problem with starting with a big heap (some of my timing tests do this because the GC is not of interest in that context), but the GC process when called will probably be slower. From wdouglass at carnegierobotics.com Fri Sep 10 06:37:51 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Fri, 10 Sep 2021 13:37:51 +0000 Subject: [CM] setting heap size preemptively at startup? In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: I've been doing some GC work as well, and I have a possible feature that i'm thinking about implementing that i'd like to run by you guys What if there was a (*s7* 'gc-hook) that ran before the gc routine got run. From that hook, it should be possible to 1) prevent the gc from running if it's a critical time 2) schedule the gc to run when the system is less busy I'm using s7 in a video rendering app, and i'd like to only have the gc run in-between frames, to keep my frame pacing as close to constant as possible Let me know what you guys think -Woody On Thu, 2021-09-09 at 21:52 -0700, Iain Duncan wrote: > CAUTION: This email originated from outside of the organization. Do > not click links or open attachments unless you recognize the sender. > > Thanks Elijah, that's very helpful. So this is what I'm taking away > from what you said, if you don't mind correcting me anywhere I'm > wrong, that would be lovely > > - we can lock out the gc for the duration of a piece, this is > reasonable > - but to do so, we should definitely establish the upper bound of the > heap size you need and pre-allocate it > - we really don't want to get this wrong, because doubling the heap > part way through will be (probably) an underrun, as everything in the > old heap gets copied to the new one > - once the heap is big, only a reboot of the interpreter will bring > it back down again. > > One thing I'm not clear on: is it necessarily a lot slower for the gc > to do a run with a large heap, even if the heap is not in use? Or is > the bottleneck the number of objects the gc goes trawling through? > I guess another way of putting that is: is there any real > disadvantage to over-allocating the heap size aside from using up > RAM? > > Thanks so much! > iain > > On Thu, Sep 9, 2021 at 9:42 PM Elijah Stone > wrote: > > On Thu, 9 Sep 2021, Iain Duncan wrote: > > > > > Is there a way to pre-emptively make the heap big from c or > > scheme, > > > aside from compiling in a default size? > > (set! (*s7* 'heap-size) ...) > > > > > So I'm wondering if it would be reasonable to give users an > > option to > > > trade size for speed by allocating a big hunk of memory and > > cleaning up > > > when it doesn't matter. > > That is very reasonable, but note that you cannot shrink the heap. > > > > > does a heap resize take a long time? > > It requires copying the entire heap. Probably not something you > > would > > want to do in real-time. > > > > > Do they take progressively more time (ie does the heap double or > > > somesuch thing) > > Yes, it doubles. (Obviously this also means you're asymptotically > > less > > likely to need a resize as time goes on...) > > > > -E > > _______________________________________________ > > Cmdist mailing list > > Cmdist at ccrma.stanford.edu > > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > > > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist From bil at ccrma.Stanford.EDU Fri Sep 10 07:00:19 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Fri, 10 Sep 2021 07:00:19 -0700 Subject: [CM] =?utf-8?q?setting_heap_size_preemptively_at_startup=3F?= In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: I'm willing to add gc-hook -- I'd also like to move all the other built-in hooks into the *s7* environment. While writing that previous message, it occurred to me that the type field could be separate from the cell, and then the amount of memory the GC has to read in is cut by a factor of 5 or 6. And then I noticed that s7_error turns the GC on -- I think that is left-over from some previous debugging, but it will take time to test. From iainduncanlists at gmail.com Fri Sep 10 07:43:43 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Fri, 10 Sep 2021 07:43:43 -0700 Subject: [CM] setting heap size preemptively at startup? In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: Hi, Woody's suggestion would be great for me. That's essentially what I'm doing manually, but it would cut down unnecessary processing a great deal if I could instead just do it when the gc wakes up. I've been using (set! (*s7* 'gc-stats) 1) to watch what goes on. Is there a way to see when a heap reallocation happens too? or do I just have to get that info from looking at the gc pass stats after it's done? thanks everyone! On Fri, Sep 10, 2021 at 7:00 AM wrote: > I'm willing to add gc-hook -- I'd also like to move > all the other built-in hooks into the *s7* environment. > > While writing that previous message, it occurred to me > that the type field could be separate from the cell, > and then the amount of memory the GC has to read in is > cut by a factor of 5 or 6. > > And then I noticed that s7_error turns the GC on -- > I think that is left-over from some previous debugging, > but it will take time to test. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Fri Sep 10 08:40:22 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Fri, 10 Sep 2021 08:40:22 -0700 Subject: [CM] =?utf-8?q?setting_heap_size_preemptively_at_startup=3F?= In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: To see heap and gc stats, set gc-stats to 3 -- I should dream up names for these bits. From iainduncanlists at gmail.com Fri Sep 10 09:59:33 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Fri, 10 Sep 2021 09:59:33 -0700 Subject: [CM] setting heap size preemptively at startup? In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: Ah, great, thanks Bill. When I feel like I have got somewhere decent I will document up what I've learned and if it's useful to have up on a non-Scheme-for-Max specific cookbook page or something, I'd be happy to make that. iain On Fri, Sep 10, 2021 at 8:40 AM wrote: > To see heap and gc stats, set gc-stats to 3 -- I should > dream up names for these bits. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iainduncanlists at gmail.com Sat Sep 11 06:39:00 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Sat, 11 Sep 2021 06:39:00 -0700 Subject: [CM] setting heap size preemptively at startup? In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: So is it correct that one cannot get the heap down to below the starting heap value without changing it and recompiling s7? I've had quite a striking change in GC time when the heap is bigger, so am curious to give a smaller heap size a try. In other news though, locking it out for the duration of a song works like a charm and allows me to run real time s4m sequencers inside Ableton Live with even very low latency values. Though for that matter, doing absolutely nothing to the GC also works fine for pretty standard Ableton Live latency settings. A large heap resize does give me an underrun but seems like I have to deliberately abuse it to make that happen, normally the gc does it's thing in time without issue. iain On Fri, Sep 10, 2021 at 9:59 AM Iain Duncan wrote: > Ah, great, thanks Bill. > > When I feel like I have got somewhere decent I will document up what I've > learned and if it's useful to have up on a non-Scheme-for-Max specific > cookbook page or something, I'd be happy to make that. > > iain > > On Fri, Sep 10, 2021 at 8:40 AM wrote: > >> To see heap and gc stats, set gc-stats to 3 -- I should >> dream up names for these bits. >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From iainduncanlists at gmail.com Sat Sep 11 06:46:07 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Sat, 11 Sep 2021 06:46:07 -0700 Subject: [CM] [OT] Coalton: new statically typed lisp Message-ID: This looks like something that might be interesting to the folks around here. It's cool that they built it (if I'm understanding correctly) so it can run with CL. https://coalton-lang.github.io/20211010-introducing-coalton/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Sat Sep 11 07:16:20 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Sat, 11 Sep 2021 07:16:20 -0700 Subject: [CM] =?utf-8?q?setting_heap_size_preemptively_at_startup=3F?= In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: > So is it correct that one cannot get the heap down to below the > starting > heap value without changing it and recompiling s7? Yes. The s7 I always use is built with -DINITIAL_HEAP_SIZE=6400. From iainduncanlists at gmail.com Sat Sep 11 07:28:43 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Sat, 11 Sep 2021 07:28:43 -0700 Subject: [CM] setting heap size preemptively at startup? In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: Thanks Bill. I shall try that out. You do mean 64 000 though right? (not 6400?) iain On Sat, Sep 11, 2021 at 7:16 AM wrote: > > So is it correct that one cannot get the heap down to below the > > starting > > heap value without changing it and recompiling s7? > > Yes. The s7 I always use is built with -DINITIAL_HEAP_SIZE=6400. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Sat Sep 11 07:41:04 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Sat, 11 Sep 2021 07:41:04 -0700 Subject: [CM] =?utf-8?q?setting_heap_size_preemptively_at_startup=3F?= In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: > You do mean 64 000 though right? (not 6400?) No, 6400 -- not sure how low it can go. From iainduncanlists at gmail.com Sat Sep 11 08:11:24 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Sat, 11 Sep 2021 08:11:24 -0700 Subject: [CM] setting heap size preemptively at startup? In-Reply-To: References: <7c6eebe2-8866-f097-7849-a55cb6e1b0af@elronnd.net> Message-ID: oh wow, OK! I need to try some low sizes.... :-) iain On Sat, Sep 11, 2021 at 7:41 AM wrote: > > You do mean 64 000 though right? (not 6400?) > > No, 6400 -- not sure how low it can go. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iainduncanlists at gmail.com Wed Sep 15 15:27:56 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Wed, 15 Sep 2021 15:27:56 -0700 Subject: [CM] question about s7_gc_protect Message-ID: Hi folks, I have some functions that recursively build trees of s7 objects from Max atoms. I am gc_protecting the top level object, but in the case that it might be a list or a hash, should I also be protecting child objects, or will they be safe as long as the parent is protected? thanks iain -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Wed Sep 15 15:41:30 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 15 Sep 2021 15:41:30 -0700 Subject: [CM] =?utf-8?q?question_about_s7=5Fgc=5Fprotect?= In-Reply-To: References: Message-ID: <8b937b7fabaeee37e956aaed8419ed86@ccrma.stanford.edu> They will be safe as long as they are accessible from the protected object. From iainduncanlists at gmail.com Wed Sep 15 16:09:07 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Wed, 15 Sep 2021 16:09:07 -0700 Subject: [CM] question about s7_gc_protect In-Reply-To: <8b937b7fabaeee37e956aaed8419ed86@ccrma.stanford.edu> References: <8b937b7fabaeee37e956aaed8419ed86@ccrma.stanford.edu> Message-ID: Great, thanks for the confirmation! :-) On Wed, Sep 15, 2021 at 3:41 PM wrote: > They will be safe as long as they are accessible from the > protected object. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From iainduncanlists at gmail.com Thu Sep 16 07:36:59 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Thu, 16 Sep 2021 07:36:59 -0700 Subject: [CM] adding regex handling to scheme for max question Message-ID: Hello colleagues, I'm thinking for many uses in Max and Pd, being able to run a regex over a string or symbol would be pretty handy. I see an example of using regex.make in the s7.html doc, but I'm not clear where this comes from, is this a C library that is standard? if anyone can point me at the right direction to make those examples that would be lovely... iain -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Thu Sep 16 07:44:05 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Thu, 16 Sep 2021 07:44:05 -0700 Subject: [CM] adding regex handling to scheme for max question In-Reply-To: References: Message-ID: <94c480a701813803a6bdf08b1a0d7848@ccrma.stanford.edu> The example starts with (require libc.scm) -- this loads libc.scm or the resultant C shared object which has various regex functions (from C's libc). From iainduncanlists at gmail.com Thu Sep 16 07:50:51 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Thu, 16 Sep 2021 07:50:51 -0700 Subject: [CM] adding regex handling to scheme for max question In-Reply-To: <94c480a701813803a6bdf08b1a0d7848@ccrma.stanford.edu> References: <94c480a701813803a6bdf08b1a0d7848@ccrma.stanford.edu> Message-ID: Ah, I see, I will try this out. thanks. A related question... is there any disadvantage to pulling in libc.scm if people don't need it? As in, does all the stuff that comes with it give the gc more that it needs to run over and increase min heap-size? (I'm assuming yes, but I keep discovering my assumptions are WRONG. lol). thanks! On Thu, Sep 16, 2021 at 7:44 AM wrote: > The example starts with (require libc.scm) -- this > loads libc.scm or the resultant C shared object which has > various regex functions (from C's libc). > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Thu Sep 16 08:19:08 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Thu, 16 Sep 2021 08:19:08 -0700 Subject: [CM] adding regex handling to scheme for max question In-Reply-To: References: <94c480a701813803a6bdf08b1a0d7848@ccrma.stanford.edu> Message-ID: <7eee0314832cf6944307f4fda2326188@ccrma.stanford.edu> You can see for yourself by running (*s7* 'memory-usage), perhaps calling (gc) first. It does add some names and so forth to the *libc* environment, but I doubt it is significant. If you want just the regex functions, you can extract them from the file that libc.scm writes, libc_s7.c. From iainduncanlists at gmail.com Thu Sep 16 08:31:26 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Thu, 16 Sep 2021 08:31:26 -0700 Subject: [CM] adding regex handling to scheme for max question In-Reply-To: <7eee0314832cf6944307f4fda2326188@ccrma.stanford.edu> References: <94c480a701813803a6bdf08b1a0d7848@ccrma.stanford.edu> <7eee0314832cf6944307f4fda2326188@ccrma.stanford.edu> Message-ID: Great, thanks Bill! iain On Thu, Sep 16, 2021 at 8:19 AM wrote: > You can see for yourself by running (*s7* 'memory-usage), > perhaps calling (gc) first. It does add some names > and so forth to the *libc* environment, but I doubt > it is significant. If you want just the regex functions, > you can extract them from the file that libc.scm writes, > libc_s7.c. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bchristensen-lists at outlook.com Thu Sep 16 10:29:28 2021 From: bchristensen-lists at outlook.com (Brad Christensen) Date: Thu, 16 Sep 2021 17:29:28 +0000 Subject: [CM] adding regex handling to scheme for max question In-Reply-To: References: Message-ID: Don't forget about case.scm, which supports regexps as part of its pattern matching. If nothing else you can take a look at its `handle-regex` to see how it was employed. Brad From iainduncanlists at gmail.com Fri Sep 17 18:29:05 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Fri, 17 Sep 2021 18:29:05 -0700 Subject: [CM] GC update, s7 flying in Ableton Live/Max for Live. :-) Message-ID: Well thanks for the help everyone, I thought folks might be interested to know that running with lower heap size and proactive gc runs every 200 to 500ms is working like an absolute charm in Max for Live. I can run heavy real time synthesis in Live with quite substantial sequencers and have Ableton Live's latency down to 64 samples (which it reports as 4.3ms latency). Dropping the heap to 16 or 32 kb cut my gc runs down to an average 0.3 ms! Even better, I added pseudo control rate DSP today to simulate (and sync up with) csound control rate processing, and running callbacks in my Scheme code every signal vectoris working beautifully. (Every 64 samples in Live, user configurable in Max standalone.) Eats some CPU, but well worth it to me! And the Ableton folks have really done a killer job of the Max integration in V11. Clocks are locked up like, well, clockwork. lol. I am of course raaather biased.... but I think this is going to be game changing for hackers who like working with commercial software. :-) iain -------------- next part -------------- An HTML attachment was scrubbed... URL: From iainduncanlists at gmail.com Fri Sep 17 18:30:41 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Fri, 17 Sep 2021 18:30:41 -0700 Subject: [CM] Question: hash-table vs lists for fast processing Message-ID: Following on the earlier post, I am looking up callbacks every 64 samples now. Given this is running a lot, is there an appreciable difference, either in speed or gc effects, in using a hash-table to find my callbacks vs an association list? thanks! iain -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Sat Sep 18 06:28:28 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Sat, 18 Sep 2021 06:28:28 -0700 Subject: [CM] Question: hash-table vs lists for fast processing In-Reply-To: References: Message-ID: There's no difference in GC; I'd expect a hash-table to be faster once you have more than 3 or 4 entries. From iainduncanlists at gmail.com Sat Sep 18 06:44:21 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Sat, 18 Sep 2021 06:44:21 -0700 Subject: [CM] Question: hash-table vs lists for fast processing In-Reply-To: References: Message-ID: Great, thanks! On Sat, Sep 18, 2021 at 6:28 AM wrote: > There's no difference in GC; I'd expect a hash-table to > be faster once you have more than 3 or 4 entries. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bchristensen-lists at outlook.com Mon Sep 20 13:19:02 2021 From: bchristensen-lists at outlook.com (Brad Christensen) Date: Mon, 20 Sep 2021 20:19:02 +0000 Subject: [CM] nrepl build error Message-ID: Greetings, The following build command I had taken from s7.html's nrepl section no longer works: gcc -o nrepl s7.c -O2 -I. -Wl,-export-dynamic -lm -ldl -DWITH_MAIN -DWITH_NOTCURSES -lnotcurses-core Luckily, the alternative given just below it does: gcc -c s7.c -O2 -I. -Wl,-export-dynamic -lm -ldl gcc -o nrepl nrepl.c s7.o -lnotcurses-core -lm -I. -ldl It seems the issue revolves around the `WITH_MAIN` and `S7_MAIN` defines. The relevant code: ``` s7.c 94951 #if WITH_MAIN && WITH_NOTCURSES 94952 #define S7_MAIN 1 94953 #include "nrepl.c" 94954 /* gcc -o nrepl s7.c -O2 -I. -Wl,-export-dynamic -lm -ldl -DWITH_MAIN -DWITH_NOTCURSES -lnotcurses-core */ 94955 #else ``` ``` notcurses_s7.c: 41 #if (!S7_MAIN) 42 static s7_int s7_integer_checked(s7_scheme *sc, s7_pointer val) 43 { 44 if (!s7_is_integer(val)) 45 s7_wrong_type_arg_error(sc, __func__, 0, val, "an integer"); 46 return(s7_integer(val)); 47 } 48 #endif ``` Perhaps a remnant of work-in-progress code? Cheers, Brad From bchristensen-lists at outlook.com Mon Sep 20 13:30:04 2021 From: bchristensen-lists at outlook.com (Brad Christensen) Date: Mon, 20 Sep 2021 20:30:04 +0000 Subject: [CM] nrepl build error In-Reply-To: References: Message-ID: I just noticed as well, running my nrepl build results in the following (perhaps an error of my own doing). I am running builds from today, 79042a3f (Sept. 20, 2021): ``` nrepl ;unbound variable lint in (set! lint (let ((old-lint lint)) (lambda* (file (outp :unset) (report-input :unset)) (if (and (eq? outp :unset) (eq? report-input :unset)) (nc-multiline-display (call-with-output-string (lambda (p) (old-lint file p)))) (old-lint file outp report-input))))) ; (set! lint (let ((old-lint lint))... ; *stdout*, line 616, position: 22732 ; run: (set! lint (let ((old-lint lint)) (l... ; run: ((set! (top-level-let 'history) (lam... ; top-level-let: #1=#, row: 0 ; ncp: # ; bols: #i(0 0 0 0 ...) ; eols: #i(0 0 0 0 ...) ; ncp-cols: 211 ; ncp-rows: 100 ; prompt: ">" ; nc: # ; col: 0 ; red-error: #(# # References: Message-ID: Thanks for the bug report. I removed s7_integer_checked from s7, but forgot I was using it in notcurses_s7.c. So just remove the #if S7_MAIN and its #endif. On the lint problem -- apparently nrepl.scm could not find lint.scm -- I think the later reference to lint needs to be wrapped in (when with-lint...). I'll have corrected versions up by tomorrow. From bchristensen-lists at outlook.com Mon Sep 20 16:44:06 2021 From: bchristensen-lists at outlook.com (Brad Christensen) Date: Mon, 20 Sep 2021 23:44:06 +0000 Subject: [CM] Specifying struct types in cload.scm C entities Message-ID: Hello again. With regards to cload.scm, the documentation states: "If the C type has a space ("struct tm*"), use (symbol "struct tm*") to construct the corresponding symbol." I perform this advice while describing C functions which deal with structure types as arguments and return values, but receive an error. For example, within a c-define: ``` (void function_taking_struct_ptr ((symbol "struct some_structure_type*"))) ``` results in an error of likeness: ``` ;symbol->string argument, "struct some_structure_type*", is a string but should be a symbol ; (do ((i 0 (+ i 1)) (type arg-types... ; /some/path/to/cload.scm, line 344, position: 14199 ; C-type->s7-type: (do ((i 0 (+ i 1)) (type... ; type: "struct some_structure_type*" ; add-one-function: ((s7-type (C-type->s7-t... ; add-one-function: (((i 0 (+ i 1)) (type a... ; add-one-function: ((if (pair? return-type... ; return-type: void ; func-name: "function_taking_struct_ptr" ; p: # ; double-funcs: () ; scheme-name: "function_taking_struct_ptr" ; int-funcs: () ; double-int-funcs: () ; functions: (("other_funcs... ``` Perhaps I've taken this usage out of context, and it is only meant for use when the C entity is a constant? I could not find uses of `(symbol "struct ...")` in any of the included 'lib*.scm'. Does dealing with struct types require 'in-C' ? Thank you for the clarification, Brad From bil at ccrma.Stanford.EDU Mon Sep 20 17:34:57 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 20 Sep 2021 17:34:57 -0700 Subject: [CM] Specifying struct types in cload.scm C entities In-Reply-To: References: Message-ID: <437c145fc3a29ab69a82ab03c3e29628@ccrma.stanford.edu> The example in cload.scm does seem to be broken, probably because the symbol prints itself as (symbol ...) -- I'll look at it tomorrow. From bradjchristensen at live.com Mon Sep 20 12:31:25 2021 From: bradjchristensen at live.com (Brad Christensen) Date: Mon, 20 Sep 2021 19:31:25 +0000 Subject: [CM] nrepl build error Message-ID: Greetings, I want to mention the following build command I had taken from s7.html's nrepl section no longer works: gcc -o nrepl s7.c -O2 -I. -Wl,-export-dynamic -lm -ldl -DWITH_MAIN -DWITH_NOTCURSES -lnotcurses-core Luckily, the alternative given just below it does: gcc -c s7.c -O2 -I. -Wl,-export-dynamic -lm -ldl gcc -o nrepl nrepl.c s7.o -lnotcurses-core -lm -I. -ldl It seems the issue revolves around the `WITH_MAIN` and `S7_MAIN` defines. The relevant code: ``` s7.c 94951 #if WITH_MAIN && WITH_NOTCURSES 94952 #define S7_MAIN 1 94953 #include "nrepl.c" 94954 /* gcc -o nrepl s7.c -O2 -I. -Wl,-export-dynamic -lm -ldl -DWITH_MAIN -DWITH_NOTCURSES -lnotcurses-core */ 94955 #else ``` ``` notcurses_s7.c: 41 #if (!S7_MAIN) 42 static s7_int s7_integer_checked(s7_scheme *sc, s7_pointer val) 43 { 44 if (!s7_is_integer(val)) 45 s7_wrong_type_arg_error(sc, __func__, 0, val, "an integer"); 46 return(s7_integer(val)); 47 } 48 #endif ``` Perhaps a remnant of in progress code? Cheers, Brad From bil at ccrma.Stanford.EDU Tue Sep 21 06:18:10 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Tue, 21 Sep 2021 06:18:10 -0700 Subject: [CM] Specifying struct types in cload.scm C entities In-Reply-To: References: Message-ID: I think this bug is fixed; the cload.scm example has been updated to reflect some other changes since 2012; remember to use "list" not "quote" here because the (symbol ...) needs to be evaluated. From chris.actondev at gmail.com Wed Sep 22 15:20:30 2021 From: chris.actondev at gmail.com (Christos Vagias) Date: Thu, 23 Sep 2021 00:20:30 +0200 Subject: [CM] s7_make_byte_vector ? Message-ID: Hi Bil, Is there a reason for not having a s7_make_byte_vector on the c side? Seeing the rest (int, float) vectors supported it seems a bit odd. Thanks, Christos From bil at ccrma.Stanford.EDU Wed Sep 22 16:50:47 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 22 Sep 2021 16:50:47 -0700 Subject: [CM] =?utf-8?b?czdfbWFrZV9ieXRlX3ZlY3RvciA/?= In-Reply-To: References: Message-ID: I can't remember any reason. The byte-vectors were added a lot later. I'll add that function. From wdouglass at carnegierobotics.com Fri Sep 24 06:41:20 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Fri, 24 Sep 2021 13:41:20 +0000 Subject: [CM] When does a let get created? Message-ID: I'm trying to write a function that makes a simple dictionary of informaton (define (make-info name location description) (curlet)) but it seems that let gets reused or something -- the values seem to change when the function gets called more then once i could just use associative lists by doing (define (make-info name location description) (let->list (curlet))) but i really like how lets work (applicable, etc...) What assumption have i gotten wrong? why doesn't a new let get created per function call? Thanks, Woody Douglass From wdouglass at carnegierobotics.com Fri Sep 24 07:29:52 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Fri, 24 Sep 2021 14:29:52 +0000 Subject: [CM] When does a let get created? In-Reply-To: References: Message-ID: I figured out that I can explicitly copy the current environment with inlet, so my function is now (define (make-info name location description) (inlet (curlet))) This works for my purposes, but is it idiomatically correct? Thanks, Woody On Fri, 2021-09-24 at 09:41 -0400, Woodrow Douglass wrote: > I'm trying to write a function that makes a simple dictionary of > informaton > > (define (make-info name location description) (curlet)) > > but it seems that let gets reused or something -- the values seem to > change when the function gets called more then once > > i could just use associative lists by doing > > (define (make-info name location description) (let->list (curlet))) > > but i really like how lets work (applicable, etc...) > What assumption have i gotten wrong? why doesn't a new let get > created > per function call? > > Thanks, > Woody Douglass From iainduncanlists at gmail.com Fri Sep 24 07:36:57 2021 From: iainduncanlists at gmail.com (Iain Duncan) Date: Fri, 24 Sep 2021 07:36:57 -0700 Subject: [CM] When does a let get created? In-Reply-To: References: Message-ID: Don't know if this is helpful because I doubt this is new to you, but I have done something like the below: ; returns inner let (define (my-obj arg val) (let ((arg val) (foo 'bar)) (curlet))) In my use case it's bigger because I actually have objects that can return their let on a specific message to allow monkey patching them from the repl. On Fri, Sep 24, 2021 at 7:30 AM Woody Douglass < wdouglass at carnegierobotics.com> wrote: > I figured out that I can explicitly copy the current environment with > inlet, so my function is now > > (define (make-info name location description) (inlet (curlet))) > > This works for my purposes, but is it idiomatically correct? > > Thanks, > Woody > > On Fri, 2021-09-24 at 09:41 -0400, Woodrow Douglass wrote: > > I'm trying to write a function that makes a simple dictionary of > > informaton > > > > (define (make-info name location description) (curlet)) > > > > but it seems that let gets reused or something -- the values seem to > > change when the function gets called more then once > > > > i could just use associative lists by doing > > > > (define (make-info name location description) (let->list (curlet))) > > > > but i really like how lets work (applicable, etc...) > > What assumption have i gotten wrong? why doesn't a new let get > > created > > per function call? > > > > Thanks, > > Woody Douglass > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wdouglass at carnegierobotics.com Fri Sep 24 07:48:58 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Fri, 24 Sep 2021 14:48:58 +0000 Subject: [CM] When does a let get created? In-Reply-To: References: Message-ID: <16ccf2b69e90ad00f4724e095fce34499670946f.camel@carnegierobotics.com> Yeah, creating a let explicitly like that works -- i'm at a point where i can move on now, i'm just trying to figure out why i saw the aliasing from my original implementation -- why doesn't returning the lambda's implicit let work in the way that i expected? Thanks, Woody On Fri, 2021-09-24 at 07:36 -0700, Iain Duncan wrote: > CAUTION: This email originated from outside of the organization. Do > not click links or open attachments unless you recognize the sender. > > Don't know if this is helpful because I doubt this is new to you, but > I have done something like the below: > > ; returns inner let > (define (my-obj arg val) > (let ((arg val) (foo 'bar)) > (curlet))) > > In my use case it's bigger because I actually have objects that can > return their let on a specific message to allow monkey patching them > from the repl. > > On Fri, Sep 24, 2021 at 7:30 AM Woody Douglass < > wdouglass at carnegierobotics.com> wrote: > > I figured out that I can explicitly copy the current environment > > with > > inlet, so my function is now > > > > (define (make-info name location description) (inlet (curlet))) > > > > This works for my purposes, but is it idiomatically correct? > > > > Thanks, > > Woody > > > > On Fri, 2021-09-24 at 09:41 -0400, Woodrow Douglass wrote: > > > I'm trying to write a function that makes a simple dictionary of > > > informaton > > > > > > (define (make-info name location description) (curlet)) > > > > > > but it seems that let gets reused or something -- the values seem > > to > > > change when the function gets called more then once > > > > > > i could just use associative lists by doing > > > > > > (define (make-info name location description) (let->list > > (curlet))) > > > > > > but i really like how lets work (applicable, etc...) > > > What assumption have i gotten wrong? why doesn't a new let get > > > created > > > per function call? > > > > > > Thanks, > > > Woody Douglass > > > > _______________________________________________ > > Cmdist mailing list > > Cmdist at ccrma.stanford.edu > > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > > From wdouglass at carnegierobotics.com Fri Sep 24 08:16:57 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Fri, 24 Sep 2021 15:16:57 +0000 Subject: [CM] When does a let get created? In-Reply-To: <16ccf2b69e90ad00f4724e095fce34499670946f.camel@carnegierobotics.com> References: <16ccf2b69e90ad00f4724e095fce34499670946f.camel@carnegierobotics.com> Message-ID: <8a26e016cfa6f7c5c0dd3a151ae96c75062fc645.camel@carnegierobotics.com> Ok, i think i've gotten to the bottom of it. The original implementation: (define (make-info name location description) (curlet)) gets marked as VERY_SAFE byt the optimizer (specifically the optimize_lambda function). According to the docs, "A safe function does not push anything on the s7 stack, and treats the arglist passed to it as immutable and temporary". I'm trying to return the arglist, which violates the "temporary" descriptor above. Maybe the optimizer needs to be less aggressive? not sure, i'm gonna stick with the "inlet" version for now. Thanks, Woody On Fri, 2021-09-24 at 14:48 +0000, Woody Douglass wrote: > Yeah, creating a let explicitly like that works -- i'm at a point > where > i can move on now, i'm just trying to figure out why i saw the > aliasing > from my original implementation -- why doesn't returning the lambda's > implicit let work in the way that i expected? > > Thanks, > Woody > > On Fri, 2021-09-24 at 07:36 -0700, Iain Duncan wrote: > > CAUTION: This email originated from outside of the organization. Do > > not click links or open attachments unless you recognize the > > sender. > > > > Don't know if this is helpful because I doubt this is new to you, > > but > > I have done something like the below: > > > > ; returns inner let > > (define (my-obj arg val) > > (let ((arg val) (foo 'bar)) > > (curlet))) > > > > In my use case it's bigger because I actually have objects that can > > return their let on a specific message to allow monkey patching > > them > > from the repl. > > > > On Fri, Sep 24, 2021 at 7:30 AM Woody Douglass < > > wdouglass at carnegierobotics.com> wrote: > > > I figured out that I can explicitly copy the current environment > > > with > > > inlet, so my function is now > > > > > > (define (make-info name location description) (inlet (curlet))) > > > > > > This works for my purposes, but is it idiomatically correct? > > > > > > Thanks, > > > Woody > > > > > > On Fri, 2021-09-24 at 09:41 -0400, Woodrow Douglass wrote: > > > > I'm trying to write a function that makes a simple dictionary > > > > of > > > > informaton > > > > > > > > (define (make-info name location description) (curlet)) > > > > > > > > but it seems that let gets reused or something -- the values > > > > seem > > > to > > > > change when the function gets called more then once > > > > > > > > i could just use associative lists by doing > > > > > > > > (define (make-info name location description) (let->list > > > (curlet))) > > > > but i really like how lets work (applicable, etc...) > > > > What assumption have i gotten wrong? why doesn't a new let get > > > > created > > > > per function call? > > > > > > > > Thanks, > > > > Woody Douglass > > > > > > _______________________________________________ > > > Cmdist mailing list > > > Cmdist at ccrma.stanford.edu > > > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > > > > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist From bil at ccrma.Stanford.EDU Fri Sep 24 10:14:25 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Fri, 24 Sep 2021 10:14:25 -0700 Subject: [CM] =?utf-8?q?When_does_a_let_get_created=3F?= In-Reply-To: <8a26e016cfa6f7c5c0dd3a151ae96c75062fc645.camel@carnegierobotics.com> References: <16ccf2b69e90ad00f4724e095fce34499670946f.camel@carnegierobotics.com> <8a26e016cfa6f7c5c0dd3a151ae96c75062fc645.camel@carnegierobotics.com> Message-ID: Yes, that's bug -- curlet should not be a safe function, or perhaps it should copy the current environment (like owlet). Thanks! The "temporary" business refers to C-side functions; in Scheme the optimizer tries to find functions that do not capture/export their arguments, and uses the old let in that case. You could use (copy (curlet)), which is essentially the same as (inlet (curlet)) but is one less character to type. From wdouglass at carnegierobotics.com Fri Sep 24 10:54:37 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Fri, 24 Sep 2021 17:54:37 +0000 Subject: [CM] When does a let get created? In-Reply-To: References: <16ccf2b69e90ad00f4724e095fce34499670946f.camel@carnegierobotics.com> <8a26e016cfa6f7c5c0dd3a151ae96c75062fc645.camel@carnegierobotics.com> Message-ID: <7f8dc68450b54f983a171f6469cf0d2ddf6fd99b.camel@carnegierobotics.com> Great! Thanks for the clarification! Thanks, Woody On Fri, 2021-09-24 at 10:14 -0700, bil at ccrma.Stanford.EDU wrote: > Yes, that's bug -- curlet should not be a safe function, > or perhaps it should copy the current environment (like owlet). > Thanks! > > The "temporary" business refers to C-side functions; in Scheme the > optimizer > tries to find functions that do not capture/export their arguments, > and > uses > the old let in that case. > > You could use (copy (curlet)), which is essentially the same as > (inlet > (curlet)) > but is one less character to type. > From chris.actondev at gmail.com Sat Sep 25 06:35:31 2021 From: chris.actondev at gmail.com (Christos Vagias) Date: Sat, 25 Sep 2021 15:35:31 +0200 Subject: [CM] s7_make_byte_vector ? In-Reply-To: References: Message-ID: Just saw the s7_make_byte_vector commit pushed. Thanks Bil! On Thu, 23 Sept 2021 at 01:50, wrote: > > I can't remember any reason. The byte-vectors were added a lot later. > I'll add that function. > From dev at mobileink.com Sun Sep 26 11:21:15 2021 From: dev at mobileink.com (Gregg Reynolds) Date: Sun, 26 Sep 2021 13:21:15 -0500 Subject: [CM] emacs support for s7 repl? Message-ID: Any tips for running s7 under emacs? I'm looking at geiser, wondering if it would be worth the trouble to derive a geiser-s7 package. Gregg -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris.actondev at gmail.com Sun Sep 26 11:52:21 2021 From: chris.actondev at gmail.com (Christos Vagias) Date: Sun, 26 Sep 2021 20:52:21 +0200 Subject: [CM] emacs support for s7 repl? In-Reply-To: References: Message-ID: Hi Gregg. You can use cmuscheme and then (run-scheme "the S7 repl binary"). But then there's the issue that when multiple lines sexps sent from emacs to S7, S7 will try to eval each line on its own and thus error. For that I compile my own main() that tries to evaluate the input, and keeps appending to the given input new until the whole sexp is given and the evaluation can occur. Bil might correct me though on this one! On Sun, Sep 26, 2021, 8:21 PM Gregg Reynolds wrote: > Any tips for running s7 under emacs? > > I'm looking at geiser, wondering if it would be worth the trouble to > derive a geiser-s7 package. > > Gregg > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Sun Sep 26 12:12:53 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Sun, 26 Sep 2021 12:12:53 -0700 Subject: [CM] =?utf-8?q?emacs_support_for_s7_repl=3F?= In-Reply-To: References: Message-ID: <7998a42ab6364dc1ddaf342ae9d6d477@ccrma.stanford.edu> The Snd repl (xen_repl in the scheme section in xen.c) uses the function stdin_check_for_full_expression (snd-xen.c) to get a full expression from emacs. It might be more straightforward in s7 to use the missing-close-paren-hook or the underlying error to do something similar. But currently the s7 emacs repl is dumb. I looked at geiser briefly, but my recollection is that it insisted on r6rs library ("module") handling. Maybe they have removed that requirement, or someone could hack around it. It would be great to have that capability in emacs. The other possibility is LSP (Miscrosoft's Language Server Protocol). Again my memory is fading, but I think it uses JSON to communicate both ways. I started json.scm, but lost interest (I guess XML would have been worse, but geez...). There is emacs support for LSP. From dev at mobileink.com Sun Sep 26 18:31:12 2021 From: dev at mobileink.com (Gregg Reynolds) Date: Sun, 26 Sep 2021 20:31:12 -0500 Subject: [CM] emacs support for s7 repl? In-Reply-To: References: Message-ID: On Sun, Sep 26, 2021 at 1:52 PM Christos Vagias wrote: > Hi Gregg. > > You can use cmuscheme and then (run-scheme "the S7 repl binary"). > Thanks, I was not aware of cmuscheme. (My workaround has been to rename my executable "scheme" and use `run-scheme`, which sorta works.) > But then there's the issue that when multiple lines sexps sent from emacs > to S7, S7 will try to eval each line on its own and thus error. > For that I compile my own main() that tries to evaluate the input, and > keeps appending to the given input new until the whole sexp is given and > the evaluation can occur. > > Bil might correct me though on this one! > > On Sun, Sep 26, 2021, 8:21 PM Gregg Reynolds wrote: > >> Any tips for running s7 under emacs? >> >> I'm looking at geiser, wondering if it would be worth the trouble to >> derive a geiser-s7 package. >> >> Gregg >> _______________________________________________ >> Cmdist mailing list >> Cmdist at ccrma.stanford.edu >> https://cm-mail.stanford.edu/mailman/listinfo/cmdist >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dev at mobileink.com Sun Sep 26 18:34:19 2021 From: dev at mobileink.com (Gregg Reynolds) Date: Sun, 26 Sep 2021 20:34:19 -0500 Subject: [CM] emacs support for s7 repl? In-Reply-To: <7998a42ab6364dc1ddaf342ae9d6d477@ccrma.stanford.edu> References: <7998a42ab6364dc1ddaf342ae9d6d477@ccrma.stanford.edu> Message-ID: On Sun, Sep 26, 2021 at 2:12 PM wrote: > The Snd repl (xen_repl in the scheme section in xen.c) > uses the function stdin_check_for_full_expression (snd-xen.c) > to get a full expression from emacs. It might be more > straightforward in s7 to use the missing-close-paren-hook or > the underlying error to do something similar. But currently > the s7 emacs repl is dumb. > > I looked at geiser briefly, but my recollection is that > it insisted on r6rs library ("module") handling. Maybe > they have removed that requirement, or someone could hack > around it. It would be great to have that capability > in emacs. > Hmm, might be a good project for the Fall. > > The other possibility is LSP (Miscrosoft's Language > Server Protocol). Again my memory is fading, but I > think it uses JSON to communicate both ways. I started > json.scm, but lost interest (I guess XML would have been > worse, but geez...). There is emacs support for LSP. > There's also nrepl , which grew out of Clojure but is apparently language-agnostic. Gregg -------------- next part -------------- An HTML attachment was scrubbed... URL: From k.s.matheussen at gmail.com Sun Sep 26 23:04:36 2021 From: k.s.matheussen at gmail.com (Kjetil Matheussen) Date: Mon, 27 Sep 2021 08:04:36 +0200 Subject: [CM] emacs support for s7 repl? In-Reply-To: References: Message-ID: On Sun, Sep 26, 2021 at 8:25 PM Gregg Reynolds wrote: > > Any tips for running s7 under emacs? > Yes, use the s7webserver. That's what it was mainly made for. From chris.actondev at gmail.com Mon Sep 27 14:57:26 2021 From: chris.actondev at gmail.com (Christos Vagias) Date: Mon, 27 Sep 2021 23:57:26 +0200 Subject: [CM] profile: prepend namespace to the function name Message-ID: Hi Bil, Was just checking the profile capabilities of s7 and noticed the following: If there are two separate namespaces (lets) both having function named foo, their timing info seems to be accumulated (since the timing info is stored as a lookup table from what I can tell, using only the functions name as a symbol). I attach a program that showcases the problem and a naive patch that uses the 'namespace/function-name as this lookup key. I'm using *ns-name* in my environment, but could be configurable with something like (*s7* 'profile-funclet-prefix-symbol). An entirely different solution would be to add the functions' actual value to the profile data, so that one can operate its funclet, but that leaves the symbol conflict to be resolved in some other way, since I had no idea what to use in the place of symbol_position and symbol_set_position What do you think? -------------- next part -------------- A non-text attachment was scrubbed... Name: profile-namespace-name.patch Type: text/x-patch Size: 671 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: profile-conflict.scm Type: text/x-scheme Size: 416 bytes Desc: not available URL: From bil at ccrma.Stanford.EDU Mon Sep 27 15:57:34 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 27 Sep 2021 15:57:34 -0700 Subject: [CM] profile: prepend namespace to the function name In-Reply-To: References: Message-ID: <727489b55b89fc03b5d6062764daa4be@ccrma.stanford.edu> An interesting problem! I lean toward (*s7* 'profile-prefix). And I'd omit "rootlet/" so that "normal" cases are easier to read. The second solution sounds problematic to me -- there's currently no space in the function cell for the profile position. From chris.actondev at gmail.com Mon Sep 27 16:32:53 2021 From: chris.actondev at gmail.com (Christos Vagias) Date: Tue, 28 Sep 2021 01:32:53 +0200 Subject: [CM] profile: prepend namespace to the function name In-Reply-To: <727489b55b89fc03b5d6062764daa4be@ccrma.stanford.edu> References: <727489b55b89fc03b5d6062764daa4be@ccrma.stanford.edu> Message-ID: I think it'd be also useful to take a moment to think about possible future module system implementation, where for example tons of modules might have an init function, and how profile output should look like. Not anything concrete, but about the possible naming styles and how it'd relate to this scenario. So, for example, a more s7-ish way would be to look for the +namespace+ or +module+ symbol's value in the funclet. Also, in my style I follow namespace/fun but others might prefer namespace:fun style. Should that be also configurable via (*s7* profile-prefix-separator) or not? About omitting "rootlet/" that could be a check in profile.scm. PS in the attached scm file above, I should have a top level (define *ns-name* 'rootlet). This is implicitly added in my setup. On Tue, 28 Sept 2021 at 00:57, wrote: > > An interesting problem! I lean toward (*s7* 'profile-prefix). And > I'd omit "rootlet/" so that "normal" cases are easier to read. > The second solution sounds problematic to me -- there's currently > no space in the function cell for the profile position. > From wdouglass at carnegierobotics.com Tue Sep 28 05:47:19 2021 From: wdouglass at carnegierobotics.com (Woody Douglass) Date: Tue, 28 Sep 2021 12:47:19 +0000 Subject: [CM] profile: prepend namespace to the function name In-Reply-To: References: <727489b55b89fc03b5d6062764daa4be@ccrma.stanford.edu> Message-ID: <54ff90743553060ef1152d7deca8abb728828c25.camel@carnegierobotics.com> What about allowing for a lambda in the environment to generate the mangled name? so i could do something like this (set! (*s7* profname-mangle) (lambda (fn name) ((funclet fn) 'namespace) ":" name) and then profname-mangle gets called for each profiled function On Tue, 2021-09-28 at 01:32 +0200, Christos Vagias wrote: > CAUTION: This email originated from outside of the organization. Do > not click links or open attachments unless you recognize the sender. > > > I think it'd be also useful to take a moment to think about possible > future module system implementation, where for example tons of > modules > might have an init function, and how profile output should look like. > Not anything concrete, but about the possible naming styles and how > it'd relate to this scenario. > So, for example, a more s7-ish way would be to look for the > +namespace+ or +module+ symbol's value in the funclet. > Also, in my style I follow namespace/fun but others might prefer > namespace:fun style. Should that be also configurable via (*s7* > profile-prefix-separator) or not? > > About omitting "rootlet/" that could be a check in profile.scm. > > PS in the attached scm file above, I should have a top level (define > *ns-name* 'rootlet). This is implicitly added in my setup. > > On Tue, 28 Sept 2021 at 00:57, wrote: > > An interesting problem! I lean toward (*s7* 'profile-prefix). And > > I'd omit "rootlet/" so that "normal" cases are easier to read. > > The second solution sounds problematic to me -- there's currently > > no space in the function cell for the profile position. > > > _______________________________________________ > Cmdist mailing list > Cmdist at ccrma.stanford.edu > https://cm-mail.stanford.edu/mailman/listinfo/cmdist From bil at ccrma.Stanford.EDU Tue Sep 28 07:25:03 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Tue, 28 Sep 2021 07:25:03 -0700 Subject: [CM] profile: prepend namespace to the function name In-Reply-To: <54ff90743553060ef1152d7deca8abb728828c25.camel@carnegierobotics.com> References: <727489b55b89fc03b5d6062764daa4be@ccrma.stanford.edu> <54ff90743553060ef1152d7deca8abb728828c25.camel@carnegierobotics.com> Message-ID: <91003c54e2dba819a78c0189766565d6@ccrma.stanford.edu> I was thinking along the lines Christos mentioned -- that there might be any number of "inits" or whatever. I can pass the profile position to the profiler functions (I think), so it won't be necessary to use the function name for that, so my current idea is to pass into scheme via (*s7* 'profile-info), the function name (a symbol), the timing data (a vector), and the ticks-per-second (as currently, so that it is backwards compatible with profile.scm), then include either the function itself for access to its file/line data and environment (but this requires GC protection), or perhaps the location data and the local profile-let-name if any. This way the profiler overhead is minimized, and profile.scm can disambiguate same-name functions; it could include a way for the caller to format output and names, etc. A function can be local to some other function, and created anew on every call of the outer function, so I'm leaning toward the file/line + profile-let-name choice. Maybe a function-local name formatter could be implemented via a local object->string method? From bil at ccrma.Stanford.EDU Wed Sep 29 02:42:08 2021 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Wed, 29 Sep 2021 02:42:08 -0700 Subject: [CM] profile: prepend namespace to the function name In-Reply-To: References: Message-ID: The profiler now returns the local let-name, if any, and the function location (file name and line-number) to scheme via (*s7* 'profile-info). (*s7* 'profile-prefix) identifies the name used for the local let name. Also each separate function in the source now has its own info. I haven't yet included the file/line stuff in profile.scm. From chris.actondev at gmail.com Wed Sep 29 13:38:13 2021 From: chris.actondev at gmail.com (Christos Vagias) Date: Wed, 29 Sep 2021 22:38:13 +0200 Subject: [CM] profile: prepend namespace to the function name In-Reply-To: References: Message-ID: Just tested it Bil, looks good! Thanks! On Wed, 29 Sept 2021 at 11:42, wrote: > > The profiler now returns the local let-name, if any, > and the function location (file name and line-number) > to scheme via (*s7* 'profile-info). (*s7* 'profile-prefix) > identifies the name used for the local let name. Also > each separate function in the source now has its own > info. I haven't yet included the file/line stuff > in profile.scm. >