incubator-lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <>
Subject Re: real time updates
Date Sat, 14 Mar 2009 11:33:01 GMT
On Sat, Mar 14, 2009 at 05:34:02AM -0400, Michael McCandless wrote:

> What is this "sneaky lock" trick?

>From the original article:

    Now, the magic happens when a write lock comes in. We don’t want our
    writes or our reads to block on these Very Important Pieces Of Data, so
    what the right lock does is first copy the old data from that record into
    memory and then go through the list of active readers and do a swaperoo on
    the data pointer. The readers are now pointing to an in-memory copy of the
    data, rather than the disk-based version. It can then go on writing and
    moving and generally doing whatever it wants with the disk based copy. The
    lock also keeps a copy of the pre-write version of the data in memory so
    that all readers that come in and try to get a lock on that record get the
    in-memory version until the write is done.

The thing I liked was being able to swap out data in the reader at any time no
matter what the reader's present state; that's similar to the CAS-based algo
(CAS = Compare And Swap) Cliff Click describes with regards to
rebuilding/rehashing the lock-free hash table.  

Code for the lock-free hash table:

Marvin Humphrey

View raw message