Replies: 3 comments 23 replies
-
When I make insert of a lot of data, I am getting a lot of reeds and the write requests: If we could postpone the writing to the final step(on transaction commit), then it should improve performance. I am using IDBBatchAtomicVFS |
Beta Was this translation helpful? Give feedback.
-
Hmm. I'm not sure why buffering the writes should speed things up, provided that wa-sqlite is using a single IDB transaction for a SQLite transaction (you can log IDB transactions by uncommenting this line to check if it is succeeding in minimizing transactions). The writes need to go to IDB eventually, so I don't see an obvious advantage in deferring them. The only thing I can think of is that if a lot of blocks are written more than once in the transaction then overwrite in memory might be a lot faster than overwrite in IDB, but I wouldn't be certain of that because I would hope that expense would be mostly off-thread. If a lot of blocks are being read after being written, then yes, that's going to be a performance hit. I would see whether increasing the SQLite cache size helps to avoid that. I would give that a try before inserting another cache at the VFS level. |
Beta Was this translation helpful? Give feedback.
-
@rhashimoto finally I was able to achieve the same write performance as absurd-sql has. I am not sure why, but your IDBContext/Store has a bottleneck somewhere. So instead of:
I put:
And this code run double faster than the first one 🤔 |
Beta Was this translation helpful? Give feedback.
-
I was discovering why absurd-sql is very fast even on large datasets write, and why wa-sqlite doesn't have such performance (when table has 100,000+ records). And I discovered something interesting — absurd-sql makes write only on transaction finish. During the transaction, it makes reads from IDB, but writes are happening in-memory. Then it dumps all the data to IDB on transaction finish https://github.com/jlongster/absurd-sql/blob/master/src/sqlite-file.js#L374
Beta Was this translation helpful? Give feedback.
All reactions