Repository navigation
Commit 3a38d56
committed
perf(index): store index records in columns
FuseIndex keeps records in typed-array columns (one row per record,
one per field value) instead of one object per record and per value.
Text values stay references to the documents' own strings; norms are
ids into a table of exact values. Scores, ordering and toJSON() output
are unchanged (differential vs 7.6.0-beta.4: 8,400 randomized searches
and 2,557 toJSON comparisons, zero differences).
Base index memory at 100k items: objects 69.6 MB -> 12.0 MB (-83%),
strings 7.2 MB -> 3.4 MB (-52%); objects with token search 81.4 MB ->
23.8 MB. Search is equal or faster, object builds equal or faster,
removeAt/remove 4-17% faster. Loading a saved index (parseIndex) is
13-33% slower since records are converted into columns, and string-list
builds are ~6-8% slower at 100k (+0.7 ms).
Behavior changes:
- FuseIndex.records is deprecated (removed in v8). It returns a fresh,
detached snapshot in the old shape on each access; writing to it no
longer affects search. Dev builds warn once.
- toJSON() builds its output from the columns instead of returning the
live record array.
- add() returns a detached record; records passed to setIndexRecords()
or assigned to records are copied in.
- parseIndex()/setIndexRecords() reject records whose document indexes,
field keys or array positions aren't integers in 0..2^31-1.
Tests updated for the detached snapshot: "FuseIndex.removeAt handles
unsorted records" now loads the reordered records via setIndexRecords(),
and the token-search removal test asserts that editing a snapshot
changes neither search nor removal.1 parent e587382 commit 3a38d56
21 files changed
Lines changed: 3517 additions & 915 deletions
File tree
- bench
- dist
- src
- core
- search/token
- tools
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
0 commit comments