Skip to content
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

Please make buffer size tunable #1

Open
mocksoul opened this issue Nov 22, 2022 · 1 comment
Open

Please make buffer size tunable #1

mocksoul opened this issue Nov 22, 2022 · 1 comment

Comments

@mocksoul
Copy link

mocksoul commented Nov 22, 2022

You use 1 page size buffer for each splice call. Its fine if second splice (to pipe) allows kernel to just mark memory pages as pagecache (thus, its fast). But fails if underiying pip is slow. For example if it belongs to file opened with O_DIRECT.

Simple test to splice data between 1GB files opened with O_DIRECT each:

(2 x SATA3 RAID0 ssd)

4k    buf_size (your default):    60.67s   17MiB/s
64k   buf size:                   13.17s   78MiB/s
256k  buf size:                    9.05s  113MiB/s
1024k buf size:                    5.46s  188MiB/s
4096k buf size:                    3.80s  270MiB/s
8192k buf size:                    3.16s  325MiB/s

What did I do above:

  1. Tuned buf_size accrordingly for each run
  2. Tuned pipe buf size for both ends (fcntl F_SETPIPE_SZ) for same value as buf_size

Pipe buf is 64k by default in modern linux. Everything above 1M requires CAP_SYS_RESOURCE non-root users. 8M is maximum I was able to test, everything above returns ENOMEM for root.

Thanks!

@mocksoul mocksoul changed the title Please made buffer size tunable Please make buffer size tunable Nov 22, 2022
@danishprakash
Copy link
Owner

Thanks @mocksoul, I wasn't aware of that. Would you mind raising a PR for the same?

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

No branches or pull requests

2 participants