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

Why fill_array.c is much slower when write_to_memory.py? #10

Open
vsvasya opened this issue Oct 29, 2015 · 2 comments
Open

Why fill_array.c is much slower when write_to_memory.py? #10

vsvasya opened this issue Oct 29, 2015 · 2 comments

Comments

@vsvasya
Copy link

vsvasya commented Oct 29, 2015

Now, write_to_memory.py answer in this game is 2,000,000,000 bytes written in one second.
But much simpler fill_array.c gives us just 376,000,000 bytes written in one second.

PS: Thank you! You create very cool thing! ))

@kamalmarhubi
Copy link
Owner

@vsvasya thanks for asking! I haven't checked, but I think it has to do with the chunked writing. The Python code is calling write with a million bytes at a time. The cStringIO object's write method likely uses memcpy or a similar very tuned mechanism for writing the string.

Meanwhile, in fill_array.c, it's writing a byte at a time, and also seems to be doing some computation in the loop. I don't know enough to figure out which part of that is slowing it down more, and this is all speculation! :-)

@vsvasya
Copy link
Author

vsvasya commented Oct 30, 2015

Oh, yes) I remember, what writing byte by byte is much slower then memsetting by dwords or even more if using SIMD.

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