Live data from Hacker News

35% Faster Than The Filesystem (2017)

sqlite.org

71–80 of 166 posts

Re: 35% Faster Than The Filesystem (2017)

#71
post #55

Wow, so maybe instead of a node_modules folder, npm should use a node_modules.db?

This sounds like a fantastic idea. You would go from 4000 directories and 50000 files to a single file with b-tree indices, hashes, etc. You could probably get a 100x speedup over the current approach.

Here you go: https://github.com/guardianproject/libsqlfs

Re: 35% Faster Than The Filesystem (2017)

#73

The fact that SQLite is much faster than file systems is not surprising at all. But there’s one surprising result there. > All machines use SSD except Win7 which has a hard-drive. And yet Win10 is much slower than Win7 in all tests (note they have latency on the graphs). How’s that possible? For a drive spinning at 5400 RPM, average random read latency can’t be smaller than 2.2ms, this is how long it takes to rotate…

There's the other obvious explanation that because the Win7 machine has slower storage it automatically uses a larger cache than the Win10 machine that more than offsets the difference.

Windows kernel uses all free RAM as a file cache. Low priority one i.e. when an app wants to allocate RAM, the file system cached pages are evicted. Their Win7 test machine has 4GB RAM, Win10 16GB RAM.

I think I know what’s going on. They don’t publish absolute numbers, they only publish result compared to SQLight on the same machine. Windows has approximately fixed overhead when opening files. Most of that overhead goes to access checks, NTFS security descriptors are way more sophisticated than 9 bits of security in Linuxes. With a fast disk that overhead dominates in the cost, SQLight doesn’t open any files while running the test, the DB already opened at startup. With a slow disk, that overhead is masked by large IO cost which affects both SQLight and NTFS.

Re: 35% Faster Than The Filesystem (2017)

#74
post #44

Earlier quoted context omitted.

Scheme could be something like; FileId, VersionId, Name, Data, UploadedTimestamp, UploadedBy, ... If you’re on AWS, pushing and pulling from an S3 bucket is probably a great solution, and then of course there’s nothing to worry about in terms of backups. Do you still need to keep an index of the files / metadata in a DB, or can you tag everything you need directly on the S3 objects and just pull the whole bucket?

Even if you’re not in AWS S3 works great, especially where you need to serve content direct to client’s browsers. S3 supports either making a file public and available to all, or using pre-signed URLs to provide short term authorisation to access a file to specific clients. No need to pull the bucket at all.

You will hit limits to how fast you can generate those crypto signatures for s3, and a limit to how much can serve; at a certain scale you will want to use a cdn

Re: 35% Faster Than The Filesystem (2017)

#75
post #39

Earlier quoted context omitted.

Which is why for decades many dB offerings offered raw or cooked storage. Cooked being that they used the file system and raw being using the device directly. I'm not sure of the upsides and downsides today as I last worked in that area about 20 years ago, but was very much a case of raw a noticeable performance gain. But then you are equally tied into the vendors backup mechanisms.

I ran a large at the time Informix implementation in the late 90s/early 2000s. Raw disk vs file system (Solaris UFS) performance was 35% faster on our transaction systems.

As did I upon AIX and NCR towers. Did you find you had to offset the start block of the raw partition? As with AIX, even though the OS saw it as raw, it would stamp over the first 8k (iirc) with volume control data and with that, could easily corrupt a raw partition if you didn't factor in an offset.

Re: 35% Faster Than The Filesystem (2017)

#76

Wow, so maybe instead of a node_modules folder, npm should use a node_modules.db?

There's already support for accessing zip and tar archives as filesystems (also see ASAR), which doesn't incur the overhead of SQL evaluation. At least on Windows, this would result in a huge speedup (just because you're avoiding antivirus latency). I don't expect it to help Mac or Linux that much (as their filesystems are comparatively much more efficient with larger numbers of small files).

Re: 35% Faster Than The Filesystem (2017)

#77
post #6

For small- to mid-sized projects, I’ve always realized huge gains in simplicity by haves “Files” tables to store various assets. It means instances in a web-farm can pull the files down when they initialize easily, it means files are automatically versioned, it provides an obvious place to put the files when they are being uploaded on the Admin panel. It means all the files are getting backed up as part of the databa…

>Really the only downside I ever found — at the scale I was operating at — was that it bloats the database backups. Easily solved by having two separate databases. One for dynamic content, one for static files, which is probably good practice regardless.

Doesn't that introduce the desync problem again? Is there something that can enforce consistency across the two databases?

Re: 35% Faster Than The Filesystem (2017)

#78
post #77

Earlier quoted context omitted.

>Really the only downside I ever found — at the scale I was operating at — was that it bloats the database backups. Easily solved by having two separate databases. One for dynamic content, one for static files, which is probably good practice regardless.

Doesn't that introduce the desync problem again? Is there something that can enforce consistency across the two databases?

Backups are fundamentally limited to eventual consistent, there is no need for databases to be synchronously replicated for backups. I mean splitting database has no effect on backup consistency, although a more decent way of dealing with it is not splitting database, but simply running an async replica to do backups from.

Re: 35% Faster Than The Filesystem (2017)

#80
post #45

Earlier quoted context omitted.

Personal opinion: Those things (static assets) belong in a container with Nginx serving them (and that’s not even counting SAAS options like S3). Easy to integrate with CDNs, easy to update, easy to roll out and back. And you get to take advantage of layers to keep the network and disk usage minimal.

I don’t see how a container solves the backing store / source of truth problem? How are changes getting put into the container? Are you versioning the container each time a file is changed or added? When files change are all instances of the containers being restarted to get the new/changed files?

One answer: the files are stored in git and the image is built on commit and tagged with the current ref, then pushed. The deployment is then updated to reference the new tag and services are restarted, pulling the new image and launching the new container. This is the typical ci/cd setup for kubernetes deployments.
Post reply on HN