Commit 681b63c
#### Relevant issue or PR
n/a
#### Description of changes
Adds optional lz4 compression for arrays serialized via `json+base64`
and `json+binref` encodings, opt-in through a new
`TESSERACT_COMPRESSION` config var (currently `lz4` or unset). lz4 was
chosen as the first option because it's a small, single dependency with
fast round-trips. Further codecs can be added later without touching the
encode/decode call sites.
`TESSERACT_COMPRESSION` only controls how a Tesseract *encodes its
output*. It has no effect on inputs: each array carries its own
`"compression"` field, so a Tesseract decodes any valid input —
compressed or not — regardless of config. This means you can pipe a
compressed output straight into another Tesseract without configuring
the receiver.
Key details:
- `lz4` is a new runtime dependency for all Tesseract builds.
- Arrays are compressed individually rather than compressing the whole
buffer, which preserves offset-based random access into binref files.
Because compressed length isn't derivable from shape/dtype, the binref
buffer spec is extended from `<path>:<offset>` to
`<path>:<offset>:<compressed_size>`, and a `"compression"` field is
added to the array data dict. The buffer regex and validation pattern
are updated accordingly; readers require `compressed_size` when
`compression` is set.
- `TESSERACT_COMPRESSION` is a runtime config var, so through `tesseract
run` it must be forwarded into the container with `-e` (a shell-level
prefix stays on the host):
```bash
# binref
$ tesseract run -e TESSERACT_COMPRESSION=lz4 vectoradd apply -f
json+binref -o /tmp/out @inputs.json
{"result": {..., "data": {"buffer": "arr.bin:0:35", "encoding":
"binref", "compression": "lz4"}}}
# base64
$ tesseract run -e TESSERACT_COMPRESSION=lz4 vectoradd apply -f
json+base64 @inputs.json
{"result": {..., "data": {"buffer": "<base64>", "encoding": "base64",
"compression": "lz4"}}}
```
#### Testing done
CI. New unit tests cover base64 and binref compress/decompress
round-trips, the extended buffer-spec parsing, and the "missing
compressed_size" error path; end-to-end `tesseract run` tests exercise
`TESSERACT_COMPRESSION=lz4` for both encodings.
New benchmark, too.
---------
Co-authored-by: Dion Häfner <dion.haefner@simulation.science>
1 parent dd88dfd commit 681b63c
15 files changed
Lines changed: 395 additions & 31 deletions
File tree
- benchmarks
- docs/content/using-tesseracts
- tesseract_core
- runtime
- sdk
- tests
- endtoend_tests
- runtime_tests
- sdk_tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
| |||
78 | 89 | | |
79 | 90 | | |
80 | 91 | | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | | - | |
| 96 | + | |
84 | 97 | | |
85 | 98 | | |
86 | 99 | | |
87 | 100 | | |
88 | 101 | | |
89 | 102 | | |
90 | 103 | | |
91 | | - | |
| 104 | + | |
92 | 105 | | |
93 | 106 | | |
94 | 107 | | |
95 | 108 | | |
96 | | - | |
| 109 | + | |
97 | 110 | | |
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
| 116 | + | |
| 117 | + | |
103 | 118 | | |
104 | 119 | | |
105 | 120 | | |
106 | | - | |
| 121 | + | |
107 | 122 | | |
108 | 123 | | |
109 | | - | |
| 124 | + | |
110 | 125 | | |
111 | | - | |
| 126 | + | |
112 | 127 | | |
113 | 128 | | |
114 | 129 | | |
115 | 130 | | |
116 | 131 | | |
117 | 132 | | |
118 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
119 | 136 | | |
120 | 137 | | |
121 | 138 | | |
| |||
129 | 146 | | |
130 | 147 | | |
131 | 148 | | |
| 149 | + | |
| 150 | + | |
132 | 151 | | |
133 | 152 | | |
134 | 153 | | |
135 | | - | |
| 154 | + | |
136 | 155 | | |
137 | 156 | | |
138 | 157 | | |
139 | | - | |
| 158 | + | |
140 | 159 | | |
141 | 160 | | |
142 | | - | |
| 161 | + | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
0 commit comments