loaderx 2.3.5__tar.gz → 2.4.0__tar.gz

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.
Files changed (110) hide show
  1. {loaderx-2.3.5/loaderx.egg-info → loaderx-2.4.0}/PKG-INFO +158 -205
  2. {loaderx-2.3.5 → loaderx-2.4.0}/README.md +157 -204
  3. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/__init__.py +1 -1
  4. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/converter.py +101 -44
  5. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/utils.py +13 -21
  6. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/zrecord.py +106 -26
  7. {loaderx-2.3.5 → loaderx-2.4.0/loaderx.egg-info}/PKG-INFO +158 -205
  8. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx.egg-info/SOURCES.txt +1 -0
  9. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/_bench_common.py +55 -158
  10. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/bench.py +5 -5
  11. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/bench_dense.py +8 -5
  12. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/bench_ragged.py +23 -111
  13. loaderx-2.4.0/scripts/prepare_vision.py +167 -0
  14. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/requirements-bench.txt +3 -1
  15. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/test_loaderx.py +161 -39
  16. {loaderx-2.3.5 → loaderx-2.4.0}/src/record/engine.zig +6 -7
  17. {loaderx-2.3.5 → loaderx-2.4.0}/src/record/executor.zig +1 -1
  18. {loaderx-2.3.5 → loaderx-2.4.0}/LICENSE +0 -0
  19. {loaderx-2.3.5 → loaderx-2.4.0}/MANIFEST.in +0 -0
  20. {loaderx-2.3.5 → loaderx-2.4.0}/build.zig +0 -0
  21. {loaderx-2.3.5 → loaderx-2.4.0}/build.zig.zon +0 -0
  22. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/_lib.py +0 -0
  23. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/_store.py +0 -0
  24. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/dataloader.py +0 -0
  25. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx/zsampler.py +0 -0
  26. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx.egg-info/dependency_links.txt +0 -0
  27. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx.egg-info/requires.txt +0 -0
  28. {loaderx-2.3.5 → loaderx-2.4.0}/loaderx.egg-info/top_level.txt +0 -0
  29. {loaderx-2.3.5 → loaderx-2.4.0}/pyproject.toml +0 -0
  30. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/build_wheels.py +0 -0
  31. {loaderx-2.3.5 → loaderx-2.4.0}/scripts/prepare_tokens.py +0 -0
  32. {loaderx-2.3.5 → loaderx-2.4.0}/setup.cfg +0 -0
  33. {loaderx-2.3.5 → loaderx-2.4.0}/setup.py +0 -0
  34. {loaderx-2.3.5 → loaderx-2.4.0}/src/record/storage.zig +0 -0
  35. {loaderx-2.3.5 → loaderx-2.4.0}/src/store.zig +0 -0
  36. {loaderx-2.3.5 → loaderx-2.4.0}/src/zsampler.zig +0 -0
  37. {loaderx-2.3.5 → loaderx-2.4.0}/src/zstd/c.zig +0 -0
  38. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/COPYING +0 -0
  39. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/LICENSE +0 -0
  40. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/allocations.h +0 -0
  41. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/bits.h +0 -0
  42. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/bitstream.h +0 -0
  43. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/compiler.h +0 -0
  44. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/cpu.h +0 -0
  45. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/debug.c +0 -0
  46. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/debug.h +0 -0
  47. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/entropy_common.c +0 -0
  48. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/error_private.c +0 -0
  49. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/error_private.h +0 -0
  50. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/fse.h +0 -0
  51. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/fse_decompress.c +0 -0
  52. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/huf.h +0 -0
  53. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/mem.h +0 -0
  54. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/pool.c +0 -0
  55. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/pool.h +0 -0
  56. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/portability_macros.h +0 -0
  57. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/threading.c +0 -0
  58. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/threading.h +0 -0
  59. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/xxhash.c +0 -0
  60. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/xxhash.h +0 -0
  61. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/zstd_common.c +0 -0
  62. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/zstd_deps.h +0 -0
  63. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/zstd_internal.h +0 -0
  64. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/common/zstd_trace.h +0 -0
  65. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/clevels.h +0 -0
  66. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/fse_compress.c +0 -0
  67. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/hist.c +0 -0
  68. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/hist.h +0 -0
  69. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/huf_compress.c +0 -0
  70. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress.c +0 -0
  71. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress_internal.h +0 -0
  72. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress_literals.c +0 -0
  73. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress_literals.h +0 -0
  74. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress_sequences.c +0 -0
  75. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress_sequences.h +0 -0
  76. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress_superblock.c +0 -0
  77. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_compress_superblock.h +0 -0
  78. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_cwksp.h +0 -0
  79. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_double_fast.c +0 -0
  80. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_double_fast.h +0 -0
  81. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_fast.c +0 -0
  82. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_fast.h +0 -0
  83. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_lazy.c +0 -0
  84. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_lazy.h +0 -0
  85. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_ldm.c +0 -0
  86. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_ldm.h +0 -0
  87. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_ldm_geartab.h +0 -0
  88. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_opt.c +0 -0
  89. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_opt.h +0 -0
  90. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_preSplit.c +0 -0
  91. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstd_preSplit.h +0 -0
  92. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstdmt_compress.c +0 -0
  93. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/compress/zstdmt_compress.h +0 -0
  94. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/huf_decompress.c +0 -0
  95. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/huf_decompress_amd64.S +0 -0
  96. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/zstd_ddict.c +0 -0
  97. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/zstd_ddict.h +0 -0
  98. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/zstd_decompress.c +0 -0
  99. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/zstd_decompress_block.c +0 -0
  100. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/zstd_decompress_block.h +0 -0
  101. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/decompress/zstd_decompress_internal.h +0 -0
  102. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/dictBuilder/cover.c +0 -0
  103. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/dictBuilder/cover.h +0 -0
  104. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/dictBuilder/divsufsort.c +0 -0
  105. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/dictBuilder/divsufsort.h +0 -0
  106. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/dictBuilder/fastcover.c +0 -0
  107. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/dictBuilder/zdict.c +0 -0
  108. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/zdict.h +0 -0
  109. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/zstd.h +0 -0
  110. {loaderx-2.3.5 → loaderx-2.4.0}/vendor/zstd/lib/zstd_errors.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: loaderx
3
- Version: 2.3.5
3
+ Version: 2.4.0
4
4
  Summary: Rebuildable high-performance ordered record containers
5
5
  Author-email: Ben0i0d <ben0i0d@foxmail.com>
6
6
  License-Expression: MIT
@@ -120,7 +120,6 @@ convert(
120
120
  dataset,
121
121
  "mnist",
122
122
  codec="zstd",
123
- batch_size=256,
124
123
  )
