Skip to content

perf: allocate a chain's sectors for a whole write at once - #86

Merged
mdsteele merged 1 commit into
mdsteele:masterfrom
francisdb:perf/bulk-sector-allocation
Sep 10, 2026
Merged

mdsteele merged 1 commit into
mdsteele:masterfrom
francisdb:perf/bulk-sector-allocation

Conversation

@francisdb

@francisdb francisdb commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Growing a chain cost a FAT entry write for the new sector, another to link it, and a zero fill, per sector. A write past the end of a chain now takes all the sectors it needs first (Allocator::extend_chain_by), writes the FAT entries of each run of consecutive ids together, and skips the zero fill of sectors it fills completely; the unused tail of the last sector and set_len growth are still zeroed.

Measured against master with #85 merged:

case master after
write to file, 50 x 1 MiB 21.9 ms 11.8 ms
write to file, 100 x 4 KiB 5.7 ms 4.9 ms
write to memory, 50 x 1 MiB 9.6 ms 8.6 ms

It also removes the zero fill that #87's direct writes pay up front, which had made the single 256 MiB write to disk slower than 0.14.0 (136 ms to 184 ms); with this change it takes 117 ms.

@francisdb
francisdb force-pushed the perf/bulk-sector-allocation branch from 9504b08 to 697ba70 Compare September 9, 2026 05:56
Comment thread src/internal/sector.rs Outdated
@francisdb
francisdb force-pushed the perf/bulk-sector-allocation branch from 697ba70 to 6263c78 Compare September 10, 2026 06:13
A write now allocates all the sectors it needs first, writes their FAT
entries together, and skips zeroing sectors it fills completely.
@francisdb
francisdb force-pushed the perf/bulk-sector-allocation branch from 6263c78 to 456eeb5 Compare September 10, 2026 06:14
@mdsteele
mdsteele merged commit 46c1dd2 into mdsteele:master Sep 10, 2026
4 checks passed
@francisdb
francisdb deleted the perf/bulk-sector-allocation branch September 10, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants