@sovereignbase/sequencer 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,20 @@ projectionA.destroy()
50
50
  projectionB.destroy()
51
51
  ```
52
52
 
53
+ ### Tuple mode
54
+
55
+ Each index represents an independent slot. Adding or removing values
56
+ never shifts other values. Empty slots return `undefined`.
57
+
58
+ Omit `maxLength` to allow dynamic growth.
59
+
60
+ ```ts
61
+ const tuple = new Projection<string>(1, undefined, { enabled: 1, maxLength: 4 })
62
+ tuple.insert(['hello'], 2)
63
+ tuple.replace(['world'], 2, 2)
64
+ tuple.remove(2, 2)
65
+ ```
66
+
53
67
  ### See documentation
54
68
 
55
69
  - [How sequencer works?](INTERNALS.md)
@@ -73,8 +87,8 @@ Invalid input to `apply()` or `merge()` returns `undefined` instead of throwing.
73
87
 
74
88
  | Format | Raw (KiB) | Minified (KiB) | Minified + gzip (KiB) |
75
89
  | -------- | --------: | -------------: | --------------------: |
76
- | ESM | 138.11 | 110.79 | 39.32 |
77
- | CommonJS | 138.25 | 111.81 | 39.39 |
90
+ | ESM | 158.96 | 129.47 | 46.18 |
91
+ | CommonJS | 159.10 | 130.50 | 46.26 |
78
92
 
79
93
  Both bundles include WASM. Terser uses three compression passes; gzip uses level 9.
80
94
 
@@ -87,37 +101,37 @@ Strips contain 1–100 Frames (visible entries). Headers show Strip counts and m
87
101
 
88
102
  | Method / case | 1,000 Strips<br>50,871 Frames | 5,000 Strips<br>252,214 Frames | 10,000 Strips<br>504,871 Frames | 15,000 Strips<br>758,280 Frames | 20,000 Strips<br>1,010,749 Frames | 25,000 Strips<br>1,264,003 Frames |
89
103
  | -------------- | ----------------------------: | -----------------------------: | ------------------------------: | ------------------------------: | --------------------------------: | --------------------------------: |
90
- | apply.random | 168,988 | 83,955 | 61,650 | 47,049 | 38,583 | 32,071 |
91
- | insert.head | 1,206,471 | 1,005,683 | 1,120,929 | 1,152,814 | 1,182,905 | 1,200,605 |
92
- | insert.random | 478,940 | 239,168 | 162,373 | 122,729 | 98,990 | 81,755 |
93
- | insert.tail | 1,334,433 | 1,104,239 | 1,256,494 | 1,303,969 | 1,339,136 | 1,349,061 |
104
+ | apply.random | 165,146 | 80,297 | 54,380 | 41,110 | 33,538 | 28,291 |
105
+ | insert.head | 1,122,612 | 837,202 | 921,657 | 958,738 | 972,684 | 965,626 |
106
+ | insert.random | 450,279 | 221,686 | 139,522 | 105,715 | 84,912 | 70,984 |
107
+ | insert.tail | 1,257,918 | 966,648 | 1,068,075 | 1,110,791 | 1,125,900 | 1,120,143 |
94
108
  | remove.head | — | — | — | — | — | — |
95
- | remove.random | 341,765 | 165,565 | 113,075 | 83,800 | 67,429 | 55,746 |
109
+ | remove.random | 321,595 | 152,089 | 97,386 | 73,599 | 58,548 | 48,596 |
96
110
  | remove.tail | — | — | — | — | — | — |
97
- | replace.head | 434,921 | 413,737 | 437,844 | 440,051 | 452,138 | 445,770 |
98
- | replace.random | 289,668 | 153,680 | 102,130 | 77,675 | 63,528 | 53,108 |
99
- | replace.tail | 378,410 | 435,943 | 470,911 | 489,325 | 467,618 | 465,423 |
100
- | value.head | 2,248,956 | 3,197,040 | 3,540,159 | 3,716,627 | 3,920,698 | 3,991,212 |
101
- | value.random | 723,289 | 231,174 | 138,597 | 96,795 | 75,674 | 61,147 |
102
- | value.tail | 5,010,118 | 5,355,455 | 5,275,683 | 5,289,080 | 5,356,586 | 5,294,392 |
111
+ | replace.head | 443,538 | 372,326 | 387,006 | 380,137 | 368,832 | 377,323 |
112
+ | replace.random | 277,133 | 139,536 | 93,692 | 69,874 | 56,537 | 46,830 |
113
+ | replace.tail | 396,605 | 384,577 | 367,733 | 388,662 | 373,868 | 326,906 |
114
+ | value.head | 2,434,405 | 3,017,725 | 3,159,921 | 3,255,278 | 3,353,882 | 3,376,975 |
115
+ | value.random | 648,315 | 219,859 | 123,644 | 86,005 | 67,010 | 54,747 |
116
+ | value.tail | 4,638,685 | 4,700,677 | 4,599,267 | 4,489,616 | 4,427,938 | 4,335,579 |
103
117
 
104
118
  **↓ Scale down (25,000 → 0 Strips)**
105
119
 
106
120
  | Method / case | 20,000 Strips<br>1,012,742 Frames | 15,000 Strips<br>755,860 Frames | 10,000 Strips<br>504,103 Frames | 5,000 Strips<br>251,203 Frames | 1,000 Strips<br>51,057 Frames | 0 Strips<br>0 Frames |
107
121
  | -------------- | --------------------------------: | ------------------------------: | ------------------------------: | -----------------------------: | ----------------------------: | -------------------: |
108
- | apply.random | 20,767 | 21,129 | 21,221 | 21,621 | 22,254 | 22,548 |
122
+ | apply.random | 17,938 | 17,713 | 17,324 | 17,192 | 17,475 | 17,723 |
109
123
  | insert.head | — | — | — | — | — | — |
110
- | insert.random | 49,291 | 50,341 | 51,237 | 51,902 | 53,706 | 53,811 |
124
+ | insert.random | 43,876 | 43,789 | 43,227 | 42,155 | 43,057 | 42,481 |
111
125
  | insert.tail | — | — | — | — | — | — |
112
- | remove.head | 609,754 | 609,062 | 614,121 | 617,274 | 622,099 | 624,577 |
113
- | remove.random | 35,772 | 36,882 | 38,342 | 40,067 | 41,973 | 42,560 |
114
- | remove.tail | 596,805 | 587,004 | 596,862 | 604,122 | 610,763 | 504,986 |
115
- | replace.head | 423,126 | 383,070 | 388,964 | 374,385 | 371,780 | 311,835 |
116
- | replace.random | 34,738 | 36,411 | 37,348 | 39,079 | 40,869 | 40,848 |
117
- | replace.tail | 227,897 | 198,045 | 194,265 | 184,618 | 184,097 | 170,615 |
118
- | value.head | 2,076,382 | 1,986,100 | 1,933,034 | 1,933,944 | 1,982,144 | 2,003,444 |
119
- | value.random | 38,599 | 39,752 | 41,093 | 42,883 | 44,849 | 45,853 |
120
- | value.tail | 2,349,312 | 2,266,890 | 2,232,286 | 2,259,013 | 2,327,296 | 2,364,396 |
126
+ | remove.head | 463,595 | 461,812 | 464,125 | 465,124 | 465,532 | 468,318 |
127
+ | remove.random | 31,986 | 32,761 | 33,073 | 33,589 | 34,651 | 35,236 |
128
+ | remove.tail | 458,417 | 441,961 | 453,605 | 457,641 | 460,637 | 426,206 |
129
+ | replace.head | 344,742 | 332,817 | 326,516 | 286,836 | 275,906 | 220,054 |
130
+ | replace.random | 31,740 | 32,287 | 32,489 | 32,466 | 33,449 | 33,035 |
131
+ | replace.tail | 177,741 | 160,539 | 153,018 | 138,043 | 135,883 | 120,041 |
132
+ | value.head | 1,601,558 | 1,562,009 | 1,528,923 | 1,523,295 | 1,556,207 | 1,574,242 |
133
+ | value.random | 35,753 | 36,152 | 36,317 | 36,833 | 37,989 | 38,814 |
134
+ | value.tail | 1,851,210 | 1,782,579 | 1,751,515 | 1,748,210 | 1,784,081 | 1,809,761 |
121
135
 
122
136
  ### API throughput at checkpoint
123
137
 
@@ -127,17 +141,17 @@ Checkpoint calls, in ops/s, averaged across runs.
127
141
 
128
142
  | Method | 1,000 Strips<br>50,871 Frames | 5,000 Strips<br>252,214 Frames | 10,000 Strips<br>504,871 Frames | 15,000 Strips<br>758,280 Frames | 20,000 Strips<br>1,010,749 Frames | 25,000 Strips<br>1,264,003 Frames |
129
143
  | --------------------------------- | ----------------------------: | -----------------------------: | ------------------------------: | ------------------------------: | --------------------------------: | --------------------------------: |
130
- | new Projection(actorID, sequence) | 4,586 | 948 | 590 | 417 | 290 | 240 |
131
- | sequence() | 520 | 96 | 55 | 30 | 24 | 18 |
132
- | values() | 555 | 226 | 57 | 79 | 29 | 54 |
144
+ | new Projection(actorID, sequence) | 4,095 | 879 | 555 | 368 | 269 | 231 |
145
+ | sequence() | 522 | 79 | 42 | 27 | 19 | 12 |
146
+ | values() | 594 | 182 | 52 | 64 | 25 | 42 |
133
147
 
134
148
  **↓ Scale down (25,000 → 0 Strips)**
135
149
 
136
150
  | Method | 20,000 Strips<br>1,012,742 Frames | 15,000 Strips<br>755,860 Frames | 10,000 Strips<br>504,103 Frames | 5,000 Strips<br>251,203 Frames | 1,000 Strips<br>51,057 Frames | 0 Strips<br>0 Frames |
137
151
  | --------------------------------- | --------------------------------: | ------------------------------: | ------------------------------: | -----------------------------: | ----------------------------: | -------------------: |
138
- | new Projection(actorID, sequence) | 284 | 414 | 493 | 1,276 | 5,419 | 21,553 |
139
- | sequence() | 16 | 14 | 10 | 10 | 9 | 8 |
140
- | values() | 63 | 34 | 79 | 82 | 209 | 109,439 |
152
+ | new Projection(actorID, sequence) | 266 | 386 | 479 | 1,167 | 4,991 | 18,336 |
153
+ | sequence() | 13 | 12 | 7 | 8 | 7 | 7 |
154
+ | values() | 43 | 41 | 59 | 76 | 204 | 87,032 |
141
155
 
142
156
  ### Sequence disk size at checkpoint
143
157
 
@@ -147,8 +161,8 @@ Complete exported Sequences, including Footage and acknowledgements. Sizes are i
147
161
 
148
162
  | Encoding | 1,000 Strips<br>50,871 Frames | 5,000 Strips<br>252,214 Frames | 10,000 Strips<br>504,871 Frames | 15,000 Strips<br>758,280 Frames | 20,000 Strips<br>1,010,749 Frames | 25,000 Strips<br>1,264,003 Frames |
149
163
  | ------------------ | ----------------------------: | -----------------------------: | ------------------------------: | ------------------------------: | --------------------------------: | --------------------------------: |
150
- | JSON | 277.41 | 1,622.78 | 3,264.00 | 4,904.44 | 7,045.81 | 9,168.42 |
151
- | JSON + gzip | 14.60 | 73.84 | 150.39 | 226.88 | 311.17 | 391.65 |
164
+ | JSON | 277.29 | 1,622.20 | 3,262.86 | 4,902.77 | 7,043.50 | 9,165.60 |
165
+ | JSON + gzip | 14.60 | 73.85 | 150.43 | 226.96 | 311.21 | 391.70 |
152
166
  | MessagePack | 164.81 | 818.88 | 1,639.69 | 3,529.41 | 5,081.04 | 6,483.22 |
153
167
  | MessagePack + gzip | 12.38 | 61.62 | 124.91 | 198.59 | 263.54 | 332.77 |
154
168
 
@@ -156,8 +170,8 @@ Complete exported Sequences, including Footage and acknowledgements. Sizes are i
156
170
 
157
171
  | Encoding | 20,000 Strips<br>1,012,742 Frames | 15,000 Strips<br>755,860 Frames | 10,000 Strips<br>504,103 Frames | 5,000 Strips<br>251,203 Frames | 1,000 Strips<br>51,057 Frames | 0 Strips<br>0 Frames |
158
172
  | ------------------ | --------------------------------: | ------------------------------: | ------------------------------: | -----------------------------: | ----------------------------: | -------------------: |
159
- | JSON | 7,451.86 | 5,621.57 | 3,772.57 | 1,886.91 | 383.51 | 0.02 |
160
- | JSON + gzip | 323.17 | 244.37 | 163.86 | 80.61 | 16.34 | 0.03 |
173
+ | JSON | 7,449.19 | 5,619.45 | 3,771.17 | 1,886.19 | 383.37 | 0.02 |
174
+ | JSON + gzip | 323.26 | 244.47 | 163.94 | 80.65 | 16.34 | 0.03 |
161
175
  | MessagePack | 5,237.17 | 3,930.33 | 2,628.38 | 1,312.43 | 266.67 | 0.01 |
162
176
  | MessagePack + gzip | 274.96 | 207.78 | 137.38 | 67.41 | 13.67 | 0.03 |
163
177
 
@@ -177,16 +191,58 @@ One instance: WASM memory plus retained JS array slots, in KiB (1,024 bytes).
177
191
  | ---------------------- | --------------------------------: | ------------------------------: | ------------------------------: | -----------------------------: | ----------------------------: | -------------------: |
178
192
  | Estimated memory (KiB) | 163,746.93 | 174,034.00 | 202,660.72 | 293,941.85 | 302,158.29 | 304,203.30 |
179
193
 
180
- Measured on Node 24.21.0, V8 13.6.233.17-node.53,
194
+ Measured on Node 24.22.2, V8 13.6.233.17-node.63,
181
195
  linux x64, AMD EPYC 7763 64-Core Processor.
182
196
  Peer synchronization, encoding and JS process garbage collection are outside API timings.
183
197
  [Full lifecycle results](benchmark/.results/lifecycle.md) · [Throughput results](benchmark/.results/throughput.md).
184
198
 
199
+ ### Tuple mode
200
+
201
+ Arithmetic means of 3 runs. Ordinary Projection versus a static tuple with maxLength. Both contain the same values; replacements preserve the field count.
202
+
203
+ #### Throughput (ops/s)
204
+
205
+ | Indices | Method / case | Projection | Static tuple | Tuple / Projection |
206
+ | ------: | --------------- | ---------: | -----------: | -----------------: |
207
+ | 2 | create.sequence | 666,485 | 589,182 | 0.88× |
208
+ | 2 | replace.random | 713,174 | 1,115,805 | 1.56× |
209
+ | 2 | apply.replace | 508,935 | 700,611 | 1.38× |
210
+ | 2 | value.random | 30,174,106 | 48,218,497 | 1.60× |
211
+ | 4 | create.sequence | 458,897 | 519,633 | 1.13× |
212
+ | 4 | replace.random | 735,182 | 1,138,983 | 1.55× |
213
+ | 4 | apply.replace | 417,043 | 707,797 | 1.70× |
214
+ | 4 | value.random | 26,113,205 | 50,651,808 | 1.94× |
215
+ | 8 | create.sequence | 349,073 | 425,121 | 1.22× |
216
+ | 8 | replace.random | 709,998 | 1,128,141 | 1.59× |
217
+ | 8 | apply.replace | 412,048 | 735,958 | 1.79× |
218
+ | 8 | value.random | 19,625,431 | 50,234,180 | 2.56× |
219
+ | 100 | create.sequence | 69,823 | 98,188 | 1.41× |
220
+ | 100 | replace.random | 697,750 | 1,214,212 | 1.74× |
221
+ | 100 | apply.replace | 323,195 | 751,943 | 2.33× |
222
+ | 100 | value.random | 8,758,041 | 49,605,873 | 5.66× |
223
+
224
+ #### Space (KiB)
225
+
226
+ | Indices | Mode | Estimated allocated memory | MessagePack | MessagePack + gzip |
227
+ | ------: | ------------ | -------------------------: | ----------: | -----------------: |
228
+ | 2 | Projection | 0.98 | 0.03 | 0.04 |
229
+ | 2 | Static tuple | 0.90 | 0.04 | 0.05 |
230
+ | 4 | Projection | 1.57 | 0.06 | 0.05 |
231
+ | 4 | Static tuple | 1.09 | 0.06 | 0.07 |
232
+ | 8 | Projection | 2.52 | 0.12 | 0.08 |
233
+ | 8 | Static tuple | 1.55 | 0.10 | 0.09 |
234
+ | 100 | Projection | 23.78 | 0.67 | 0.57 |
235
+ | 100 | Static tuple | 12.23 | 0.51 | 0.35 |
236
+
237
+ Measured on Node 24.22.2, V8 13.6.233.17-node.63, linux x64, AMD EPYC 7763 64-Core Processor. Fixtures are hydrated compacted snapshots after one replacement per field. Each case warms up for ≥25 ms and measures ≥50 ms of API time; mutation bursts restart after 4,096 replacements. Peer authoring, encoding, result checks, destruction and explicit JS process garbage collection are outside API timings. Memory estimates are the increase in live native allocator bytes plus retained JS array slots for one instance, including exercised runtime buffers. Unused WASM capacity, JS object headers and referenced payload objects are excluded.
238
+
239
+ [Full tuple results](benchmark/.results/tuple.md).
240
+
185
241
  ## Tests
186
242
 
187
243
  ### Behaviour guaranteed by excessive tests
188
244
 
189
- The latest verification passed 249 Vitest tests and 117 compatibility checks.
245
+ The latest verification passed 271 Vitest tests and 117 compatibility checks.
190
246
  The configured 100% coverage threshold is met (100% statements, 100% branches, 100% functions, 100% lines).
191
247
  See the [test suites](test/README.md) and
192
248
  [automated test report](https://sovereignbase.dev/sequencer/tests/).