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

Basic performance improvements #28

Closed
10 tasks done
gsvarovsky opened this issue Jun 20, 2020 · 8 comments
Closed
10 tasks done

Basic performance improvements #28

gsvarovsky opened this issue Jun 20, 2020 · 8 comments
Labels
investigate Extra attention is needed prior to a fix

Comments

@gsvarovsky
Copy link
Member

gsvarovsky commented Jun 20, 2020

Basic performance optimisations – in chaos testing, transactions seem to sometimes take 10ms or more.

In the browser, observing up to 100ms!

Need an example dataset - m-ld/m-ld-spec#17

Current checklist:

@gsvarovsky
Copy link
Member Author

Tried removing strange Indexeddb loop in Level.js https://github.com/Level/level-js/blob/cdacd61dba749f638123420a2ea2073e948f34be/index.js#L159

No effect.

@gsvarovsky
Copy link
Member Author

gsvarovsky commented Jul 10, 2020

Every quad is entered 6 times into the store as different indexes.

Quadstore uses encoding-down to do JSON value encoding. not any longer

Level.js encodes keys and values as Uint8Arrays.

There is a potential issue with IndexedDB storing the backing buffer: dexie/Dexie.js#665

For the demo, keys and values are approx. 200B.

@gsvarovsky
Copy link
Member Author

Testing with https://github.com/nolanlawson/database-comparison with 50-100B key and 100-300B buffer values, it really does take ~150ms to put 120 entries. No difference using string keys/values.

@gsvarovsky
Copy link
Member Author

https://stackoverflow.com/a/22315353 "I saw 60-70 entries/second"

@gsvarovsky
Copy link
Member Author

Attempted compaction of IRIs in storage.
Branch: https://github.com/m-ld/m-ld-js/tree/compact-iri-storage
Requires: https://github.com/m-ld/node-quadstore/tree/compact-iris
Analysis: https://docs.google.com/spreadsheets/d/1xyYqS4FcB_MCguQSyLrfh1XhfCMOOJpy7_SKKML4BdA/edit?usp=sharing
Bottom Line: no performance benefit. 40% reduction in storage volume.

@gsvarovsky
Copy link
Member Author

Reducing quad count for the journal, by packaging most state and entry properties into a single 'body', has improved transaction apply time by about 20%. However it also made a big difference to transaction prepare time.

@gsvarovsky
Copy link
Member Author

gsvarovsky commented Jul 22, 2020

When using Memdown (and maybe others) in the browser, setTimeout(x, 0) is used by the Browserify process shim. This is a performance problem because setTimeout is throttled to 4ms when deeply nested.

https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Reasons_for_delays_longer_than_specified

defunctzombie/node-process#86


Update: gone away with quadstore 7

@gsvarovsky gsvarovsky added this to To do in m-ld backlog Aug 27, 2020
@gsvarovsky gsvarovsky changed the title Basic performance testing Basic performance Aug 27, 2020
@gsvarovsky
Copy link
Member Author

gsvarovsky commented Sep 10, 2020

Experiment using work from defunctzombie/node-process#88 removes 4ms delays and shows ~14ms transactions.
https://github.com/m-ld/m-ld-website/tree/node-process-shim
Profile-20200911T084202.json.zip

Significant time is in utf8ToBytes and blitBuffer, which are used to serialise keys and values in memdown. Could fix by using TextEncoder API in the browser feross/buffer#268

@gsvarovsky gsvarovsky added the investigate Extra attention is needed prior to a fix label Oct 21, 2020
@gsvarovsky gsvarovsky moved this from To do to Expedite in m-ld backlog Oct 28, 2020
@gsvarovsky gsvarovsky moved this from Expedite to In progress in m-ld backlog Nov 16, 2020
gsvarovsky added a commit that referenced this issue Nov 19, 2020
@gsvarovsky gsvarovsky moved this from In progress to To do in m-ld backlog Nov 28, 2020
@gsvarovsky gsvarovsky changed the title Basic performance Basic performance improvements Dec 10, 2020
m-ld backlog automation moved this from To do to Done Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Extra attention is needed prior to a fix
Projects
None yet
Development

No branches or pull requests

1 participant