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

Use one read thread and one write thread #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dzamlo
Copy link
Contributor

@dzamlo dzamlo commented Aug 5, 2018

On my machine, when benchmarking withe the provided docker image (make build && make run) show a significant speed improvement. Other small benchmarking seems to show a very small improvement.

@mre
Copy link
Owner

mre commented Aug 6, 2018

To know if this change improves performance, it would be nice to have automated benchmarks.
@vbrandl is working on the travis setup. Once he's done, we could add pv to travis, create a large file (e.g. 2GB of /dev/urandom using dd) and read it a few times with cat and fcat. (I would also use cat in order to have a baseline, because measurements could be flaky depending on how busy travis is.)

@ArniDagur
Copy link

@mre I recall testing this and seeing a performance increase. What is the state of this PR?

@mre
Copy link
Owner

mre commented Feb 2, 2019

Hey @ArniDagur,

this PR was lying dormant for a while. Thanks for the ping.
I haven't gotten around to testing it, but if you like you could provide some benchmark data to show that it's faster. The simplest way would be using time fcat on a big file and comparing the times. A more sophisticated way would be adding a benchmark test to the project and posting the results.

Would you be willing to work on that? 😊

@ArniDagur
Copy link

ArniDagur commented Feb 4, 2019

Multithreaded seems to actually be slower on my laptop for a 2 gigabyte file:

[arni@arni-pc][/tmp]% time ./fcat largefile > /dev/null
./fcat largefile > /dev/null  0.06s user 0.23s system 99% cpu 0.290 total
[arni@arni-pc][/tmp]% time ./fcat largefile > /dev/null
./fcat largefile > /dev/null  0.04s user 0.18s system 99% cpu 0.215 total
[arni@arni-pc][/tmp]% time ./fcat largefile > /dev/null
./fcat largefile > /dev/null  0.04s user 0.25s system 99% cpu 0.295 total
[arni@arni-pc][/tmp]% time ./fcat-multithreaded largefile > /dev/null
./fcat-multithreaded largefile > /dev/null  0.05s user 0.70s system 198% cpu 0.381 total
[arni@arni-pc][/tmp]% time ./fcat-multithreaded largefile > /dev/null
./fcat-multithreaded largefile > /dev/null  0.06s user 0.70s system 197% cpu 0.383 total
[arni@arni-pc][/tmp]% time ./fcat-multithreaded largefile > /dev/null
./fcat-multithreaded largefile > /dev/null  0.07s user 0.69s system 197% cpu 0.385 total
[arni@arni-pc][/tmp]% time ./fcat largefile > /dev/null
./fcat largefile > /dev/null  0.05s user 0.25s system 99% cpu 0.305 total
[arni@arni-pc][/tmp]% time ./fcat largefile > /dev/null
./fcat largefile > /dev/null  0.06s user 0.24s system 99% cpu 0.300 total
[arni@arni-pc][/tmp]% time ./fcat largefile > /dev/null
./fcat largefile > /dev/null  0.07s user 0.23s system 99% cpu 0.301 total
[arni@arni-pc][/tmp]% time ./fcat-multithreaded largefile > /dev/null
./fcat-multithreaded largefile > /dev/null  0.07s user 0.59s system 196% cpu 0.337 total
[arni@arni-pc][/tmp]% time ./fcat-multithreaded largefile > /dev/null
./fcat-multithreaded largefile > /dev/null  0.08s user 0.68s system 197% cpu 0.387 total
[arni@arni-pc][/tmp]% time ./fcat-multithreaded largefile > /dev/null
./fcat-multithreaded largefile > /dev/null  0.08s user 0.68s system 197% cpu 0.388 total

@vbrandl
Copy link
Collaborator

vbrandl commented Feb 4, 2019

Maybe using lightweight threads (e.g. rayon) over full blown OS threads might help improve the performance?

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

Successfully merging this pull request may close these issues.

4 participants