3 ms·
> The performance difference arises (we believe) because when working from an SQLite database, the open() and close() system calls are invoked only once, wherea
by blinkingled 7y ago
> The performance difference arises (we believe) because when working from an SQLite database, the open() and close() system calls are invoked only once, whereas open() and close() are invoked once for each blob when using blobs stored in individual files. It appears that the overhead of calling open() and close() is greater than the overhead of using the database. The size reduction arises from the fact that individual files are padded out to the next multiple of the filesystem block size, whereas the blobs are packed more tightly into an SQLite database.
open() and close() are significantly slower[1] on non-Linux OSes so this would be even more drastic on say Windows or macOS.
[1] I once had to debug a library that was lot slower on Mac and Windows and it mostly turned out to be because of doing open/close of files instead of caching the handles - on Linux it was barely showing up on the perf traces and I had no easy way to debug on the other OSes. On a hunch I cached the file
handles and the performance difference was mostly gone.
- vdfs 7y agoAlso doesn't make any sense, of course something that use open/close once will be faster than using open/close n time.
- blinkingled 7y agoIt gets weird when you throw Linux in the mix - open/close are extremely cheap on Linux, to the point of being free - at least used to be before Spectre and Meltdown and what not. So on Linux doing n more open/closes isn't much different than doing a single pair if n is not humongous and the program is doing other things besides just open close.