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

[IDNA] Documentation improvements, performance improvements #155

Merged
merged 2 commits into from
Jun 19, 2022

Conversation

karwa
Copy link
Owner

@karwa karwa commented Jun 19, 2022

Before

name                                  time          std        iterations warmup           
-------------------------------------------------------------------------------------------
Constructor.HTTP.AverageURLs           24707.000 ns ±  17.66 %      53628  266289080.000 ns
Constructor.HTTP.AverageURLs.filtered  37439.000 ns ±  27.44 %      33427  416324500.000 ns
Constructor.HTTP.IDNA                 141071.000 ns ±  23.49 %       9138 1548975540.000 ns

After

name                                  time          std        iterations warmup           
-------------------------------------------------------------------------------------------
Constructor.HTTP.AverageURLs           23391.000 ns ±  24.68 %      61023  238289616.000 ns
Constructor.HTTP.AverageURLs.filtered  38563.000 ns ±  26.68 %      32004  431694166.000 ns
Constructor.HTTP.IDNA                 110999.500 ns ±  23.30 %      11272 1268018770.000 ns

The biggest issue is still the NFC normalization, which comes from Foundation and requires bridging, etc. Using the standard library NFC instead is way faster:

xcrun -toolchain swift swift build -c release -Xswiftc -DWEBURL_IDNA_USE_STDLIB_NFC                                                                                              
<plus some rpath fiddling with install_name_tool so it actually uses the toolchain stdlib>
name                                  time         std        iterations warmup          
-----------------------------------------------------------------------------------------
Constructor.HTTP.AverageURLs          24325.000 ns ±  27.30 %      54222 237479378.000 ns
Constructor.HTTP.AverageURLs.filtered 39292.000 ns ±  25.89 %      32053 439869002.000 ns
Constructor.HTTP.IDNA                 71475.000 ns ±  23.93 %      18097 788458819.000 ns

But even that could be much better. We're still buffering everything in a string, and profiling shows that is by far the biggest performance hit. That's just because of how the stdlib SPI happens to be exposed; it could offer something far more efficient and help us cut that out (also, isNFC could be way faster than we're doing it here).

So yeah - better NFC normalization APIs are what we need to really make a significant dent.

@karwa karwa merged commit 27983e9 into main Jun 19, 2022
@karwa karwa deleted the idna-docs-n-perf branch June 19, 2022 18:54
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.

None yet

1 participant