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

perf impact of format_err!(..) in decode_buffer tight loop #3

Open
jjhbw opened this issue Mar 7, 2021 · 0 comments
Open

perf impact of format_err!(..) in decode_buffer tight loop #3

jjhbw opened this issue Mar 7, 2021 · 0 comments

Comments

@jjhbw
Copy link

jjhbw commented Mar 7, 2021

Hi! Thanks for these useful bindings.

I noticed that the use of format_err! slows down the tight loop in decode_buffer quite a bit. Considering it is just a static error string it performs a lot of redundant work in a tight loop and it should be trivial to refactor out. I would make a PR myself, but I couldn't get the error types to line up with the rest of the library in time.

The line in question:

.ok_or(format_err!("Conversion to primitive error"))?

A flamechart of the current situation:
Screenshot 2021-03-07 at 10 22 05

After turning the format_err! call to a static error string (copied the whole thing into my project's codebase):

Screenshot 2021-03-07 at 10 23 25

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

1 participant