Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexedDB write performance #64

Open
MathisBullinger opened this issue Oct 1, 2021 · 9 comments
Open

IndexedDB write performance #64

MathisBullinger opened this issue Oct 1, 2021 · 9 comments

Comments

@MathisBullinger
Copy link
Member

No description provided.

@MathisBullinger
Copy link
Member Author

This seems to be an issue of limited IndexedDB write speed or more specifically, how fast IDB resolves its promises. See idb-test repo.

Screen.Recording.2021-10-06.at.03.17.26.mov

@MathisBullinger
Copy link
Member Author

Confirmed that waiting for the displayed IndexedDB storage size to come to rest (takes several minutes for ~8.5 MB) does result in all episodes being persisted in the database.

@MathisBullinger
Copy link
Member Author

next steps:

  • don't write episodes in serial
  • don't use IDB promises (but IndexedDB directly) for writing episodes
  • throttle batch episode writes
  • investigate if any other IDB writes block execution

@MathisBullinger MathisBullinger changed the title Some episodes don't get written to IndexedDB IndexedDB write performance Oct 6, 2021
@MathisBullinger
Copy link
Member Author

Using parallel single item transactions in IndexedDB directly for a test set of 1000 records results in virtually the same delays to the .onsucess callback as the IDB promise resolve times.

The timings are consistent with IndexedDB locking the database to perform a single readwrite transaction at a time.

time till  onsuccess per index of insertion (152 3 ms - 19 648 s)

@MathisBullinger
Copy link
Member Author

The same test takes 305 ms in Firefox and 584 ms in Safari.

@MathisBullinger
Copy link
Member Author

This might be due to Chrome's strict durability guarantees. There is a relaxed durability API available in Chrome.

@MathisBullinger
Copy link
Member Author

Performing the same test in Chrome with the transaction option { durability: 'relaxed' } reduces the time to ~700 ms.

@MathisBullinger
Copy link
Member Author

relevant blog post: Speeding up IndexedDB reads and writes

@MathisBullinger
Copy link
Member Author

f1348e0 resolves the issue. Tuning of batch window is TBD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant