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

Consider switching to string streams instead of char streams #10

Open
aantron opened this issue Mar 14, 2016 · 3 comments
Open

Consider switching to string streams instead of char streams #10

aantron opened this issue Mar 14, 2016 · 3 comments
Labels

Comments

@aantron
Copy link
Owner

aantron commented Mar 14, 2016

The performance will probably be much better, but compare and measure first.

@xguerin
Copy link

xguerin commented Jan 5, 2018

What is your intuition about this for performance improvement?

@aantron
Copy link
Owner Author

aantron commented Jan 5, 2018

For consumers that allocate something per unit of output from the parser, giving them one byte at a time makes them allocate too much. Feeding them strings at a time (so chunks, basically) amortizes the cost of their allocations. Also, if they do unbuffered I/O, it saves overhead of doing system calls or other I/O one byte at a time, in the same way.

@xguerin
Copy link

xguerin commented Jan 5, 2018

Makes sense. I was looking at the code and since most of the internal logic is byte oriented, I was wondering whether or not it made sense to convert all functions to string streams. At this moment it is not clear to me that's the case. Especially if the original intent is I/O optimization, the outer API can expose string streams while some of the logic can retain its byte stream interface.

That being said, a benefit to more generally use strings instead of bytes would be to reduce the amount of continuation calls.

@aantron aantron added this to the 0.8.2 milestone Aug 17, 2019
@aantron aantron removed this from the 0.8.2 milestone Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants