<?xml version="1.0"?>
<rss version="0.92">
 <channel>
  <title>Nikodemus Siivola</title>
  <description>Curios, oddities, vagaries and anomalies
-- all to amuse the old and delight the young. Lisp hacks sold during
intermission.</description>
  <link>http://random-state.net/</link>
  <item>
  <title>Holiday Hack: Bit Position</title>
   <category>hacking</category>
   <link>http://random-state.net/log/holiday-hack-bit-position.html</link>
   <pubDate>Fri, 30 Dec 2011 12:35:55 +0300</pubDate>
   <description>
&lt;p&gt;Logically speaking, &lt;tt&gt;POSITION&lt;/tt&gt; with trivial &lt;tt&gt;:KEY&lt;/tt&gt;
and &lt;tt&gt;:TEST&lt;/tt&gt; arguments should be much faster on bit-vectors than
on simple vectors: the system should be able to pull one words worth
of bits out of the vector at a single go, check if any are set (or
unset), and if so locate the one we're interested in -- else going on
to grab the next word.&lt;/p&gt;

&lt;p&gt;Practically speaking, no-one who needed fast &lt;tt&gt;POSITION&lt;/tt&gt; on
bit-vectors seems to have cared enough to implement it, and so until
yesterday (1.0.54.101) SBCL painstakingly pulled things one bit at a
time from the vector, creating a lot of unnecessary memory traffic and
branches.&lt;/p&gt;

&lt;p&gt;How much of a difference does this make? I think the technical term
is "quite a bit of a difference." See &lt;a
href="http://random-state.net/files/sbcl-bit-position-report.html"&gt;here&lt;/a&gt;
for the benchmark results. First chart is from the new implementation,
second from the new one. Other calls to &lt;tt&gt;POSITION&lt;/tt&gt; are included
for comparison: ones prefixed with &lt;tt&gt;generic-&lt;/tt&gt; all go through
the full generic &lt;tt&gt;POSITION&lt;/tt&gt;, while the others know the type of
the sequence at the call-site, and are able to sidestep a few
things.&lt;/p&gt;

&lt;p&gt;So, if you at some point considered using bit-vectors, but decided
against them because &lt;tt&gt;POSITION&lt;/tt&gt; wasn't up to snuff, now might
be a good time to revisit that decision.&lt;/p&gt;

&lt;p&gt;Gory details at the end of &lt;tt&gt;src/code/bit-bash.lisp&lt;/tt&gt;, full
story (including how the system dispatches to the specialized version)
best read from git.&lt;/p&gt;

&lt;p&gt;Also, if you're looking for an SBCL project for next year, consider
the following:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;Using a similar strategy for &lt;tt&gt;POSITION&lt;/tt&gt; on base-strings:
     on a 64-bit system one memory read will net you 8 base-chars.&lt;/li&gt;
 &lt;li&gt;Using similar strategy for &lt;tt&gt;POSITION&lt;/tt&gt; on all vectors
     with element-type width of half-word or less.&lt;/li&gt;
 &lt;li&gt;Improving the performance of the generic &lt;tt&gt;POSITION&lt;/tt&gt; for
     other cases, using eg. specialized out-of-line versions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy Hacking and New Year!&lt;/p&gt;
  </description>
  </item>
<item>
  <title>SBCL Threading News</title>
   <category>hacking</category>
   <link>http://random-state.net/log/sbcl-threading-news.html</link>
   <pubDate>Mon, 5 Dec 2011 18:47:29 +0300</pubDate>
   <description>
&lt;p&gt;&lt;a href="http://www.sbcl.org/news.html#1.0.54"&gt;SBCL 1.0.54&lt;/a&gt; is
barely out of the door, but I'm actually going to mention something
that went in the repository today, and will be in the next
release:&lt;/p&gt;

&lt;p&gt;(TL;DR: Threads on Darwin are looking pretty solid right now.  Go
give them a shake and let me know what falls out.)&lt;/p&gt;

&lt;pre&gt;commit 8340bf74c31b29e9552ef8f705b6e1298547c6ab
Author: Nikodemus Siivola &lt;nikodemus@random-state.net&gt;
Date:   Fri Nov 18 22:37:22 2011 +0200

  semaphores in the runtime
    
    Trivial refactorings:
    
    * Rename STATE_SUSPENDED STATE_STOPPED for elegance. (Spells with
      the same number of letters as STATE_RUNNING, things line up
      nicer.)
    
    * Re-express make_fixnum in terms of MAKE_FIXNUM so that we can
      use the latter to define STATE_* names in a manner acceptable to
      use in switch-statements.
    
    * Move Mach exception handling initialization to darwin_init from
      create_initial_thread so that current_mach_task gets initialized
      before the first thread struct is initialized.
    
    The Beef:
    
      Replace condition variables in the runtime with semaphores.
    
      On most platforms use sem_t, but on Darwin use semaphore_t. Hide
      the difference behind, os_sem_t, os_sem_init, os_sem_destroy,
      os_sem_post, and os_sem_wait.
    
      POSIX realtime semaphores are supposedly safe to use in signal
      handlers, unlike condition variables -- and experimentally at
      least Mach semaphores on Darwin are a lot less prone to
      problems.
    
      (Our pthread mutex usage isn't quite kosher either, but it's the
      pthread_cond_wait and pthread_cond_broadcast pair that seemed to
      be causing most of the trouble.)&lt;/pre&gt;

&lt;p&gt;(There are some other neat things lurking in HEAD in addition to this, but
I'll let you discover them for yourself.)&lt;/p&gt;
  </description>
  </item>
<item>
  <title>December Potpourri</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3531716037.html</link>
   <pubDate>Thu, 1 Dec 2011 10:13:57 +0300</pubDate>
   <description>
&lt;p&gt;&lt;b&gt;Features of Common Lisp&lt;/b&gt; Abhishek Reddy used to have a page
up on the topic, based on Robert Strandh's list.  It's been down for a
while now, so I rescued a copy from the Wayback Machine and put it
up. So: &lt;a
href="http://random-state.net/features-of-common-lisp.html"&gt; Features
of Common Lisp&lt;/a&gt;.

&lt;p&gt;&lt;b&gt;Reporting Bugs, Howto.&lt;/b&gt; I think it is actually a good thing
that I need to say this, because it tends to be a sign of new people
in the community, but if you've never read it, go &lt;em&gt;now&lt;/em&gt; and
read Simon Tatham's &lt;a
href="http://www.chiark.greenend.org.uk/~sgtatham/bugs.html"&gt;How to
Report Bugs Effectively&lt;/a&gt;.

&lt;p&gt;TL;DR. &lt;em&gt;*sigh*&lt;/em&gt; Short version: provide directions to
reproduce such that your idiot cousing could follow them while drunk.
Don't be afraid of giving too much details. Don't speculate on causes.

&lt;p&gt;Specific hints.

&lt;ul&gt;
 &lt;li&gt;Use &lt;tt&gt;(lisp-implementation-version)&lt;/tt&gt; to check the
     version of the Lisp you're actually running.
 &lt;li&gt;Use "uname -a" to get information about the OS and architecture
     you're running on.
 &lt;li&gt;When providing information, copy-paste as much as possible
     directly from the terminal or Emacs.
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;SBCL 1.0.54 due in a few days.&lt;/b&gt; This means we're in our
monthly freeze, and testing is much appreciated. This month's release
contains &lt;em&gt;a lot&lt;/em&gt; of changes -- including plenty of threading
work.

&lt;p&gt;&lt;b&gt;Microbench.&lt;/b&gt; A while ago I mentioned a microbenchmarking suite
I'd been working on on-again, off-again. It's still not much to look
at, and comes with zero documentation -- but curious souls can now &lt;a
href="https://github.com/nikodemus/microbench"&gt;get it from Github&lt;/a&gt;
It &lt;em&gt;should&lt;/em&gt; work on SBCL, CMUCL, CCL, and Lispworks. Clisp and
ACL not tested yet, but a port should be fairly trivial.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;What Microbench Is Good For, and Why You Should Not Trust
Benchmarks at All.&lt;/b&gt; Look &lt;a
href="http://random-state.net/files/microbench-2011-11-29.html"&gt;
here&lt;/a&gt; (EDIT: Same on &lt;a
href="http://random-state.net/files/microbench-2011-11-29-log.html"&gt;logarithmic
scale&lt;/a&gt;, per request.). Pay special attention to &lt;tt&gt;double-sans-result+&lt;/tt&gt; and
&lt;tt&gt;double-unsafe-sans-result+&lt;/tt&gt;. When I published some of the
results earlier, I was a bit surprised that they didn't perform much
better then &lt;tt&gt;double+&lt;/tt&gt;. Then I ran the same benchmarks on CCL
and saw it running those two benchmarks 5 times faster!

&lt;p&gt;With a bit of help from Paul Khuong the difference turned out to be
in SBCL's loading of floating-point constants, which is heavily
optimized for inline-use. I have a pending patch that makes this
smarter, the effect of which you can at link see above. (First set is
with the patch, second without.)

&lt;p&gt;The moral of "be sure what it is you're &lt;em&gt;really&lt;/em&gt;
benchmarking" is an old one, but bears repeating. What makes
microbenchmarks attractive to me, however -- despite their many
shortcomings -- is that when something turns out slow (in comparison
to another implementation, a previous version of SBCL, or another
comparable benchmark) is tends to be easier to figure out the cause
than with a macrobenchmark.&lt;/p&gt;

&lt;p&gt;You probably also noticed that CCL seems to do &lt;em&gt;really badly&lt;/em&gt;
at inline floating point arithmetic if my benchmarks are to be trusted.
They're not. I'm 99% sure this is a case of the something specific in
the way those benchmarks are implemented heavily pessimizing them for
CCL.
  </description>
  </item>
<item>
  <title>SBCL Numeric Performance Today</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3530433886.html</link>
   <pubDate>Wed, 16 Nov 2011 14:04:46 +0300</pubDate>
   <description>
&lt;p&gt;I've been working on and off on a new microbenchmark tool --
primarily for SBCL, but usable for other implementations as well.
Last night I finally got around to teaching it how to generate
pretty pictures, using Google Visualization API, and wrote a number
of microbenchmarks that show the &lt;i&gt;variety&lt;/i&gt; of numeric performance
in SBCL.&lt;/p&gt;

&lt;p&gt;Here it is: &lt;a
href="http://random-state.net/files/add-perf-1.0.53.31-dirty.html"&gt;Performance
of addition variants in SBCL 1.0.53.31&lt;/a&gt; The higher the bar, the
better the performance -- the numbers are million iterations of the
benchmark per second of run-time.&lt;/p&gt;

&lt;p&gt;Each benchmark does a roughly comparable task: adds two
numbers. What varies is what the types of the numbers are, and how
much the compiler knows about the situation. (In some benchmarks there
may be an extra comparison or so per iteration to keep the compiler
from getting and flushing out the code as effectless.) There are
basically four classes of performance:&lt;/p&gt;

&lt;ul&gt;

 &lt;li&gt;&lt;b&gt;Superb:&lt;/b&gt; Modular inline integer arithmetic. This is
     performance essentially identical with what you'd expect from C
     or ASM.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;Good:&lt;/b&gt; Compiler knows the types, the argument types are
     inline-arithmetic-friendly, the result type is not in doubt
     (addition of two fixnums can be a bignum), and the function doing
     the addition is inlined at the site where the results are unboxed
     and the result is used.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;Decent:&lt;/b&gt; Compiler knows the types, the types are
     inline-arithmetic-friendly and have an immediate representation,
     but the function doing the addition is out of line.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;Bad&lt;/b&gt; Generic arithmetic on anything else but fixnums small
    enough for the result to be a fixnum is just not that great.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;What should be of interest to anyone optimizing floating point
performance is that type-checking doesn't really cost anything
measurable most of the time. All of those benchmarks do full type
typechecks except for &lt;tt&gt;double-unsafe-sans-result+&lt;/tt&gt;, and the
gain over the safe variant is minuscule.&lt;/p&gt;

&lt;p&gt;What matters is that you generate inline
arithmetic so that your floating points don't get boxed. On x86-64
SBCL has immediate single-floats, so occastional boxing isn't quite as
disastrous (compare &lt;tt&gt;single+&lt;/tt&gt; and &lt;tt&gt;double+&lt;/tt&gt;), but
getting rid of the boxed representations completely is a huge win --
just compare &lt;tt&gt;single+&lt;/tt&gt; to &lt;tt&gt;complex-double-inline+&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;Postscript: I know not everyone reading this will be clear on
unboxed, boxed, immediate, non-immediate, etc. My apologies. I will
try to remedy the situation and write about the different
representations and how and why they matter at a later date.&lt;/p&gt;

&lt;p&gt;Post-Postscript: I will be publishing the benchmark tool once it
settles down, and once I have a chance to test-drive it with
something besides SBCL. Could be a while, though. If you urgently
need it, get in tough and we'll arrange something.&lt;/p&gt;
  </description>
  </item>
<item>
  <title>What Does Extensible CAS Mean?</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3530170348.html</link>
   <pubDate>Sun, 13 Nov 2011 12:52:28 +0300</pubDate>
   <description>
&lt;p&gt;Yesterday I said SBCL now had extensible CAS. &lt;i&gt;Was sind
paranormale Tonbandstimmen&lt;/i&gt;, what is CAS, and why should you care
if it's extensible? Turn off the music and I'll tell you.&lt;/p&gt;

&lt;p&gt;CAS is short for compare-and-swap. Compare-and-swap is a fairly
common atomic operation. It compares the current value of a memory
location with another value, and if they are the same it replaces the
value of that memory location with a specified new value.&lt;/p&gt;

&lt;p&gt;Depending on the language and the exact design of the interface, it
might just return true for success, or it might return the old
value. In SBCL it does the latter, which is sometimes very convenient,
but also means you need to compare the return value to the
expected-old-value you specified to know if CAS succeeded.&lt;/p&gt;

&lt;p&gt;Because it is atomic, if you have two threads doing CAS on the
same memory location in parallel, only one can succeed:&lt;/p&gt;

&lt;pre&gt;(let* ((x (list nil))
       (a (join-thread (make-thread (lambda () (cas (car x) nil :a)))))
       (b (join-thread (make-thread (lambda () (cas (car x) nil :b))))))
  ;; Because CAS is atomic, we know that exactly one of the threads
  ;; will succeed -- but we can't know which beforehand.
  (cond ((not a)
         ;; A returned NIL, therefore it replaced the CAR with :A
	 ;; and therefore B must return :A and do nothing.
         (assert (and (eq :a (car x)) (eq :a b))))
        ((not b)
         ;; ...and vice versa.
         (assert (and (eq :b (car x)) (eq :b a))))
        (t
         (error "WTF? Broken CAS?"))))&lt;/pre&gt;

&lt;p&gt;If you have the least bit of threads on your mind, you
can imagine how this can be quite useful.&lt;/p&gt;

&lt;p&gt;Out of the box current bleeding edge SBCL supports CAS on a number
places: &lt;tt&gt;car&lt;/tt&gt;, &lt;tt&gt;cdr&lt;/tt&gt;, &lt;tt&gt;first&lt;/tt&gt;, &lt;tt&gt;rest&lt;/tt&gt;,
&lt;tt&gt;svref&lt;/tt&gt;, &lt;tt&gt;slot-value&lt;/tt&gt;,
&lt;tt&gt;standard-instance-access&lt;/tt&gt;,
&lt;tt&gt;funcallable-standard-instance-access&lt;/tt&gt;, &lt;tt&gt;symbol-value&lt;/tt&gt;,
&lt;tt&gt;symbol-plist&lt;/tt&gt;, and &lt;tt&gt;defstruct&lt;/tt&gt;-defined slot accessors
with slot types &lt;tt&gt;fixnum&lt;/tt&gt; and &lt;tt&gt;t&lt;/tt&gt;. &lt;i&gt;(Note:
&lt;tt&gt;slot-value&lt;/tt&gt; is not currently supported by CAS if
&lt;tt&gt;slot-value-using-class&lt;/tt&gt; or friends are involved -- that's
still in the works.)&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;With the exception of &lt;tt&gt;slot-value&lt;/tt&gt; all of those
pretty much come down to a single &lt;tt&gt;LOCK:CMPXCGH&lt;/tt&gt; instruction
on Intel architectures.&lt;/p&gt;

&lt;p&gt;...but what it you have a data structure -- say a queue of some
sort -- and want to implement &lt;tt&gt;cas-queue-head&lt;/tt&gt; which does CAS
on the first element of the queue. Fine. You can do that without
any CAS support from the implementation by using eg. a lock.&lt;/p&gt;

&lt;p&gt;...but what if you want to write a macro that operates on a CAS-able
place?&lt;/p&gt;

&lt;pre&gt;(defmacro my-atomic-incf (place &amp;optional (delta 1))
  "Spins till it succeeds in atomically incrementing PLACE by
DELTA. PLACE must be CASable."
  ;; OOPS! We're multiply-evaluating PLACE.
  (with-gensyms (old new n-delta))
    `(let* ((,old ,place)
            (,n-delta ,delta)
            (,new (+ ,old ,n-delta)))
      (loop until (eq ,old
                      (setf ,old (cas ,place ,old ,new)))
            do (setf ,new (+ ,old ,n-delta)))
      ,new))&lt;/pre&gt;

&lt;p&gt;Now imagine some hapless user doing:&lt;/p&gt;

&lt;pre&gt;(loop with i = 0
      while (&lt; i (length vec))
      do (my-atomic-incf (svref vec (1- (incf i)))))&lt;/pre&gt;

&lt;p&gt;Where instead of I increasing by 1 each time through the loop and
iterating across the whole vector, it could increase I by
who-knows-how-many on a single attempt skipping entries and even
running out of bounds. Ouch.&lt;/p&gt;

&lt;p&gt;Turns out that to write a macro that operates on a CASable place
you need something analogous to &lt;tt&gt;get-setf-expansion&lt;/tt&gt;, except
for CAS instead of SETF. As of yesterday, SBCL has
&lt;tt&gt;sb-ext:get-cas-expansion&lt;/tt&gt; that you can use to write a macro
like &lt;tt&gt;my-atomic-incf&lt;/tt&gt; correctly and safely.&lt;/p&gt;

&lt;pre&gt;(defmacro my-atomic-incf (place &amp;optional (delta 1) &amp;environment env)
  (multiple-value-bind (vars vals old new cas-form read-form)
      (sb-ext:get-cas-expansion place env)
    (with-gensyms (n-delta)
      `(let* (,@(mapcar 'list vars vals)
               (,old ,read-form)
               (,n-delta ,delta)
               (,new (+ ,old ,n-delta)))
          (loop until (eq ,old (setf ,old ,cas-form))
                do (setf ,new (+ ,old ,n-delta)))
          ,new))))&lt;/pre&gt;

&lt;p&gt;What's more, we've now have the notion of a generalized CASable
place, just like Common Lisp has the notion of a generalized SETFable
place.&lt;/p&gt;

&lt;p&gt;This means that the person who has written &lt;tt&gt;cas-queue-head&lt;/tt&gt; can
use &lt;tt&gt;defcas&lt;/tt&gt;, &lt;tt&gt;define-cas-expander&lt;/tt&gt;, or even just:&lt;/p&gt;

&lt;pre&gt;(defun (sb-ext:cas queue-head) (old new queue)
  (cas-queue-head queue old new))&lt;/pre&gt;

&lt;p&gt;to make &lt;tt&gt;queue-head&lt;/tt&gt; a CASable place on equal footing with
the baked-in ones -- so that&lt;/p&gt;

&lt;pre&gt;(my-atomic-incf (queue-head queue))&lt;/pre&gt;

&lt;p&gt;will &lt;i&gt;Just Work&lt;/i&gt;. (Assuming your &lt;tt&gt;cas-queue-head&lt;/tt&gt; works and is atomic, of
course. The system will not magically make it atomic -- meaning you will either have
to use CAS internally, or lock, or... well, it depends on what you're doing.)&lt;/p&gt;

&lt;p&gt;I think that's pretty nifty. I'm still looking at adding support
for &lt;tt&gt;(cas slot-value-using-class)&lt;/tt&gt;, which will be even niftier.
Who says there's no innovation in open source? (Maybe I'm feeling a
bit hubristic right now. I'll come down soon enough when the first
bug-reports hit the fan.)&lt;/p&gt;