125
124
  ```
126
125
 
@@ -128,8 +127,9 @@ convert(
128
127
  snapshot, then downloads and returns the repository's DatasetDict. Repositories
129
128
  without one default config require `config=...`. `convert` is the independent
130
129
  persistence stage: it accepts that DatasetDict or one already normalized
131
- Dataset. `batch_size` bounds records per Python batch; actual bytes also depend
132
- on record sizes and Ragged packing.
130
+ Dataset. Conversion batches are bounded internally by decoded numeric bytes,
131
+ not a public row-count parameter; they flush at 32K records or near 64 MiB,
132
+ whichever comes first.
133
133
  For private or gated repositories, pass `token="hf_..."`; `None` uses the
134
134
  standard HF environment, local login, or anonymous access.
135
135
  Static or regularly batched numeric arrays become Dense stores, while dynamic
@@ -138,8 +138,9 @@ arrays become Ragged stores; source dtype and record shape are preserved.
138
138
  Zrecord persists numeric tensors rather than Python objects. A standard HF
139
139
  feature that cannot be represented losslessly fails with its column name;
140
140
  conversion does not filter, pad, tokenize, reshape, or run a transform stage.
141
- Arrow dtypes, including float64 and uint64, are preserved. Only the current
142
- batch is formatted; `with_format` never materializes the complete dataset.
141
+ Arrow dtypes, including float64 and uint64, are preserved. Hugging Face formats
142
+ only bounded decode slices; the converter retains their numeric results only
143
+ until the byte-aware append boundary and never formats the complete dataset.
143
144
 
144
145
  The result groups aligned streams under one published root:
145
146
 
@@ -267,10 +268,12 @@ with Dense.open("events") as events:
267
268
  ```
268
269
 
269
270
  Ragged creators may consume a one-pass iterable, while Dense creators take
270
- explicit ndarray batches. Concurrent append calls are serialized by the native
271
- writer lock, but their batch order is the lock-acquisition order rather than
272
- Python call-start order; sequence builders that require an external temporal
273
- order should use one producer or order batches before append.
271
+ explicit ndarray batches. Dense concurrent append calls are serialized by the
272
+ native writer lock, and their batch order is lock-acquisition order. Ragged
273
+ creators serialize packing and bounded submission through one producer lock;
274
+ their batches reach the native writer in FIFO submission order. Sequence
275
+ builders that require an external temporal order should still use one producer
276
+ or order batches before append.
274
277
 
275
278
  A ``DataLoader`` dynamically composes a dict of dense and ragged streams.
276
279
  Collation is the ``transform`` — a batch dict in, a batch dict out:
@@ -325,7 +328,10 @@ batch extends the logical sequence without exposing native physical completion
325
328
  order.
326
329
  Dense append is synchronous and borrows an already-contiguous ndarray without a
327
330
  snapshot copy. Ragged append consumes its iterable once into one owned packed
328
- buffer, then completes the native append before returning. Nothing is inferred.
331
+ buffer, then submits it to the creator's ``Queue(maxsize=1)`` writer. The next
332
+ Ragged batch can be packed while the native engine writes the current batch;
333
+ ``len()`` counts accepted records and ``close()`` drains them before publishing.
334
+ Nothing is inferred.
329
335
 
