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

Suboptimal block sizes #3

Closed
lnicola opened this issue Nov 14, 2017 · 2 comments
Closed

Suboptimal block sizes #3

lnicola opened this issue Nov 14, 2017 · 2 comments

Comments

@lnicola
Copy link
Contributor

lnicola commented Nov 14, 2017

While 8192 b seems like a reasonable default for reading files, on modern systems it might be a bit too small, especially for sequential access. We should consider bumping it up a bit.

I ran a couple of tests on my NAS:

8 kb (default)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3165M  100 3165M    0     0  87.9M      0  0:00:36  0:00:36 --:--:-- 79.8M
100 3165M  100 3165M    0     0  85.5M      0  0:00:37  0:00:37 --:--:-- 79.1M
100 3165M  100 3165M    0     0  87.9M      0  0:00:36  0:00:36 --:--:-- 79.0M

32 kb
100 3165M  100 3165M    0     0   197M      0  0:00:16  0:00:16 --:--:--  168M
100 3165M  100 3165M    0     0   166M      0  0:00:19  0:00:19 --:--:--  167M
100 3165M  100 3165M    0     0   175M      0  0:00:18  0:00:18 --:--:--  167M

128 kb
100 3165M  100 3165M    0     0   175M      0  0:00:18  0:00:18 --:--:--  175M
100 3165M  100 3165M    0     0   175M      0  0:00:18  0:00:18 --:--:--  177M
100 3165M  100 3165M    0     0   186M      0  0:00:17  0:00:17 --:--:--  181M

nginx (32 kb)
100 3165M  100 3165M    0     0   143M      0  0:00:22  0:00:22 --:--:--  140M
100 3165M  100 3165M    0     0   158M      0  0:00:20  0:00:20 --:--:--  141M
100 3165M  100 3165M    0     0   150M      0  0:00:21  0:00:21 --:--:--  142M

Note that I'm using ZFS, which doesn't support sendfile(). The 128 kb value is the filesystem preferred buffer size (st_blksize in struct stat).

EDIT: notice how hyper with futures-fs was faster than nginx 👍.

@seanmonstar
Copy link
Owner

Yea, good point! I picked 8kb as its a nice default for packet size in networking. I think there's perhaps two things we could do, maybe one or the other, or both:

  1. Have a configuration option for FsPool (or just read?) on preferred buffer/read size.
  2. Check for st_blksize on cfg(unix) before starting to read a file.

Perhaps the best is to have the config option, and prefer that over st_blksize if set, so people can still explicitly say things like "even though my file system likes 128kb buffers, I don't want more than 32kb of memory used at a time". What do you think?

@lnicola
Copy link
Contributor Author

lnicola commented Dec 20, 2017

Hmm, wasn't this closed in #5?

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