&lt;p&gt;Feel free to turn Laurie Anderson back on now.&lt;/p&gt;
  </description>
  </item>
<item>
  <title>Extensible CAS and Timeouts All Over The Place</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3530095339.html</link>
   <pubDate>Sat, 12 Nov 2011 16:02:19 +0300</pubDate>
   <description>
&lt;p&gt;More IndieGoGo funded goodies have landed in the SBCL
   repository:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;tt&gt;COMPARE-AND-SWAP&lt;/tt&gt; is now user-extensible, and also supports &lt;tt&gt;SLOT-VALUE&lt;/tt&gt;
      &lt;tt&gt;STANDARD-INSTANCE-ACCESS&lt;/tt&gt;, and &lt;tt&gt;FUNCALLABLE-STANDARD-INSTANCE-ACCESS&lt;/tt&gt;
      out of the box.&lt;/li&gt;
  &lt;li&gt;All blocking functions in the threading API and the &lt;tt&gt;SB-CONCURRENCY&lt;/tt&gt; contrib
      support timeouts and deadlines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More to come...&lt;/p&gt;
  </description>
  </item>
<item>
  <title>SBCL Threading Work, First Merge</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3529868963.html</link>
   <pubDate>Thu, 10 Nov 2011 01:09:23 +0300</pubDate>
   <description>
&lt;p&gt;I just merged the &lt;a
href="http://sbcl.git.sourceforge.net/git/gitweb.cgi?p=sbcl/sbcl.git;a=commitdiff;h=d6f9676ae94419cb5544c45821a8d31adbc1fbe8"&gt;first
part of the IndieGoGo funded SBCL threading work&lt;/a&gt;. This
entailed:&lt;/p&gt;

&lt;ul&gt;

 &lt;li&gt;&lt;tt&gt;GRAB-MUTEX&lt;/tt&gt; now supports timeouts on all platforms.&lt;/li&gt;

 &lt;li&gt;&lt;tt&gt;CONDITION-WAIT&lt;/tt&gt; now supports timeouts.&lt;/li&gt;

 &lt;li&gt;Killing lutexes, replacing them with userspace synchronization.
     This main affects non-Linux platforms. Performance implications
     are a mixed bag, depending on what you're doing. Some things
     perform an order of magnitude better, some things about the same,
     some things somewhat worse. The stability improvements on Darwin
     are well worth the costs, though and I will try to address the
     cases where performance suffers in due course.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's more to come -- stay tuned. ...and please report any
   regressions to &lt;a href="https://bugs.launchpad.net/sbcl"&gt;SBCL
   bug-tracker on Launchpad&lt;/a&gt; or on the mailing lists.&lt;/p&gt;

&lt;p&gt;EDIT: ...and just now I realized I left out the list of
   contributors I was supposed to include. Gah. Will add to
   later commit in the series. Sorry.&lt;/p&gt;
  </description>
  </item>
<item>
  <title>SB-TEXINFO</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3529325598.html</link>
   <pubDate>Thu, 3 Nov 2011 18:13:18 +0300</pubDate>
   <description>
&lt;p&gt;Docstring processors are thirteen to a dozen, and those derived
from SBCL's docstrings.lisp are a legion of their own.&lt;/p&gt;

&lt;p&gt;I've been guilty of copying SBCL's docstrings.lisp to various
projects myself, hand tweaking it to suit their needs... till finally
I found myself with a half a dozen divergent copies. Eugh.&lt;/p&gt;

