<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Brad!</div><div dir="ltr"><br></div><div dir="ltr">On Thu, 15 Oct 2020 at 03:11, Bradley Lucier <<a href="mailto:lucier@math.purdue.edu">lucier@math.purdue.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 9/30/20 9:26 AM, Adam wrote:<br>
> Dear Marc,<br>
> <br>
> Is it that Gambit tends to allocate a list's elements, in sequential <br>
> memory order, and |cdr| internally tends to be a +1 pointer operation?<br>
<br>
If you have a (list arg1 ... argn) then yes, I believe that gsc <br>
generates code to allocate the pairs in the list adjacently in memory.<br></blockquote><div><br></div><div>At allocation time they will tend to be in sequential memory, yes, I share your understanding on this one.</div><div><br></div><div>I also believe a GC will tend to keep a chain of cells essentially in sequence also.</div><div><br></div><div>I would be curious to learn if Gambit implements any particular special tricks to "help" locality - I thiiink Marc mentioned something to this effect in the past but I don't remember. Something about that a |cdr| call reduces to a memory address + operation.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> I recall you said something to this effect in the past.<br>
> <br>
> Thought came to mind now, that what about that Gambit could have use of <br>
> an |apply| form that takes a vector as argument, due to prevalence of <br>
> speed benefit of vector over list.<br>
> <br>
> Please share your thoughts on this one.<br>
<br>
I don't see how this would work, each pair in a list is still allocated <br>
using three words (one for the tag, one for the car, one for the cdr).<br></blockquote><div><br></div><div>What I meant was a form (apply-vector thunk vector), such that (apply-vector + '#(1 2 3)) leads to (+ 1 2 3).</div><div><br></div><div>While |apply-vector| would admittedly be a nuance less lispy than |apply|, then it would have certain performance benefits, e.g. space density of a vector is higher than that of a list.</div><div><br></div><div>Since this kind of form would need to be implemented in Gambit's runtime, it's quite lowlevel, I wanted to bring it up with Marc directly here on the ML"</div><div><br></div><div>I added it as a feature request in a GitHub issue now: <a href="https://github.com/gambit/gambit/issues/644">https://github.com/gambit/gambit/issues/644</a></div><div><br></div><div>Adam</div></div></div></div></div>