3 ms·
Why are you comparing DB engines if the bottleneck is the serialization? You're the one doing the serialization! You could store the embedding directly into SQL
by electroly 3y ago
Why are you comparing DB engines if the bottleneck is the serialization? You're the one doing the serialization! You could store the embedding directly into SQLite columns if you wanted.
- vishnumohandas 3y agoI agree that deserialization is not the responsibility of the database. But as an end consumer, the overall throughput while using SQLite as the DB engine was not sufficient to serve our use case of reading 100k embeddings.
- hinkley 3y agoWhat people are saying is your premise is wrong, and you’re getting defensive. Either of those would not be an interesting problem except that your title is calling out a particular and beloved database as being the culprit. Which feels a lot like defamation. Even if deserialization is the bottleneck, bottlenecks are relative and don’t have to be singular. You can have multiple bottlenecks and being blind to one because of PEBCAK can still skew results and thus conclusions. The people you’re responding to want you to fix your code and run it again. I think that’s reasonable. And maybe deserves a follow up post or a rework of the existing one.
- vishnumohandas 3y agoSorry if I sounded defensive! I have nothing against SQLite, but I unfortunately haven't yet understood how to write and read Lists more efficiently. Once I do, I'll definitely post a follow up :)
- vishnumohandas 3y agoUpdate: https://ente.io/blog/tech/sqlite-objectbox-isar#update https://ente.io/blog/tech/sqlite-objectbox-isar#update TL;DR: Removing Protobuf and directly serializing the list to a blob helped!
- lqet 3y agoIf the serialization is really the bottleneck, as you say, then you aren't serializing the data in the Isar evaluation. Which makes the comparison unfair. Your comment reads a bit like saying you don't like a Toyota car for transporting apples, because it takes too long to bake a pie out of them first. BTW, if Isar's data format really is "very close to in-memory representation", then why aren't you simply packing the 512 floats into an array (which I guess is how this data is represented anyhow), and use this continuous block of memory directly as the serialized value?
- vishnumohandas 3y agoHey, since SQLite does not yet support lists, if there's a better way to serialize so that reads can be sped up, do let me know, it would help!
- lovasoa 3y agoSQLite supports raw binary BLOBs, and I would store embeddings as a simple 512*4 = 2048 bytes blob representing just the float32 embeddings. Then you can access the data from the buffer directly in dart: https://api.dart.dev/stable/2.8.1/dart-typed_data/ByteBuffer/asFloat32List.html https://api.dart.dev/stable/2.8.1/dart-typed_data/ByteBuffer...
- vishnumohandas 3y agoThis[1] has improved the situation considerably! ``` [log] SQLite: 100000 embeddings inserted in 2635 ms [log] SQLite: 100000 embeddings retrieved in 561 ms ``` Isar is still ~2x faster, but there's room for optimization. Thanks a bunch for sharing this, I will update the post. [1]: https://github.com/ente-io/edge-db-benchmarks/commit/51ec4965fd4138a02b2ab544191fa26e47e99e3c https://github.com/ente-io/edge-db-benchmarks/commit/51ec496...
- lqet 3y agoWow, kudos for actually implementing the proposed fix and documenting it here so quickly!