330
336
  ```python
331
337
  from loaderx.zrecord import Dense, Ragged
@@ -337,8 +343,8 @@ ds.append(single_image[None]) # one sample is batch_size 1 — add the ax
337
343
  ds.close() # publish before opening
338
344
 
339
345
  tok = Ragged.create('tokens', dtype=np.int32, ndim=1, codec='zstd')
340
- tok.append([seq_a, seq_b, seq_c])
341
- tok.close()
346
+ tok.append([seq_a, seq_b, seq_c]) # owned batch accepted by the bounded writer
347
+ tok.close() # drain, then publish
342
348
 
343
349
  with Dense.open('mnist/x') as ds:
344
350
  first_four = ds[:4] # opened containers are read-only
@@ -349,9 +355,12 @@ the native Header, must be in `1..255`, and defaults to four. Values near the
349
355
  writer lane count spread payload writes across independent files; opening a
350
356
  completed container discovers the value automatically.
351
357
 
352
- Dense and Ragged append both report native errors in the current call and return
353
- only after accepting the batch. A writer cannot be read, and a reader cannot be
354
- appended to. ``close()`` on a writer publishes the container Header;
358
+ Dense append reports native errors in the current call. Ragged validation errors
359
+ are direct; a background native error poisons that creator and is reported by a
360
+ later append or ``close()``. A failed build is discarded and rebuilt rather than
361
+ recovered; deterministic ``close()`` or a context manager is required to observe
362
+ writer errors. A writer cannot be read, and a reader cannot be appended to.
363
+ ``close()`` on a writer publishes the container Header;
355
364
  ``close()`` on a reader releases it. Dense, Ragged, and DataLoader support
356
365
  ``with`` for scoped lifetimes. Content is never changed in place: rerun the
357
366
  authoritative build at a new path, validate it, then switch consumers to it.
@@ -380,29 +389,16 @@ published without one.
380
389
  for general-purpose compression; it is fast and must be selected explicitly.
381
390
 
382
391
  `"zstd_dict"` trains a shared dictionary on a sample of the data before writing
383
- any record, then compresses every record against it at level 15. The dictionary
392
+ any record, then compresses every record against it at level 3. The dictionary
384
393
  captures structure shared across records that per-record compression cannot see —
385
- a large win for many small, similar records (image tiles, token sequences).
386
-
387
- The dictionary's cost is a cache footprint: every record's decompression
388
- references the shared dictionary window, so a larger dictionary means more
389
- cache misses on gather — the path a loader pays forever. Three named tiers
390
- (`loaderx.zrecord.DICT_TIERS`) preset the whole tradeoff — the dictionary size
391
- and how much data trains it — so a caller picks a tier, never a number:
392
-
393
- | tier | dict | sample | tradeoff |
394
- |------|------|--------|----------|
395
- | `"fast"` | 32 KiB | 4 MiB | fastest gather and training; ratio barely above `zstd` |
396
- | `"balanced"` | 128 KiB | 16 MiB | **default** — most of the ratio at a fraction of the gather cost |
397
- | `"max"` | 1 MiB | 64 MiB | best ratio; slowest gather and training |
398
-
399
- The sample is the byte budget the dictionary trains on (a strided subset of the
400
- records), so each tier costs the same training time whatever the record size.
401
- At realistic image scale (768 KiB records) the tiers converge — on the earlier
402
- measurement box's structured data `"balanced"` and `"max"` both gather
403
- ~1.6 GiB/s at a 1.74x ratio — because a dictionary is a small fraction of a
404
- large frame. The tiers still matter at small record sizes, where the dict is
405
- most of a record and `"max"` trades gather throughput for ratio.
394
+ a useful fit for large corpora of small, similar records such as token sequences
395
+ and image tiles. Plain `"zstd"` or `"raw"` remains the better default for large
396
+ records and small corpora.
397
+
398
+ Dictionary geometry is fixed: `train_dict` trains a dictionary of at most 32 KiB
399
+ from a strided sample bounded at 4 MiB. Real WikiText and MNIST profiling found
400
+ that larger 128 KiB and 1 MiB dictionaries added training and cache cost without
401
+ a stable ratio or gather advantage. There is no dictionary tuning API.
406
402
 
407
403
  `"zstd_dict"` records can only be read from a store that has the dictionary
408
404
  (`dict.zr`). The dictionary is loaded on open and shared, lock-free, across all
@@ -410,7 +406,7 @@ reader threads.
410
406
 
411
407
  A dictionary must train on the settled, complete data. :func:`train_dict` is the
412
408
  standalone, **manual** training step — a numpy array, an iterable of records, or
413
- a typed container all train the same way, sized by a tier — and its bytes are handed to
409
+ a typed container all train the same fixed contract — and its bytes are handed to
414
410
  a container-writing path via ``dict_bytes``. ``zstd_dict`` never trains by itself: a
415
411
  write without a dictionary is an error. A stream cannot train its own
416
412
  dictionary, but it can write with one trained on the settled data:
@@ -420,7 +416,7 @@ from loaderx.utils import train_dict
420
416
  from loaderx.zrecord import Dense, Ragged
421
417
 
422
418
  # train once on the settled data — a standalone, reusable artifact
423
- d = train_dict(settled_array, tier="balanced")
419
+ d = train_dict(settled_array)
424
420
 
425
421
  # then any new store can install it and append explicitly
426
422
  with Ragged.create('tokens', np.int32, ndim=1,
@@ -555,7 +551,8 @@ caller's to own and reuse. This is the entire H2D answer — there is no `pin=`
555
551
  hook or device backend, because the only unified thing a multi-framework loader
556
552
  can own is the CPU batch.
557
553
 
558
- For practical integration examples, please refer to the **[Data2Latent](https://codeberg.org/eoelab/Data2Latent)** repository
554
+ For a practical JAX/Flax integration, see the
555
+ **[MNIST layer-representation example](examples/mnist_latent/)**.
559
556
 
560
557
  ## Benchmarks
561
558
 
@@ -568,12 +565,14 @@ so CFFI, NumPy allocation, and Ragged list/shape reconstruction are timed.
568
565
 
569
566
  ### Methodology
570
567
 
571
- The comparison matrix began as one complete run on a warm page cache. All
572
- Zrecord Store rows and the two loaderx identity rows were refreshed on 2.3.0
573
- with the default `data_shards=4`. Unchanged
574
- optional Store backends, sampler rows and external loader rows remain from the
575
- immediately preceding 2.0.9 run. These are not three-run medians: an unexpected result is traced
576
- separately instead of being hidden by repeated aggregation. Within each store workload every
568
+ The comparison matrix began as one complete run on a warm page cache. Most Store
569
+ matrices and the loader rows were refreshed on 2.3.6 with the default
570
+ `data_shards=4`; the Dense token matrix was refreshed on 2.3.8 after the append
571
+ window increased to 32,768 records. Both Ragged matrices were refreshed after
572
+ the bounded writer began overlapping owned packing with native append. Every
573
+ workload uses a prepared real source.
574
+ These are not three-run medians: an unexpected result is traced separately
575
+ instead of being hidden by repeated aggregation. Within each store workload every
577
576
  backend receives identical source records. Correctness and timing use independent
578
577
  deterministic `zsampler` IID streams. Loader backends receive
579
578
  the same source and seed but use their own shipped samplers, so their exact
@@ -592,7 +591,7 @@ operation. Reusable source preparation is outside that timer; in particular,
592
591
  The measured Store paths are explicit:
593
592
 
594
593
  ```text
595
- write: make_data returns -> writer setup [untimed]
594
+ write: source is ready -> writer setup [untimed]
596
595
  -> start -> encode/pack -> append/write -> logical finalize -> return -> stop
597
596
  -> resource-only cleanup [untimed]
598
597
 
@@ -617,8 +616,10 @@ reconstruction are included, while open, close and destruction after return are
617
616
  not.
618
617
  Every backend name states its actual codec; the full default set is required
619
618
  rather than silently skipped when a package is missing.
620
- Dense and Ragged use the same CHW RGB image generator, record count, batch plan
621
- and seed. Dense fixes every image at `(3, 224, 224)`; Ragged changes only H and W.
619
+ The vision source is the Oxford-IIIT Pet train split prepared by
620
+ `scripts/prepare_vision.py`. Dense uses RGB photographs resized on the short side
621
+ to 256 and center-cropped to `(3, 224, 224)`; Ragged uses the same ordered source
622
+ at native RGB resolution. Both are mmap-loaded uint8 CHW records.
622
623
 
623
624
  **Machine** — one local workstation (AMD Ryzen AI 9 HX PRO 370, 12 cores / 24
624
625
  threads):
@@ -642,75 +643,67 @@ pipeline. Store reads run on the ordinary page cache.
642
643
 
643
644
  #### Fixed-Shape Dense
644
645
 
645
- Zrecord against array-store alternatives: random batch gather, 2,500 CHW RGB
646
- records, batch 256. Every image is `(3, 224, 224)` and comes from the same
647
- spatial model used by the variable-shape benchmark.
646
+ Zrecord against array-store alternatives: random batch gather over the first
647
+ 2,500 Oxford-IIIT Pet train images, batch 256. Every prepared image is
648
+ `uint8[3,224,224]`; `metadata.json` records the source revision, transform,
649
+ decoder versions and logical SHA-256.
648
650
 
649
651
  Fixed-resolution vision records — 147 KiB per record, 36.8 MiB per batch:
650
652
 
651
653
  | backend | logical write | logical gather | krecords/s | p95 | disk | ratio |
652
654
  |---|---:|---:|---:|---:|---:|---:|