&lt;p&gt;So, &lt;a
href="http://nikodemus.github.com/sb-texinfo/"&gt;SB-TEXINFO&lt;/a&gt; was
born: it &lt;i&gt;should&lt;/i&gt; contain tweaks from all my copies, merged back
on top of SBCL's upstream copy.&lt;/p&gt;

&lt;p&gt;I plan to merge it back to SBCL as a contrib once I'm happy with
it, but the schedule is still open on that.&lt;/p&gt;

  </description>
  </item>
<item>
  <title>Crowdfunding Success, Work In Progress</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3523852985.html</link>
   <pubDate>Thu, 1 Sep 2011 11:03:05 +0300</pubDate>
   <description>
&lt;p&gt;My &lt;a
href="http://www.indiegogo.com/SBCL-Threading-Improvements-1"&gt;SBCL
crowdfunding campaign&lt;/a&gt; at IndieGoGo is over, with $16,507 raised
and all goals met! (There were some folks who wanted to donate either
after the deadline or via a different channel who aren't included in
that sum, so the actual number is closer to $17k before IndieGoGo's,
PayPal's, and taxman's cuts. I expect my final share to be around
$12-13k after dust settles.)&lt;/p&gt;

&lt;p&gt;Thank You, Everyone. I can't say this often enough. Your support
has been overwhelming, and is greatly appreciated.&lt;/p&gt;

&lt;p&gt;Sorting out all the perks is probably going to take most of today
and tomorrow, then it's back to work on the project.&lt;/p&gt;

&lt;p&gt;To summarize, here are the things that are going to happen, in the
approximate order I expect to commit them. (This is a superset of the
list at IndieGogo, because it includes some intermediate steps which
are likely to get their own commits.)&lt;/p&gt;

&lt;ul&gt;

 &lt;li&gt;&lt;b&gt;DONE AND MERGED.&lt;/b&gt; &lt;tt&gt;SB-THREAD:MUTEX&lt;/tt&gt; outside futex-platforms to be built on
     top of userspace spinlocks. &lt;tt&gt;CONDITION-WAIT&lt;/tt&gt; is also
     getting a userspace implementation when futexes are not
     available.  This will fix interrupt-safety issues with locks on
     non-futex platforms such as Darwin and Solaris.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;DONE AND MERGED.&lt;/b&gt; &lt;tt&gt;CONDITION-WAIT&lt;/tt&gt;, &lt;tt&gt;WAIT-ON-SEMAPHORE&lt;/tt&gt;, and
     &lt;tt&gt;JOIN-THREAD&lt;/tt&gt; in &lt;tt&gt;SB-THREAD&lt;/tt&gt;, and
     &lt;tt&gt;RECEIVE-MESSAGE&lt;/tt&gt;, &lt;s&gt;&lt;tt&gt;RECEIVE-PENDING-MESSAGES&lt;/tt&gt;&lt;/s&gt; in
     &lt;tt&gt;SB-CONCURRENCY&lt;/tt&gt; to support timeouts and deadlines on all
     platforms.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;DONE AND MERGED.&lt;/b&gt; Lock
     unification: &lt;tt&gt;SB-THREAD::SPINLOCK&lt;/tt&gt; to become an alias for
     mutexes. Old names will be supported for a while, being
     deprecated gradually.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;DONE AND MERGED.&lt;/b&gt;CAS support extended to &lt;tt&gt;SLOT-VALUE&lt;/tt&gt;,
   &lt;tt&gt;STANDARD-INSTANCE-ACCESS&lt;/tt&gt;, &lt;tt&gt;FUNCALLABLE-STANDARD-INSTANCE-ACCESS&lt;/tt&gt;,
   and made user-extensible.&lt;/li&gt;
 
 &lt;li&gt;&lt;b&gt;DONE AND MERGED.&lt;/b&gt;Allegro-style gates to be added to &lt;tt&gt;SB-THREAD&lt;/tt&gt; or
     &lt;tt&gt;SB-CONCURRENCY&lt;/tt&gt;.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;Mostly done, merge pending.&lt;/b&gt;&lt;tt&gt;SB-THREAD:MUTEX&lt;/tt&gt; to be
     renamed &lt;tt&gt;SB-THREAD:LOCK&lt;/tt&gt; with similar renamings in the
     functions and macros. This is mainly motivated by the need for
     incompatible API-changes to lock acquisition and release. Old
     names will be supported for a fair while, being deprecated very
     gradually. Feature
     &lt;tt&gt;:SB-THREAD-LOCK&lt;/tt&gt; can be used to detect the presence or
     absence of the new API.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;Bughunt in progress.&lt;/b&gt; Locks outside futex-platforms are to be mostly fair by
     default.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;Work in progress.&lt;/b&gt;Read/write locks to be added to &lt;tt&gt;SB-THREAD&lt;/tt&gt; or
     &lt;tt&gt;SB-CONCURRENCY&lt;/tt&gt;.&lt;/li&gt;

 &lt;li&gt;&lt;b&gt;Work in progress.&lt;/b&gt;Sempahore notification objects to be added to &lt;tt&gt;SB-THREAD&lt;/tt&gt; or
     &lt;tt&gt;SB-CONCURRENCY&lt;/tt&gt;.&lt;/li&gt;

 &lt;li&gt;Other threading API change/enhancement, to be specified later.&lt;/li&gt;

 &lt;li&gt;A new portability library called &lt;a
     href="http://random-state.net/log/3522216438.html"&gt;Madeira&lt;/a&gt;
     will be implemented. I'll blog more on it once I'm starting to
     work on it in earnest. &lt;i&gt;(Not started yet.)&lt;/i&gt;&lt;/li&gt;

 &lt;li&gt;SBCL's big compiler lock will be removed, so that parallel
     compilation is possible. Again, I'll blog more on this when it's
     time. &lt;i&gt;(Not started yet.)&lt;/i&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;I will update this post as work progresses.&lt;/p&gt;
  </description>
  </item>
<item>
  <title>IndieGoGo &amp; The Big Compiler Lock</title>
   <category>hacking</category>
   <link>http://random-state.net/log/3523430724.html</link>
   <pubDate>Sat, 27 Aug 2011 13:45:24 +0300</pubDate>
   <description>
&lt;p&gt;My &lt;a href="http://igg.me/p/37144?a=92517&amp;i=shlk"&gt;SBCL crowdfunding
at IndieGoGo&lt;/a&gt; has continued to be successful beyond my wildest
expectations: it has reached $12k funding so far, which means that &lt;a
href="http://random-state.net/log/3522216438.html"&gt;Madeira&lt;/a&gt; has
been fully funded in addition to the earlier SBCL specific goals.&lt;/p&gt;

&lt;p&gt;This lead me to a bit of a conundrum. Should I add another goal and
try for more funding while there's time left in the campaign (can't
adjust the duration after the fact), or leave more than good enough
alone? At the end, since I lit upon a good goal that fits well with
the previous ones, I opted to add it and see if I could reach all the
way to the moon...&lt;/p&gt;

&lt;p&gt;&lt;b&gt;If funding reaches $16k, that will be enough to allow us to kiss the big
compiler lock goodbye.&lt;/b&gt;&lt;/p&gt;

&lt;p class="sub"&gt;&lt;i&gt;What is the big compiler lock?&lt;/i&gt; SBCL grabs a lock when it compiles
anything.  The same lock is also used for some non-compiler activities
like modifying the class graph. This lock prevents parallel
compilation. Even if you don't care about parallel compilation as
such, there are other unfortunate consequences: CLOS dispatch (before
caches settle down) can involve compiling code. Most of the time BCL
is a tiny annoyance, but sometimes it can be a real headache.
Sometimes it is an insurmountable barrier.&lt;/p&gt;

&lt;p&gt;If $16k is not reached, any monies over $12k will be split between
general SBCL work and work leading to curtailing the effects of the
big compiler lock. (Eg. making CLOS dispatch optionally work without
the compiler.)&lt;/p&gt;

&lt;p&gt;Finally, a big &lt;i&gt;Thank You&lt;/i&gt; to all contributors.&lt;/p&gt;
  </description>
  </item>
  </channel>
  </rss>

