idna: optimize punycode handling, add amortized allocation API, improve error reporting #653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Benchmarks before:
Benchmarks after:
Across a few runs, I see performance improvements like this:
to_ascii_merged: 4%
to_ascii_puny_label: 12%
to_ascii_simple: 3%
to_unicode_ascii: -5% (but on a much smaller base)
to_unicode_merged_label: 14%
to_unicode_puny_label: 13%
This pretty much comes from the first four commits (each commit is logically separate and can be reviewed as such, although some of the first commits don't pay off in performance until the fourth one). The fifth commit adds a separate API that allows reusing allocations -- any performance benefits of this aren't reflected in the benchmarks because they only do one operation per benchmark. The final three commits instead improve error handling (although they don't change the API).
All of this comes at the cost of +300 SLOC in the idna crate.
I'm using this for my work project, so would like to get something like this merged.