653
- | zrecord-zstd | 7172 MiB/s | 11081 MiB/s | 77.2 | 4.38 ms | 24.4 MiB | 14.69x |
654
- | zrecord-zstdict | 104 MiB/s | 12042 MiB/s | 83.9 | 4.09 ms | 16.2 MiB | 22.10x |
655
- | zrecord-raw | 5721 MiB/s | 14457 MiB/s | 100.7 | 3.16 ms | 358.9 MiB | 1.00x |
656
- | npy-mmap-raw | 2004 MiB/s | 4749 MiB/s | 33.1 | 11.08 ms | 358.9 MiB | 1.00x |
657
- | hdf5-raw | 2350 MiB/s | 1836 MiB/s | 12.8 | 29.68 ms | 359.0 MiB | 1.00x |
658
- | hdf5-gzip | 277 MiB/s | 657 MiB/s | 4.6 | 62.53 ms | 26.1 MiB | 13.73x |
659
- | lmdb-raw | 1546 MiB/s | 4034 MiB/s | 28.1 | 11.38 ms | 361.4 MiB | 0.99x |
660
- | arrow-ipc-raw | 1766 MiB/s | 3413 MiB/s | 23.8 | 15.10 ms | 358.9 MiB | 1.00x |
661
- | arrow-ipc-zstd | 656 MiB/s | 174 MiB/s | 1.2 | 239.23 ms | 22.6 MiB | 15.86x |
662
- | parquet-raw | 1174 MiB/s | 435 MiB/s | 3.0 | 95.45 ms | 358.9 MiB | 1.00x |
663
- | parquet-zstd | 592 MiB/s | 159 MiB/s | 1.1 | 251.37 ms | 22.6 MiB | 15.86x |
664
- | arrayrecord-raw | 1704 MiB/s | 2066 MiB/s | 14.4 | 20.36 ms | 359.2 MiB | 1.00x |
665
- | arrayrecord-zstd | 804 MiB/s | 1294 MiB/s | 9.0 | 36.89 ms | 25.1 MiB | 14.32x |
666
- | tiledb-raw | 743 MiB/s | 630 MiB/s | 4.4 | 66.01 ms | 359.0 MiB | 1.00x |
667
- | tiledb-zstd | 1498 MiB/s | 1503 MiB/s | 10.5 | 27.82 ms | 26.9 MiB | 13.36x |
668
-
669
- At 147 KiB per record, Zrecord-raw reaches 14.1 GiB/s and is 3.0x npy-mmap-raw;
670
- plain zstd gathers at 10.8 GiB/s while reducing the corpus 14.69x. LMDB and Arrow
655
+ | zrecord-zstd | 1375 MiB/s | 6020 MiB/s | 41.9 | 6.97 ms | 311.1 MiB | 1.15x |
656
+ | zrecord-zstdict | 1145 MiB/s | 7318 MiB/s | 51.0 | 6.06 ms | 320.1 MiB | 1.12x |
657
+ | zrecord-raw | 5111 MiB/s | 14808 MiB/s | 103.2 | 2.81 ms | 358.9 MiB | 1.00x |
658
+ | npy-mmap-raw | 2023 MiB/s | 4751 MiB/s | 33.1 | 10.46 ms | 358.9 MiB | 1.00x |
659
+ | hdf5-raw | 2310 MiB/s | 1903 MiB/s | 13.3 | 22.33 ms | 359.0 MiB | 1.00x |
660
+ | hdf5-gzip | 41 MiB/s | 213 MiB/s | 1.5 | 193.93 ms | 301.8 MiB | 1.19x |
661
+ | lmdb-raw | 1359 MiB/s | 4120 MiB/s | 28.7 | 10.10 ms | 361.4 MiB | 0.99x |
662
+ | arrow-ipc-raw | 1117 MiB/s | 3439 MiB/s | 24.0 | 12.89 ms | 358.9 MiB | 1.00x |
663
+ | arrow-ipc-zstd | 223 MiB/s | 97 MiB/s | 0.7 | 399.21 ms | 305.9 MiB | 1.17x |
664
+ | parquet-raw | 1237 MiB/s | 454 MiB/s | 3.2 | 85.72 ms | 358.9 MiB | 1.00x |
665
+ | parquet-zstd | 215 MiB/s | 80 MiB/s | 0.6 | 480.45 ms | 305.9 MiB | 1.17x |
666
+ | arrayrecord-raw | 1852 MiB/s | 2092 MiB/s | 14.6 | 20.84 ms | 359.2 MiB | 1.00x |
667
+ | arrayrecord-zstd | 219 MiB/s | 1779 MiB/s | 12.4 | 23.15 ms | 320.1 MiB | 1.12x |
668
+
669
+ At 147 KiB per record, Zrecord-raw reaches 14.5 GiB/s and is 3.1x npy-mmap-raw.
670
+ Decoded photographs have little remaining redundancy: plain zstd reduces them
671
+ only 1.15x, while dictionary mode falls to 1.12x. This is
672
+ why large real images should use plain zstd or raw. LMDB and Arrow
671
673
  IPC are competitive raw record
672
674
  stores, while codecs tied to whole IPC batches or Parquet row groups pay read
673
675
  amplification on random gathers. Dense demonstrates that
674
676
  typed record ownership and per-record compression do not turn fixed tensors
675
677
  into an object-store slow path.
676
678
 
677
- #### Variable-Shape Ragged
679
+ #### Native-Resolution Ragged
678
680
 
679
- This workload contains 2,500 variable-resolution CHW RGB images. Height and
680
- width are independently lognormal and clipped to 64..512 (observed medians
681
- 223 and 224), totaling 417.1 MiB of logical uint8 payload. Each of 50 random
681
+ This workload contains the first 2,500 native-resolution Oxford-IIIT Pet CHW RGB
682
+ images. Height is 108..2606 (median 375) and width is 117..3264 (median 500),
683
+ totaling 1252.3 MiB of logical uint8 payload. Each of 50 random
682
684
  batches contains 256 records. Every backend persists payload plus exact shape
683
685
  and must return an ordered `list[np.ndarray]` of `(3, H, W)` arrays; a flat byte
684
686
  list or a one-dimensional variable-length abstraction is not enough.
685
687
 
686
688
  | backend | logical write | logical gather | krecords/s | p95 | disk | ratio |
687
689
  |---|---:|---:|---:|---:|---:|---:|
688
- | zrecord-zstd | 2220 MiB/s | 9444 MiB/s | 56.7 | 5.67 ms | 26.9 MiB | 15.48x |
689
- | zrecord-zstdict | 102 MiB/s | 10345 MiB/s | 62.1 | 5.15 ms | 18.2 MiB | 22.97x |
690
- | zrecord-raw | 2171 MiB/s | 12356 MiB/s | 74.2 | 4.22 ms | 417.2 MiB | 1.00x |
691
- | hdf5-raw | 1451 MiB/s | 1059 MiB/s | 6.4 | 44.91 ms | 418.0 MiB | 1.00x |
692
- | hdf5-gzip | 250 MiB/s | 126 MiB/s | 0.7 | 359.23 ms | 29.9 MiB | 13.94x |
693
- | lmdb-raw | 1717 MiB/s | 7269 MiB/s | 43.6 | 7.93 ms | 422.2 MiB | 0.99x |
694
- | arrow-ipc-raw | 1363 MiB/s | 4015 MiB/s | 24.1 | 14.97 ms | 417.2 MiB | 1.00x |
695
- | arrow-ipc-zstd | 570 MiB/s | 198 MiB/s | 1.2 | 238.70 ms | 25.9 MiB | 16.10x |
696
- | parquet-raw | 927 MiB/s | 501 MiB/s | 3.0 | 94.62 ms | 417.2 MiB | 1.00x |
697
- | parquet-zstd | 507 MiB/s | 173 MiB/s | 1.0 | 268.56 ms | 25.9 MiB | 16.10x |
698
- | arrayrecord-raw | 1650 MiB/s | 2661 MiB/s | 16.0 | 18.19 ms | 417.6 MiB | 1.00x |
699
- | arrayrecord-zstd | 758 MiB/s | 1499 MiB/s | 9.0 | 39.16 ms | 27.2 MiB | 15.31x |
700
- | tiledb-raw | 392 MiB/s | 48 MiB/s | 0.3 | 941.09 ms | 417.2 MiB | 1.00x |
701
- | tiledb-zstd | 675 MiB/s | 138 MiB/s | 0.8 | 328.05 ms | 27.0 MiB | 15.46x |
702
-
703
- Zrecord-raw is 1.7x LMDB and 3.1x Arrow IPC in logical gather. Zrecord-zstd
704
- delivers 9.2 GiB/s of
705
- logical payload while reducing the corpus to 26.9 MiB. HDF5, Arrow IPC, Parquet,
706
- ArrayRecord and TileDB
707
- show the same framework/codec tradeoffs in both tables; compressed batch, chunk
708
- and row-group formats pay read amplification on random records.
709
-
710
- The shared generator makes compression ratios directly comparable across
711
- contracts: Zrecord zstd is 14.69x Dense versus 15.48x Ragged, and zstdict is
712
- 22.10x versus 22.97x. The remaining difference comes from the H/W distribution
713
- and Ragged shape metadata, not a different image entropy model.
690
+ | zrecord-zstd | 1077 MiB/s | 5160 MiB/s | 10.3 | 46.26 ms | 1032.2 MiB | 1.21x |
691
+ | zrecord-zstdict | 815 MiB/s | 5075 MiB/s | 10.1 | 44.99 ms | 1032.9 MiB | 1.21x |
692
+ | zrecord-raw | 2407 MiB/s | 13793 MiB/s | 27.6 | 13.97 ms | 1252.4 MiB | 1.00x |
693
+ | hdf5-raw | 1879 MiB/s | 2336 MiB/s | 4.7 | 64.39 ms | 1253.1 MiB | 1.00x |
694
+ | lmdb-raw | 1779 MiB/s | 9218 MiB/s | 18.4 | 21.76 ms | 1257.0 MiB | 1.00x |
695
+ | arrow-ipc-raw | 1348 MiB/s | 4416 MiB/s | 8.8 | 40.51 ms | 1252.4 MiB | 1.00x |
696
+ | parquet-raw | 713 MiB/s | 512 MiB/s | 1.0 | 281.02 ms | 1252.4 MiB | 1.00x |
697
+ | arrayrecord-raw | 1877 MiB/s | 2839 MiB/s | 5.7 | 68.32 ms | 1253.0 MiB | 1.00x |
698
+ | arrayrecord-zstd | 215 MiB/s | 2074 MiB/s | 4.1 | 92.45 ms | 1054.6 MiB | 1.19x |
699
+
700
+ Zrecord-raw is 1.5x LMDB and 3.1x Arrow IPC in logical gather. Plain and
701
+ dictionary zstd both reach 1.21x, confirming that dictionary mode is not useful
702
+ for these large photographs. The Ragged matrix is intentionally asymmetric:
703
+ HDF5 gzip, Arrow IPC zstd and Parquet zstd adapters are not implemented because
704
+ the real 256-record batch took 1.1–1.7 seconds; TileDB variable queries took
705
+ 8.6–9.6 seconds and the backend was removed entirely. ArrayRecord zstd remains
706
+ because its batch p95 is 92 ms.
714
707
 
715
708
  ### Small Token Records
716
709
 
@@ -729,19 +722,20 @@ accumulate at least two seconds.
729
722
 
730
723
  | backend | logical write | logical gather | krecords/s | p95 | disk | ratio |
731
724
  |---|---:|---:|---:|---:|---:|---:|
732
- | zrecord-zstd | 989 MiB/s | 2012 MiB/s | 1030.3 | 0.34 ms | 193.2 MiB | 2.02x |
733
- | zrecord-zstdict | 62 MiB/s | 2079 MiB/s | 1064.6 | 0.32 ms | 154.4 MiB | 2.53x |
734
- | zrecord-raw | 4542 MiB/s | 6391 MiB/s | 3272.3 | 0.11 ms | 393.7 MiB | 0.99x |
735
- | npy-mmap-raw | 1587 MiB/s | 9070 MiB/s | 4644.0 | 0.08 ms | 390.6 MiB | 1.00x |
736
- | lmdb-raw | 639 MiB/s | 1104 MiB/s | 565.0 | 0.71 ms | 786.3 MiB | 0.50x |
737
- | arrow-ipc-raw | 2068 MiB/s | 225 MiB/s | 115.0 | 2.81 ms | 390.8 MiB | 1.00x |
738
- | arrayrecord-raw | 807 MiB/s | 150 MiB/s | 76.7 | 4.99 ms | 401.4 MiB | 0.97x |
739
- | arrayrecord-zstd | 127 MiB/s | 135 MiB/s | 69.4 | 4.45 ms | 201.3 MiB | 1.94x |
740
-
741
- The contiguous NumPy baseline is strongest when the whole corpus is one fixed
742
- typed matrix. Zrecord-raw reaches 3.27 Mrecords/s while retaining independent
743
- record semantics; the per-record zstd codecs halve disk and still return
744
- 1.03–1.06 Mrecords/s. LMDB's B-tree/page overhead is visible in both throughput
725
+ | zrecord-zstd | 1060 MiB/s | 2149 MiB/s | 1100.2 | 0.33 ms | 193.2 MiB | 2.02x |
726
+ | zrecord-zstdict | 1435 MiB/s | 2478 MiB/s | 1268.7 | 0.28 ms | 168.5 MiB | 2.32x |
727
+ | zrecord-raw | 5535 MiB/s | 7056 MiB/s | 3612.5 | 0.10 ms | 393.7 MiB | 0.99x |
728
+ | npy-mmap-raw | 1771 MiB/s | 10306 MiB/s | 5276.6 | 0.07 ms | 390.6 MiB | 1.00x |
729
+ | lmdb-raw | 692 MiB/s | 1133 MiB/s | 580.3 | 0.61 ms | 786.3 MiB | 0.50x |
730
+ | arrow-ipc-raw | 1330 MiB/s | 213 MiB/s | 109.2 | 4.09 ms | 390.8 MiB | 1.00x |
731
+ | arrayrecord-raw | 887 MiB/s | 158 MiB/s | 80.8 | 5.16 ms | 401.4 MiB | 0.97x |
732
+ | arrayrecord-zstd | 123 MiB/s | 134 MiB/s | 68.5 | 4.69 ms | 201.3 MiB | 1.94x |
733
+
734
+ The contiguous NumPy baseline is strongest for gather when the whole corpus is
735
+ one fixed typed matrix. Zrecord-raw reaches 3.61 Mrecords/s while retaining
736
+ independent record semantics and writes 3.1x faster than npy-mmap-raw;
737
+ dictionary zstd writes 35% faster than plain zstd, uses 13% less disk and gathers
738
+ 15% faster in this pass. LMDB's B-tree/page overhead is visible in both throughput
745
739
  and disk.
