Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Flatpack JSON V2 format to produce more diff-friendly serialized output, centered on a string table (for deduped/compact string storage) and a configurable pretty stringifier, while keeping V1 available for compatibility.
Changes:
- Added Flatpack format selection (
V1/V2) and implemented V2 packing/unpacking primitives (string table + negative string refs) plus metadata/annotation helpers. - Updated
stringifyFlatpackedto support diff-friendly, line-batched formatting for arrays (configurable via options). - Expanded optimization and test coverage for V2 (including circular structures), plus supporting utilities (Trie, WeakCache, RefCounter).
Reviewed changes
Copilot reviewed 49 out of 60 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/flatpack-json/tsconfig.json | Updates TS include list to accommodate new test file extension usage. |
| packages/flatpack-json/src/unpackedAnnotation.mts | Adds helpers to extract/check unpacked annotations and metadata. |
| packages/flatpack-json/src/unpack.test.mts | Expands tests for V1 vs V2 round trips and annotation behavior, including circular cases. |
| packages/flatpack-json/src/unpack.mts | Updates unpacking to support V2 string table + annotations + ref counting. |
| packages/flatpack-json/src/types.mts | Adds V2 header/types, string table element, metadata/annotation types, and format option. |
| packages/flatpack-json/src/stringify.mts | Adds configurable diff-friendly formatting for array elements. |
| packages/flatpack-json/src/stringTable.test.mts | Adds tests for StringTable and StringTableBuilder behavior (refs, tokenization, sorting). |
| packages/flatpack-json/src/stringTable.mts | Introduces string table runtime + builder utilities. |
| packages/flatpack-json/src/storageV2.mts | Adds CompactStorageV2 with string-table-based encoding and metadata-assisted reuse. |
| packages/flatpack-json/src/storageV1.test.mts | Adds dedicated V1 storage test suite and snapshots. |
| packages/flatpack-json/src/storageV1.mts | Extracts the prior storage implementation into an explicit V1 packer. |
| packages/flatpack-json/src/storage.test.mts | Extends tests to cover V1/V2, optimization, and V2 “update value” diff stability. |
| packages/flatpack-json/src/storage.mts | Routes toJSON/stringify through V1/V2 implementations and normalizes options. |
| packages/flatpack-json/src/proxy.mts | Removes stray debug logging from proxyMap. |
| packages/flatpack-json/src/optimizeFlatpacked.mts | Extends optimizer to understand V2 string table + negative string references. |
| packages/flatpack-json/src/flatpacked.test.mts | Adds unit tests for flatpack helpers (root index, referenced indexes, object kv indexes). |
| packages/flatpack-json/src/flatpacked.mts | Adds helpers for root detection, reference extraction, and metadata generation. |
| packages/flatpack-json/src/WeakCache.test.mts | Adds tests for mixed primitive/object-key caching behavior. |
| packages/flatpack-json/src/WeakCache.mts | Introduces WeakCache abstraction (Map + WeakMap). |
| packages/flatpack-json/src/Trie.test.mts | Adds tests for new generic Trie plus legacy TrieOfStrings behavior. |
| packages/flatpack-json/src/Trie.mts | Adds new generic Trie and deprecates/renames legacy string trie. |
| packages/flatpack-json/src/RefElements.mts | Updates index type usage (Index → FlatpackIndex). |
| packages/flatpack-json/src/RefCounter.test.mts | Adds tests for reference counter behavior. |
| packages/flatpack-json/src/RefCounter.mts | Adds RefCounter utility used for reference tracking. |
| packages/flatpack-json/src/FlatpackV2.test.mts | Adds V2 store tests including diff snapshots and proxy identity cases. |
| packages/flatpack-json/src/FlatpackV2.mts | Adds FlatpackStoreV2 wrapper that maintains metadata for stable diffs across updates. |
| packages/flatpack-json/src/FlatpackV1.test.mts | Updates V1 test to use renamed V1 store entry point. |
| packages/flatpack-json/src/FlatpackData.mts | Adds FlatpackData structure to track used/available indices + ownership + string table. |
| packages/flatpack-json/src/CompactStorage.mts | Introduces a shared CompactStorage API/base class for V1/V2 packers. |
| packages/flatpack-json/src/snapshots/storageV2_fileList.data.json | Adds V2 snapshot fixture output. |
| packages/flatpack-json/src/snapshots/FlatpackV2_fileList.data.json | Adds V2 snapshot fixture output for file list tests. |
| packages/flatpack-json/src/snapshots/FlatpackV1_fileList.data.json | Adds V1 snapshot fixture output for file list tests. |
| packages/flatpack-json/src/snapshots/storageV1.test.mts.snap | Adds V1 snapshot baselines for storage tests. |
| packages/flatpack-json/src/snapshots/FlatpackV2.test.mts.snap | Adds V2 snapshot baselines for diff behavior tests. |
| packages/flatpack-json/src/snapshots/FlatpackV1.test.mts.snap | Adds/updates V1 snapshot baselines for store tests. |
| packages/cspell-normalize-json/src/index.test.mts | Updates tests to use V1 explicitly (and adjusts import extension). |
| .prettierignore | Ignores .npm*.json fixture outputs from formatting. |
Contributor
Performance ReportDaily Performancexychart-beta
title Files Per Second by Day
y-axis Files per Second
x-axis Date [Feb-22, Feb-23, Feb-24, Feb-26, Feb-27, Mar-2, Mar-3, Mar-10, Mar-13, Mar-15, Mar-16, Mar-20, Mar-21, Mar-22, Mar-23, Mar-24]
bar [188.84, 190.95, 190.14, 188.86, 187.47, 189.15, 187.99, 188.38, 189.98, 185.21, 189.57, 188.63, 189.87, 187.45, 187.93, 185.46]
line [25.16, 23.04, 24.66, 23.19, 24.07, 21.50, 23.56, 24.56, 23.16, 23.57, 24.07, 23.83, 22.72, 24.07, 23.01, 23.70]
line [39.75, 38.29, 38.55, 38.02, 38.35, 35.65, 38.90, 38.99, 38.46, 40.13, 39.77, 36.42, 40.38, 36.50, 39.38, 37.42]
line [5.92, 6.38, 6.30, 6.44, 6.78, 6.62, 6.55, 6.32, 6.79, 7.12, 6.59, 6.35, 6.19, 6.26, 6.60, 6.79]
line [66.82, 66.94, 70.88, 67.89, 70.56, 67.78, 66.98, 69.18, 70.51, 65.83, 66.30, 67.73, 68.98, 63.91, 69.35, 65.05]
line [135.57, 126.55, 124.20, 119.96, 129.35, 126.96, 116.50, 125.61, 123.50, 128.64, 128.22, 133.34, 123.28, 125.66, 126.65, 127.56]
line [102.79, 103.56, 108.60, 97.11, 104.32, 106.04, 94.30, 104.19, 100.36, 94.07, 106.95, 99.82, 102.15, 104.63, 100.11, 99.21]
line [84.08, 83.91, 75.76, 83.59, 84.08, 83.89, 88.30, 81.02, 82.11, 85.90, 84.63, 82.99, 84.87, 85.57, 82.40, 87.06]
line [215.58, 226.36, 225.70, 222.46, 230.96, 236.51, 222.64, 222.38, 225.56, 216.60, 228.18, 224.68, 217.69, 227.52, 226.28, 210.09]
line [18.38, 19.68, 18.34, 19.60, 19.60, 19.63, 18.78, 19.22, 18.67, 19.78, 18.71, 19.79, 19.47, 18.35, 19.30, 19.48]
line [46.89, 43.13, 47.48, 43.86, 43.58, 44.95, 42.68, 45.79, 43.00, 44.30, 47.55, 45.42, 45.55, 44.76, 44.94, 43.23]
line [124.67, 122.06, 125.40, 123.31, 123.27, 118.58, 127.90, 124.38, 120.45, 128.40, 126.26, 121.85, 123.29, 123.31, 123.57, 120.28]
line [331.76, 320.00, 316.72, 330.45, 317.84, 319.02, 305.87, 317.67, 331.44, 338.69, 332.97, 333.24, 336.87, 327.34, 320.84, 324.76]
line [148.15, 148.90, 152.11, 143.30, 150.41, 149.07, 153.47, 146.06, 140.05, 150.95, 150.81, 144.94, 146.39, 146.52, 149.65, 150.55]
line [194.82, 190.50, 191.36, 189.34, 184.31, 185.47, 198.42, 191.68, 193.62, 189.84, 166.89, 171.60, 172.56, 154.71, 166.00, 170.54]
line [244.70, 255.35, 256.03, 252.54, 255.82, 263.63, 252.65, 260.43, 254.55, 236.73, 261.47, 259.22, 254.59, 258.80, 265.17, 269.15]
line [141.79, 137.76, 142.75, 135.42, 139.26, 136.06, 139.99, 140.01, 135.63, 143.93, 142.95, 134.36, 139.82, 141.15, 141.79, 133.17]
line [89.64, 87.93, 87.72, 85.68, 85.69, 83.26, 89.40, 86.73, 86.09, 89.20, 79.46, 84.64, 82.02, 89.37, 88.80, 87.93]
line [375.70, 377.89, 371.33, 366.95, 377.92, 377.66, 385.69, 370.91, 378.91, 387.90, 387.80, 386.06, 387.41, 376.59, 391.51, 367.84]
line [14.08, 14.28, 13.96, 14.98, 14.69, 15.09, 15.05, 14.93, 14.92, 15.23, 14.84, 14.06, 13.99, 14.45, 15.39, 15.32]
line [80.37, 81.15, 79.72, 81.93, 80.10, 84.29, 81.35, 81.66, 80.93, 85.41, 78.19, 83.51, 83.81, 81.43, 79.47, 84.14]
line [49.05, 48.06, 46.41, 47.91, 43.77, 46.60, 45.68, 47.70, 47.47, 48.64, 47.90, 46.22, 49.72, 49.15, 48.47, 46.41]
line [36.75, 33.50, 33.75, 33.98, 34.43, 34.99, 32.10, 34.36, 33.03, 34.53, 33.80, 33.49, 35.23, 32.80, 33.41, 31.42]
line [130.26, 129.44, 123.58, 128.31, 129.87, 130.27, 130.71, 127.81, 125.76, 132.01, 131.14, 128.67, 125.67, 130.11, 116.06, 134.73]
line [55.45, 55.44, 54.09, 53.55, 56.91, 50.34, 56.33, 53.77, 52.96, 57.64, 49.40, 55.01, 55.07, 55.14, 54.97, 55.59]
line [263.71, 255.40, 259.16, 257.65, 254.22, 257.02, 267.92, 259.39, 256.02, 269.97, 254.79, 259.65, 234.19, 251.38, 263.45, 256.83]
line [238.32, 230.44, 216.76, 225.02, 229.69, 222.82, 225.14, 221.56, 225.82, 223.33, 223.62, 225.78, 230.86, 229.00, 232.44, 231.53]
line [127.43, 118.55, 121.57, 118.53, 115.70, 116.93, 121.24, 118.95, 118.40, 114.99, 118.14, 119.47, 113.95, 118.70, 123.16, 125.31]
line [100.38, 103.85, 96.33, 99.09, 99.19, 100.48, 103.18, 103.33, 98.05, 102.55, 95.32, 100.34, 95.68, 103.94, 100.49, 103.51]
line [171.99, 177.77, 181.65, 177.93, 171.71, 171.61, 178.31, 176.56, 173.19, 174.63, 177.66, 175.92, 178.79, 174.01, 172.30, 178.48]
line [223.87, 231.37, 229.84, 219.75, 240.64, 223.28, 229.19, 235.85, 231.18, 227.46, 239.47, 235.22, 227.41, 228.79, 241.01, 249.20]
line [216.61, 212.54, 214.33, 212.86, 215.99, 216.40, 215.81, 217.40, 210.64, 213.63, 210.38, 215.44, 220.20, 209.66, 217.73, 211.67]
line [213.31, 213.15, 214.61, 215.98, 216.39, 213.20, 207.00, 210.46, 215.67, 209.05, 214.60, 209.59, 204.82, 212.94, 211.50, 216.14]
line [175.03, 175.02, 172.48, 176.50, 175.06, 173.05, 179.29, 168.17, 175.84, 172.23, 167.20, 162.09, 175.73, 167.53, 169.26, 163.10]
line [193.32, 192.22, 196.28, 187.50, 189.10, 188.54, 189.19, 186.81, 190.52, 190.26, 197.02, 193.75, 189.15, 186.42, 190.28, 195.47]
line [246.48, 246.10, 248.98, 240.98, 239.52, 244.96, 243.99, 244.22, 247.23, 240.74, 246.80, 248.37, 243.77, 240.29, 242.61, 244.02]
line [402.15, 417.55, 417.69, 405.05, 412.32, 405.86, 426.09, 413.29, 411.20, 402.18, 405.65, 399.88, 410.92, 409.10, 416.42, 405.21]
line [36.10, 37.37, 36.52, 37.66, 35.60, 37.02, 36.08, 36.38, 35.91, 38.37, 36.25, 36.61, 35.87, 38.67, 37.37, 37.84]
line [177.56, 185.31, 187.50, 177.93, 177.54, 178.41, 174.58, 186.65, 179.06, 166.05, 180.55, 173.75, 182.92, 186.30, 171.18, 187.97]
line [162.30, 157.06, 159.96, 153.79, 161.66, 159.28, 163.36, 159.01, 157.48, 159.10, 169.05, 154.54, 158.47, 152.54, 153.40, 165.56]
line [99.76, 98.90, 95.69, 94.30, 98.50, 95.82, 98.55, 97.82, 96.22, 96.21, 96.60, 95.61, 100.00, 97.34, 96.90, 96.95]
line [78.95, 76.37, 76.80, 73.75, 75.77, 77.40, 74.68, 79.36, 75.39, 75.58, 78.40, 76.58, 74.92, 73.83, 77.77, 72.58]
line [25.87, 24.49, 24.03, 24.62, 25.06, 24.45, 24.76, 24.74, 25.60, 26.18, 25.98, 23.83, 25.61, 25.64, 25.22, 24.68]
line [229.20, 204.56, 214.62, 214.22, 215.21, 211.23, 203.79, 213.30, 213.00, 209.05, 214.75, 216.78, 222.67, 220.47, 206.28, 212.36]
line [227.37, 223.02, 226.36, 218.81, 215.75, 221.50, 212.02, 224.11, 219.75, 232.68, 220.52, 223.12, 228.15, 216.79, 218.07, 223.68]
line [362.80, 356.26, 358.85, 353.61, 350.32, 358.90, 343.06, 352.21, 348.39, 359.59, 349.81, 342.75, 347.71, 359.34, 340.76, 347.39]
line [207.58, 214.51, 202.85, 211.79, 211.44, 214.66, 206.78, 214.22, 219.20, 204.44, 213.42, 215.32, 218.95, 211.96, 209.30, 211.22]
line [284.25, 260.54, 263.62, 267.57, 257.62, 270.01, 257.62, 250.97, 253.10, 248.68, 263.99, 260.91, 239.46, 259.16, 256.10, 266.48]
line [131.83, 132.27, 131.01, 131.00, 133.00, 131.45, 127.22, 127.60, 130.54, 131.20, 126.76, 126.98, 130.36, 127.52, 127.75, 124.58]
line [194.87, 203.28, 199.45, 200.84, 188.59, 197.81, 190.62, 200.86, 205.50, 202.63, 202.69, 199.56, 199.40, 197.96, 202.91, 207.84]
line [171.39, 176.96, 177.51, 175.27, 171.69, 175.82, 173.02, 172.27, 176.52, 160.55, 175.49, 175.91, 178.24, 172.29, 170.07, 158.58]
Time to Process Files
Note:
Files per Second over Time
Data Throughput
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull request overview
This PR introduces a new Flatpack JSON V2 format to produce more diff-friendly serialized output, centered on a string table (for deduped/compact string storage) and a configurable pretty stringifier, while keeping V1 available for compatibility.
Changes:
V1/V2) and implemented V2 packing/unpacking primitives (string table + negative string refs) plus metadata/annotation helpers.stringifyFlatpackedto support diff-friendly, line-batched formatting for arrays (configurable via options).