On Tue, Nov 27, 2012 at 11:50 AM, Jeff Cunningham <email@example.com
> According to the Hyperspec:
> "let and let* create new variable bindings and execute a series of forms
> that use these bindings. let performs the bindings in parallel and let* does
> them sequentially. "
> I thought I knew what that meant until I tried to demonstrate it to myself.
> I wrote a simple function that eats cpu cycles for a visible period of time.
> Then I set up a let expression which I thought would evaluate these forms in
> (defun waste-time (n)
> (let ((a 0))
> (dotimes (i n a)
> (incf a (- (random 1.0) 0.5)))))
> (let ((n 100000000))
> (let ((n1 (waste-time n))
> (n2 (waste-time n)))
> (print n1)
> (print n2)))
> I have a quad-core i7 running Linux 3.2.0-33-generic #52-Ubuntu SMP Thu Oct
> 18 16:29:15 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux.
> I built a fresh copy of SBCL with --fancy (which includes threading I
> believe) which I cloned via git this morning.
> What I expected to see was two cpu cores busy for a few seconds when I run
> this. But what I in fact see is a single thread running. This indicates it
> is evaluating the let bindings serially, not in parallel.
> If I wrap the code with (time ) I get this for the parallel let:
> Evaluation took:
> 3.815 seconds of real time
> 3.816238 seconds of total run time (3.816238 user, 0.000000 system)
> 100.03% CPU
> 8,753,527,227 processor cycles
> 30,000 bytes consed
> And I get this for the serial let*:
> Evaluation took:
> 3.783 seconds of real time
> 3.780236 seconds of total run time (3.780236 user, 0.000000 system)
> 99.92% CPU
> 8,680,021,725 processor cycles
> 33,168 bytes consed
> So I don't understand what the difference is, other than the compiler not
> being willing to recognize sequential bindings in the case of let vs let*.
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> Sbcl-help mailing list