Zero-copy loading of precomputed dictionaries #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why?
Wanted a way to avoid the browser frozen for half a second or more while loading the dictionary
How
dictionaryTable
variable for any generic key-value store interfacerequire()
environments due to some dependencies, but otherwise all other functionality should still work as beforeLimitations
Other things fixed:
Benchmarks
TLDR: Loading from the precomputed dictionary table is magnitudes better in terms of memory usage and load time. But, checking and suggesting operations are much slower. From my tests, more performance could probably be obtained by optimizing the new datastructure, but so far it has been sufficient for interactive applications.
Memory usage taken manually by idling the following script:
Overall node process memory usage:
Using loadPrecomputed: 14.8Mb
Using load: 59.9Mb
Speed
Generated by the
bin/benchmark.js
script.