-
-
Notifications
You must be signed in to change notification settings - Fork 74
Description
Hi, thank you so much for making fakeIndexedDB
! I love using it in my tests; it's a marvelous piece of software. 🙂
I'm running into an issue where fakeIndexedDB
is taking a very long time to insert data. Here is a test where I am inserting 1000 objects, each with 100 multiEntry
keys.
On my Dell XPS 13 (i7 processor) running Ubuntu 20.04 and Node v12.16.3, this takes 35.5 seconds to complete. Unfortunately this means that my tests time out, and it's not feasible for me to create/destroy the database between each test.
In contrast, this same code takes 595ms in Chrome, 774ms in Firefox, and 1773ms in GNOME Web (WebKit, like Safari).
Looking at a Node cpuprofile, it appears that the main issue is that FDBTransaction._start queues up many recursive calls (if you insert 10,000 objects it will throw a stack overflow error), and each of those are spending time in Index.storeRecord
and RecordStore.add
. (Maybe switching to a non-recursive pattern would help?)
Attached is the trace file, which you can load into Chrome Dev Tools in the "JavaScript Profiler" section. If you'd like to profile this yourself, you can run node --inspect-brk index.js
, then in chrome:inspect
open the Node debugger, then in Profiler click "start".