jam1garner / jam1garner/binrw

Excessive syscalls when using BufWriter

Open
#220 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance issue
Dominant language
Rust
Stars
853
Forks
56
PR merge metrics
No merged PRs in 30d

Description

I am writing to a BufWriter<File>. Unfortunately, std::io::BufWriter::stream_position falls back to running a seek syscall to figure out the current stream position. This makes my serialization workload take ~300x longer than necessary.

As a workaround, NoSeek<BufWriter<File>> works for my usecase. In fact, the values returned by stream_position are never used by the generated code. Emitting them only when necessary should improve the performance in many cases.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing generated serialization code that calls std::io::BufWriter::stream_position and compare it with the NoSeek<BufWriter> workaround described in the issue. Determine when those position values are needed; done means unnecessary stream_position calls are omitted and the serialization workload no longer performs the avoidable seek syscalls.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.