A couple weeks ago I emailed the list asking for help with signaling a
condition variable upon a thread's exit. Since then the parallelization
system has been completely redesigned so that threads can be recycled.
As a result, I don't need this feature anymore.
There is, however, one feature that would be nice to have.
Occasionally, I spawn up to around 200 threads (pick any number that's
stable), and there's a mechanism for letting those threads
self-terminate when there's no need to keep them around - a timed wait
on semaphore. If the thread doesn't get the semaphore after 60 seconds,
it throws :thread-no-longer-needed, which is caught higher in the stack,
and the thread unwinds and terminates nicely. Would it be possible to
have a timed-condition-wait in SBCL?
Possible implementation issues:
When I used OpenMCL's timed-wait-on-semaphore with 200 threads spawning
up, the ephemeral garbage collector (EGC) would get triggered,
consistently burning time on 1.5 of our 4 CPU cores. This was due to
some bignum arithmetic and the fact that the default allocation size was
64k (EGC is triggered by default @ 1 megabyte so 200 threads computing
wait times triggers an EGC). Since then, Gary Byers has given us a way
to dynamically change the default allocation size, and I think he may
have switched away from bignum arithmetic, since it's not really
necessary (granularity of timing is around 10ms - can elaborate more if
According to section 11.6 of the documentation (Implementation Linux
x86), the default allocation size is 8k, so this should help avoid
triggering a GC. Plus, maybe SBCL's default garbage collection
threshold is higher.
I briefly looked at the spec for futex-wait, and it seems some
implementations take a timeout variable, so maybe this wouldn't be too
bad. The intracacies of LISP interrupts can be bewildering though.
If you'd like to look at OpenMCL's implementation of
timed-wait-on-semaphore, it can be found in
Thanks again for your attention,