← Back to context

Comment by tnelsond4

6 hours ago

I'm always inspired by SQLite. Overall I like it, but if you're not doing writes it's really overkill.

So I made a format that will never surpass SQLite, except that it's extremely lighter and faster and works on zstd compressed files. It has really small indexes and can contain binaries or text just like SQLite.

The wasm part that decompresses and reads and searches the databases is only 38kb (uncompressed (maybe 16kb gzipped)). Compare that to SQLite's 1.2mb of wasm and glue code it's 3% the size but searching and loading is much faster. My program isn't really column based and isn't suitable for managing spreadsheets, but it's great for dictionaries and file archives of images and audio.

I ported the jbig2 decoder as a 17kb wasm module, so I can load monochrome scans that are 8kb per page and still legible.

https://github.com/tnelsond/peakslab

SQLite is very well engineered, PeakSlab is very simple.

> Compare that to SQLite's 1.2mb of wasm and glue code

The current trunk is actually 1.7mb in its canonical unminified form (which includes very nearly as much docs as JS code), split almost evenly between the WASM and JS pieces :/. Edit: it is 1.2mb in minified form, though.

Disclosure: i'm its maintainer.

Edit: current trunk, for the sake of trivia:

    sqlite3.wasm 896745
    sqlite3.mjs  816270 # unminified w/ docs
    sqlite3.mjs  431388 # unminified w/o docs
    sqlite3.mjs  310975 # minified

I think actually this competes with the old BerkeleyDB: https://en.wikipedia.org/wiki/Berkeley_DB - which I now see is no longer BSD-licensed, and in any case has been rendered almost extinct by SQLite. It was used for basic on-disk key-value store work.

  • Even BerkeleyDB tries to be mutable. What I'm doing doesn't need the mutability so it's much more similar to dictionary formats (though probably simpler) than it is to a database. Though a lot of people do use full databases for immutable dictionary key-value stuff. I just couldn't get any database to work well enough for a pwa dictionary.

Many comments here to your creation, PeakSlab, but not yet a dedicated praise. I didn't know it but I have to say it is really cool and innovative! The performance of the dictionary is indeed superb and I will definitely bookmark this for future reuse. So, in a nutshell: thanks for sharing!

Perhaps a dumb question, but how do you get data into it if you’re not doing writes

  • I think it's just immutable once you've generated it. No need to update indexes or check consistency on writes, no need for transactions, etc.

  • Think historical records of, say, share values for past years. You might have a single db for 1900-2000, for instance. Things like that.

    Not everything needs to be real-time updated.

something something XKCD competing standards something something

  • Creating something new for a different use case isn't pointless. It's like comparing inline skates to ice skates.

  • Doesn’t even apply unless someone says that (1) there are too many “standards”, and (2) so we are making this standard (neither apply here). Someone made something.

    We should really consider eventually retiring memes because they just end up as thought-terminating cliches.

    This is of course referring to xkcd #927. How do I know that?