746
740
 
747
741
  #### Variable Token Sequences
@@ -753,18 +747,18 @@ with exact `int32` values and original one-dimensional shapes.
753
747
 
754
748
  | backend | logical write | logical gather | krecords/s | p95 | disk | ratio |
755
749
  |---|---:|---:|---:|---:|---:|---:|
756
- | zrecord-zstd | 287 MiB/s | 315 MiB/s | 594.6 | 0.60 ms | 67.4 MiB | 1.57x |
757
- | zrecord-zstdict | 54 MiB/s | 332 MiB/s | 627.6 | 0.58 ms | 49.1 MiB | 2.16x |
758
- | zrecord-raw | 536 MiB/s | 389 MiB/s | 734.9 | 0.50 ms | 110.5 MiB | 0.96x |
759
- | lmdb-raw | 318 MiB/s | 113 MiB/s | 214.3 | 1.48 ms | 153.0 MiB | 0.69x |
760
- | arrow-ipc-raw | 562 MiB/s | 44 MiB/s | 83.1 | 4.00 ms | 109.9 MiB | 0.96x |
761
- | arrayrecord-raw | 288 MiB/s | 26 MiB/s | 49.3 | 7.39 ms | 118.8 MiB | 0.89x |
762
- | arrayrecord-zstd | 62 MiB/s | 33 MiB/s | 61.5 | 5.58 ms | 76.2 MiB | 1.39x |
750
+ | zrecord-zstd | 499 MiB/s | 369 MiB/s | 697.7 | 0.49 ms | 67.4 MiB | 1.57x |
751
+ | zrecord-zstdict | 587 MiB/s | 409 MiB/s | 771.9 | 0.44 ms | 53.0 MiB | 2.00x |
752
+ | zrecord-raw | 668 MiB/s | 469 MiB/s | 885.7 | 0.39 ms | 110.5 MiB | 0.96x |
753
+ | lmdb-raw | 369 MiB/s | 114 MiB/s | 214.6 | 2.10 ms | 151.8 MiB | 0.70x |
754
+ | arrow-ipc-raw | 345 MiB/s | 45 MiB/s | 85.0 | 4.11 ms | 109.1 MiB | 0.97x |
755
+ | arrayrecord-raw | 282 MiB/s | 26 MiB/s | 49.5 | 8.08 ms | 118.0 MiB | 0.90x |
756
+ | arrayrecord-zstd | 62 MiB/s | 28 MiB/s | 52.2 | 6.22 ms | 76.0 MiB | 1.39x |
763
757
 
764
758
  Here the record contract, not bulk byte bandwidth, is the useful scale.
765
- Zrecord's three codecs return 595–735 krecords/s with 0.50–0.60 ms p95;
766
- the dictionary gives the best disk ratio and is slightly ahead of plain zstd in
767
- this pass.
759
+ Zrecord's three codecs return 698–886 krecords/s with 0.39–0.49 ms p95.
760
+ Dictionary zstd writes 18% faster than plain zstd, uses 21% less disk and gathers
761
+ 11% faster in this pass.
768
762
 
769
763
  ### Sampler
770
764
 
@@ -785,7 +779,7 @@ a 1.87–7.96x margin across batch sizes.
785
779
 
786
780
  The full input pipeline comparison (sample, fetch, collate, hand over a batch)
787
781
  uses exactly the Dense vision source above: 2,500 `(3,224,224)` uint8
788
- records from `make_vision_records`, 4 high-level workers, and batch 256
782
+ Oxford-IIIT Pet records from the prepared mmap corpus, 4 high-level workers, and batch 256
789
783
  (36.8 MiB). After warmup, throughput and memory are collected during one
790
784
  200-batch qualitative pass. `peak PSS` sums proportional
791
785
  set size across the process tree, apportioning mapped shared and copy-on-write
@@ -809,19 +803,19 @@ and Grain reads ArrayRecord.
809
803
 
810
804
  | loader | model | storage | batches/s | p95 | steady PSS | peak PSS | peak RSS |
811
805
  |---|---|---|---:|---:|---:|---:|---:|
812
- | **loaderx** | threads | zrecord-zstd | 171.5 | 12.69 ms | 984 MiB | 985 MiB | 988 MiB |
813
- | loaderx-raw | threads | zrecord-raw | 200.0 | 12.50 ms | 993 MiB | 993 MiB | 996 MiB |
814
- | torch | fork | npy-mmap-raw | 109.4 | 32.70 ms | 1783 MiB | 1889 MiB | 6396 MiB |
815
- | torch-spawn | spawn | npy-mmap-raw | 111.6 | 30.69 ms | 2835 MiB | 2913 MiB | 4880 MiB |
816
- | grain | processes | arrayrecord-zstd | 46.6 | 93.48 ms | 1847 MiB | 1946 MiB | 2065 MiB |
806
+ | **loaderx** | threads | zrecord-zstd | 129.2 | 10.68 ms | 641 MiB | 666 MiB | 670 MiB |
807
+ | loaderx-raw | threads | zrecord-raw | 226.7 | 7.97 ms | 668 MiB | 669 MiB | 672 MiB |
808
+ | torch | fork | npy-mmap-raw | 91.7 | 40.30 ms | 1403 MiB | 1597 MiB | 3845 MiB |
809
+ | torch-spawn | spawn | npy-mmap-raw | 115.2 | 30.41 ms | 2632 MiB | 2710 MiB | 4700 MiB |
810
+ | grain | processes | arrayrecord-zstd | 43.0 | 101.51 ms | 1706 MiB | 1770 MiB | 1892 MiB |
817
811
 
818
812
  At 36.8 MiB per batch the per-batch gather dominates the tiny sampler cost, and
819
813
  the transform threads overlap Python-side collation with the next gather. The
820
814
  memory is the source, Zrecord container and bounded in-flight batches. loaderx prefetches in
821
815
  threads inside one process, so workers share one interpreter, one NumPy runtime
822
816
  and one set of gather buffers. With source geometry and entropy held constant,
823
- raw is 1.17x compressed loaderx; compressed loaderx is 1.57x Torch fork, 1.54x
824
- Torch spawn and 3.68x Grain, while raw is 1.83x, 1.79x and 4.29x faster.
817
+ raw is 1.75x compressed loaderx; compressed loaderx is 1.41x Torch fork, 1.12x
818
+ Torch spawn and 3.00x Grain, while raw is 2.47x, 1.97x and 5.27x faster.
825
819
  Torch's aggregate RSS is high because
826
820
  Linux fork mappings are counted repeatedly; it is not a total-memory ratio
827
821
  against Zrecord's unaccounted page cache. The explicit `torch-spawn` row removes
@@ -830,19 +824,19 @@ not copy the full corpus into every worker; a Windows Dataset holding Python
830
824
  lists or in-memory arrays would be a different, deliberately harsher workload.
831
825
 
832
826
  The Torch-only worker sweep runs each count once. Worker 0 is an in-process
833
- baseline (154.5 and 163.5 batches/s with 1484/1486 MiB peak PSS in the two equivalent
827
+ baseline (74.8 and 79.8 batches/s with 1413/1415 MiB peak PSS in the two equivalent
834
828
  rows), so the process-context comparison starts at one worker:
835
829
 
836
830
  | workers | fork batches/s | fork peak PSS | fork peak RSS | spawn batches/s | spawn peak PSS | spawn peak RSS |
837
831
  |---:|---:|---:|---:|---:|---:|---:|
838
- | 1 | 42.5 | 1647 MiB | 2483 MiB | 46.3 | 1890 MiB | 2128 MiB |
839
- | 2 | 68.9 | 1725 MiB | 3796 MiB | 72.3 | 2241 MiB | 3066 MiB |
840
- | 4 | 106.0 | 1849 MiB | 6385 MiB | 102.7 | 2878 MiB | 4859 MiB |
841
- | 8 | 114.3 | 2021 MiB | 11334 MiB | 107.8 | 4195 MiB | 8402 MiB |
842
-
843
- Spawn peak PSS grows from 1890 to 4195 MiB as workers rise from one to eight,
844
- while fork grows from 1647 to 2021 MiB because it retains COW sharing. At eight
845
- workers spawn uses 2.08x fork's peak PSS and throughput has already flattened.
832
+ | 1 | 49.3 | 1428 MiB | 1733 MiB | 46.8 | 1711 MiB | 1950 MiB |
833
+ | 2 | 78.2 | 1512 MiB | 2481 MiB | 79.0 | 2068 MiB | 2893 MiB |
834
+ | 4 | 111.5 | 1614 MiB | 3898 MiB | 113.1 | 2729 MiB | 4710 MiB |
835
+ | 8 | 123.2 | 1802 MiB | 6579 MiB | 124.2 | 4039 MiB | 8189 MiB |
836
+
837
+ Spawn peak PSS grows from 1711 to 4039 MiB as workers rise from one to eight,
838
+ while fork grows from 1428 to 1802 MiB because it retains COW sharing. At eight
839
+ workers spawn uses 2.24x fork's peak PSS and throughput has already flattened.
846
840
  This demonstrates no-fork memory pressure; it is not labeled OOM because this
847
841
  31 GiB machine completed the run. Fork aggregate RSS grows faster because Linux
848
842
  counts shared/COW mappings in every process, so RSS is diagnostic rather than
@@ -851,20 +845,19 @@ physical memory.
851
845
  **CPU-heavy transform solutions.** The same Python per-sample transform exposes
852
846
  the GIL bottleneck on standard CPython. Numba is an explicit solution, not the
853
847
  default: `--transform numba-nogil` compiles the equivalent batch transform with
854
- `nogil=True`. The other explicit solution runs the Python transform on
855
- free-threaded CPython. Numba compilation is warmed before timing. Store
856
- microbenchmarks are not repeated under free-threaded Python because Loaderx has
857
- no separate no-GIL Store implementation; the Store table above applies to both.
848
+ `nogil=True`. The other explicit solution runs the unchanged Python transform on
849
+ free-threaded CPython. Numba compilation is warmed before timing; both
850
+ interpreters use NumPy 2.4.6 and the same prepared real corpus.
858
851
 
859
852
  | loader | GIL Python | GIL + Numba nogil | free-threaded Python | Numba gain | free-threaded gain |
860
853
  |---|---:|---:|---:|---:|---:|
861
- | **loaderx** | 48.8 batches/s | 107.2 batches/s | 88.0 batches/s | **2.20x** | **1.80x** |
862
- | loaderx-raw | 51.2 batches/s | 113.1 batches/s | 94.1 batches/s | **2.21x** | **1.84x** |
854
+ | **loaderx** | 50.2 batches/s | 101.5 batches/s | 86.2 batches/s | **2.02x** | **1.72x** |
855
+ | loaderx-raw | 57.7 batches/s | 130.8 batches/s | 98.4 batches/s | **2.27x** | **1.71x** |
863
856
 
864
- Peak PSS for compressed/raw was 1193/1202 MiB with GIL Python,
865
- 1291/1314 MiB with Numba, and 1190/1191 MiB with free-threaded Python. These are
866
- two deployment solutions to the transform bottleneck, not claims that Store
867
- itself was optimized for either runtime.
857
+ Peak PSS for compressed/raw was 878/883 MiB with GIL Python, 942/967 MiB with
858
+ Numba, and 872/900 MiB with free-threaded Python. These are two deployment
859
+ solutions to the transform bottleneck, not claims that Store itself was
860
+ optimized for either runtime.
868
861
 
869
862
  **Conclusion** — why the numbers look like this.
870
863
 
@@ -889,14 +882,15 @@ specialization for compression and a complete variable-shape persistence model.
889
882
  "storage plus a codec": the layout, the multi-core decompress and the GIL-free
890
883
  copy are one path, so turning compression on costs part of a margin, not an
891
884
  order of magnitude. The ratio is the data, not the
892
- format: in the current Dense structured-vision workload, plain zstd reaches
893
- 14.69x and the balanced dictionary reaches 22.10x.
885
+ format: in the current real-photograph Dense workload, plain zstd reaches only
886
+ 1.15x and the fixed dictionary reaches 1.12x. Dictionary mode is for repeated
887
+ small records, not a universal higher-ratio setting.
894
888
 
895
889
  **Loader results combine architecture and storage.** loaderx uses threads and
896
890
  never ends an epoch, so a step pays no IPC and never waits on an epoch boundary;
897
891
  torch uses finite shuffled epochs, worker processes and shared-memory handoff.
898
- Here compressed loaderx is 1.57x Torch fork, 1.54x Torch spawn and 3.68x Grain;
899
- raw loaderx is 1.83x, 1.79x and 4.29x faster, respectively.
892
+ Here compressed loaderx is 1.41x Torch fork, 1.12x Torch spawn and 3.00x Grain;
893
+ raw loaderx is 2.47x, 1.97x and 5.27x faster, respectively.
900
894
  Storage also differs per loader — each reads from what it was
901
895
  built for — so the loader table is a different comparison from either store
902
896
  table, not a rerun.
@@ -915,55 +909,18 @@ views into one batch allocation, while most byte-store adapters return
915
909
  independent copies. This is a single benchmark run, while each Store read path
916
910
  accumulates at least two timed seconds —
917
911
  the µs-scale sampler timings and the loader `batches/s` fluctuate with box load
918
- (on these 12 cores the compressed loader trails the raw one by about 22%), so
912
+ (on these 12 cores the compressed loader trails the raw one materially), so
919
913
  treat the absolute numbers as ballpark and the cross-backend margins as the
920
914
  signal.
921
915
 
922
- ### Reproduction
923
-
924
- ```bash
925
- .venv/bin/python scripts/bench_dense.py
926
- .venv/bin/python scripts/bench_ragged.py
927
-
928
- .venv/bin/python scripts/prepare_tokens.py wiki.train.tokens /tmp/wikitext-gpt2
929
- .venv/bin/python scripts/bench_dense.py --workload tokens \
930
- --token-corpus /tmp/wikitext-gpt2 --records 200000 --batches 100
931
- .venv/bin/python scripts/bench_ragged.py --workload tokens \
932
- --token-corpus /tmp/wikitext-gpt2 --records 200000 --batches 100
933
-
934
- .venv/bin/python scripts/bench.py sampler
935
- .venv/bin/python scripts/bench.py loader \
936
- --only loaderx,loaderx-raw,torch,torch-spawn,grain --workers 4
937
- .venv/bin/python scripts/bench.py loader --only torch,torch-spawn \
938
- --workers 0,1,2,4,8
939
- .venv/bin/python scripts/bench.py loader \
940
- --only loaderx,loaderx-raw --workers 4 --transform python-loop
941
- .venv/bin/python scripts/bench.py loader --only loaderx,loaderx-raw \
942
- --workers 4 --transform numba-nogil
943
-
944
- .venv-t/bin/python scripts/bench.py loader --only loaderx,loaderx-raw \
945
- --workers 4 --transform python-loop
946
- ```
947
-
948
- `prepare_tokens.py` also accepts Hugging Face WikiText Parquet shards directly.
949
- The published run used `Salesforce/wikitext`, config `wikitext-103-raw-v1`,
950
- revision `refs/convert/parquet`, train shards `0000.parquet` then
951
- `0001.parquet`; their SHA-256 values are respectively
952
- `74da360f23826045b3e6ac6375411fdb15f003030aa74f2596ed08b857cb9212` and
953
- `ba090ac30dbf5461e8dcbdd1a1b8e6f3cf9c2c756d64f0c1220450acd514f720`.
954
- The focused token defaults omit formats that are already represented in the
955
- larger vision matrix; `--only` can select any registered backend explicitly.
956
- The loader rows used Numba 0.67.0, Torch 2.13.0 and Grain 0.2.18; all benchmark dependencies
957
- are pinned in `scripts/requirements-bench.txt`. Temporary stores used the ordinary
958
- disk-backed `/tmp` filesystem, not `/dev/shm`.
959
-
960
916
  ## Real-data verification
961
917
 
962
- Dataset-specific preprocessing and verification remain in the
918
+ Production dataset-specific preprocessing and verification remain in the
963
919
  **[DataPipe](https://codeberg.org/eoelab/DataPipe)** repository. The built-in
964
920
  converter covers standardized Hugging Face datasets; DataPipe handles sources
965
921
  without a common remote protocol and implements derived modalities as loader
966
- transforms without NumPy dump intermediates.
922
+ transforms without NumPy dump intermediates. Oxford-IIIT Pet is only the shared
923
+ benchmark fixture.
967
924
 
968
925
  ## Current Limitations
969
926
  * Single-host only; multi-host training is not supported.
@@ -981,10 +938,6 @@ transforms without NumPy dump intermediates.
981
938
  zig build # host shared objects, into loaderx/lib/
982
939
  zig build test # native store suite, in both Debug and ReleaseFast
983
940
  python3 scripts/test_loaderx.py # Python integration suite against the real build
984
- uv pip install --python .venv/bin/python -r scripts/requirements-bench.txt
985
- .venv/bin/python scripts/bench_dense.py # fixed-shape store comparison
986
- .venv/bin/python scripts/bench_ragged.py # variable-length store comparison
987
- .venv/bin/python scripts/bench.py # machine, sampler, and dense loader layers
988
941
  ```
989
942
 
990
943
  The Zig side is tested for behaviour only; throughput is measured from Python,
@@ -1107,7 +1060,7 @@ defend against bypassing the public Python API do not belong in zrecord.
1107
1060
  |-------|-----------|----------------------------------------|
1108
1061
  | 0 | raw | none |
1109
1062
  | 1 | zstd | zstd (plain, level 3) |
1110
- | 2 | zstdict | zstd with a trained dictionary (level 15) |
1063
+ | 2 | zstdict | zstd with a trained dictionary (level 3) |
1111
1064
  ```
1112
1065
 
1113
1066
  7. Compression is transparent to the client:
@@ -1126,10 +1079,10 @@ defend against bypassing the public Python API do not belong in zrecord.
1126
1079
  record is still independent, random access is unchanged — but the
1127
1080
  dictionary carries the structure shared across records, which per-record
1128
1081
  compression cannot see. On many small, similar records (image tiles, token
1129
- sequences) this is a large win: the current Dense structured-vision set
1130
- is 14.69x with plain zstd and 22.10x with the balanced dictionary. The dictionary is loaded once on
1131
- open and shared, lock-free, across all reader threads. The dictionary size
1132
- is chosen from the `DICT_TIERS` presets (see Codec notes).
1082
+ sequences) this can be a large win. Decoded real photographs are a useful
1083
+ counterexample where plain zstd or raw is the better fit. The 32 KiB
1084
+ dictionary is loaded once on open and shared, lock-free, across all reader
1085
+ threads.
1133
1086
  * A `zstd_dict` store needs its dictionary to read every record; a `raw` or
1134
1087
  `zstd` store rejects an unexpected dictionary as malformed state.
1135
1088