Root cause: writeln! directly on raw File — each line (~70 bytes) triggered a separate write syscall.
Fix: Wrapped all three write-heavy functions with BufWriter::with_capacity(64KB):
generate_test_file (74M lines / ~5GB)
generate_growable_file (150K lines / ~10MB)
append_lines (caller-determined)
Added explicit flush()? + drop(file) before subsequent reads to ensure data visibility and propagate flush errors.
Fixed in 6dd87d2.
Root cause: writeln! directly on raw File — each line (~70 bytes) triggered a separate write syscall.
Fix: Wrapped all three write-heavy functions with BufWriter::with_capacity(64KB):
- generate_test_file (74M lines / ~5GB)
- generate_growable_file (150K lines / ~10MB)
- append_lines (caller-determined)
Added explicit flush()? + drop(file) before subsequent reads to ensure data visibility and propagate flush errors.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
问题
generate_test_file生成约 7400 万行,generate_growable_file生成约 15 万行,但都直接对File执行循环writeln!,没有使用BufWriter。影响
大文件生成会产生大量小写 syscall,尤其 5GB 测试文件可能慢几个数量级,影响 benchmark 可用性。
位置
crates/bench/src/data_gen.rs:54crates/bench/src/data_gen.rs:75建议
用
std::io::BufWriter::with_capacity(64 * 1024, file)包装输出文件,并在结束时 flush。Fixed in
6dd87d2.Root cause: writeln! directly on raw File — each line (~70 bytes) triggered a separate write syscall.
Fix: Wrapped all three write-heavy functions with BufWriter::with_capacity(64KB):
Added explicit flush()? + drop(file) before subsequent reads to ensure data visibility and propagate flush errors.