News for hackers. Stuff that matters.
Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by cypherpunks01 on Tuesday May 29, 2012 @12:47AM (#4036006)
What are people using this 'cdb' for, irl? Sounds interesting but this is the first i've heard of it.
Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by tlack on Tuesday May 29, 2012 @01:01AM (#4036044)
It's useful if you have data that is easy to cache (i.e., rebuilt every 6 hours) but very commonly accessed. Because the lookups are so quick (two seeks) it's almost raw disk speed. But yeah, rebuilding the files is an offline process (build new file and swap it in using a rename), so your data has to be cache-friendly.

It's a good alternative to memcache if your data is larger than what memcached can support in RAM.

In the early 2000s I used it to implement most of the frontend for a PPC marketplace for search engines. Held up well. These days I'd just use memcached or redis.

Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by yummyfajitas on Tuesday May 29, 2012 @08:05AM (#4037043)
It's a good alternative to memcache if your data is larger than what memcached can support in RAM.

Unless you are running memcached on an ec2 large instance (8gb) or bigger:

"No random limits: cdb can handle any database up to 4 gigabytes."

Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by jbooth on Tuesday May 29, 2012 @09:20AM (#4037288)
It's pretty easy to throw together a variant using longs for position instead of unsigned ints, the rest of the code stays the same. Slightly more overhead in the file but as long as the items you're storing are bigger than a few bytes it's not a huge deal.

Anyways, it's useful for stuff where you want to ship out a big dictionary once a day or so and you need fast lookup but it doesn't have to be updated transactionally.

Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by pilif on Tuesday May 29, 2012 @03:02AM (#4036292)
I use it on my mail relay to determine whether a domain is local or not. As this check happens for every incoming RCPT TO (including all the bots checking to see whether I'm an open relay or not), I don't want to hit the database where the accounts are stored just yet.

This is the perfect case for a cdb file: the list of local domains changes very rarely, but lookups happen 100s of times per second.

Granted though, it's a very special case. Aside of this mail case, I've yet to find another real world application.

Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by tptacek on Tuesday May 29, 2012 @01:00AM (#4036040)
It's a persistent data structure optimized for static lookup tables. Bernstein's qmail and djbdns use it for mail routing and DNS zone data, respectively.
Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by haberman on Tuesday May 29, 2012 @03:39AM (#4036417)
I'm curious to know how it compares to LevelDB (http://code.google.com/p/leveldb/). I'd love to see a detailed comparison between the two. LevelDB is mutable, but is built on top of an immutable key/value map: http://code.google.com/p/leveldb/source/browse/include/level...
Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by alec on Tuesday May 29, 2012 @04:52AM (#4036573)
LevelDB is a sorted string table; cdb is a hash table. Without knowing anything more about the implementation, I expect that arbitrary lookups are slower in LevelDB than cdb.
Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by dpkendal on Tuesday May 29, 2012 @01:25AM (#4036085)
It's used extensively in djb's packages like qmail and ucspi-tcp. In the latter, it's used to maintain a database of blacklisted IPs which are blocked from connecting to a TCP server, among other things. http://cr.yp.to/cdb.html
Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by pudquick on Tuesday May 29, 2012 @11:17AM (#4037841)
I used it in combination with the public dumps from IMDB to make a quick on-disk lookup database for use with my favorite (albeit slower) scripting language python.

I didn't have the RAM for holding it all in memory and I was only ever going to do read lookups on it.

It made it very easy to query things like: Given my favorite set of movies, which actors appearing in them have also appeared in the Doctor Who television series?

Just for fun / learning :)

Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by sigil on Tuesday May 29, 2012 @05:44PM (#4040134)
Incidentally, I've heard the IMDB site itself uses cdbs heavily to serve static content and data.
Re:Pure Go implementation of D. J. Bernstein's cdb constant ... by pcwalton on Tuesday May 29, 2012 @12:51AM (#4036015)
DJB's qmail (the security-hardened sendmail replacement) uses it.