Skip to content

Unbox writer (3-5% faster) #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

alamb
Copy link
Collaborator

@alamb alamb commented Mar 18, 2025

Rationale

Using a Box<dyn Write> when there is only one actual writer implementation prevents certain inlining from occurring.

I noticed this while looking at some performance traces

Changes

Use the actual types for the writer rather than Box<dyn Write>

I measured a small but measurable 3-5% improvement using time target/release/tpchgen-cli -s 1 --output-dir=/tmp/tpchdbgen-rs

branch time
main 0m8.573s
this branch 0m8.297s

@alamb alamb changed the title Unbox writer (3% faster) Unbox writer (3-5% faster) Mar 18, 2025
@alamb alamb marked this pull request as ready for review March 18, 2025 10:53
@alamb alamb requested a review from clflushopt March 18, 2025 10:58
Copy link
Owner

@clflushopt clflushopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM fyi I did experiment with different buffer capacities for the BufWriter I noticed there are speed ups when I increased the buffer to 16 or 32 MBs on my Linux machine but I am not confident it makes sense since it would depend on page sizes and OS buffer caches because the improvements were not noticeable on my Macbook so i didn't add those.

@clflushopt clflushopt merged commit 632f87d into clflushopt:main Mar 19, 2025
2 checks passed
@clflushopt clflushopt added this to the v0.1.0 milestone Mar 19, 2025
@clflushopt clflushopt added the enhancement New feature or request label Mar 19, 2025
@alamb alamb deleted the alamb/concrete_writer branch March 19, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants