Commit 7a3ede2
PERF: Enlarge zlib read buffer in NIfTI reader for NAS performance
The NIfTI reader opened files with a bare gzopen(), leaving zlib at its
8 KB default internal buffer. zlib refills from the underlying file in
buffer-sized chunks, so a multi-GB .nii.gz triggered hundreds of
thousands of small reads. On network attached storage each refill is a
latency-bound round-trip, making reads disproportionately slow compared
to a local disk.
Call gzbuffer() with a 4 MiB buffer (new shared constant
nifti::k_GzReadBufferSize) immediately after every gzopen(), before the
first read/seek. This cuts the number of NAS round-trips by ~512x on a
2 GB file while costing only a few MiB of working memory. Larger buffers
yield diminishing returns once they exceed the link's bandwidth-delay
product and client read-ahead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 7cff7f2 commit 7a3ede2
3 files changed
Lines changed: 28 additions & 0 deletions
File tree
- src/Plugins/SimplnxCore/src/SimplnxCore
- Filters/Algorithms
- utils
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
381 | 387 | | |
382 | 388 | | |
383 | 389 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
49 | 66 | | |
50 | 67 | | |
51 | 68 | | |
| |||
0 commit comments