Repository navigation
Conversation
Time validation of the embedded ASMap. Measure `GetGroup` for the same IPv4 address with and without a map. The existing lookup benchmarks cover `GetMappedAS` without constructing a group.
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Use a single-prefix map with a four-byte ASN to cover the last ASN encoding class. Truncating the offset in that class must invalidate the map. Native IPv4 and its RFC 6052, RFC 6145, 6to4 and Teredo forms must resolve to the same ASN.
Skip classes with a set continuation bit, then shift in the bits of the offset within the selected class. Keep returning `INVALID` for an empty class list before reading the selected class size. On a Raspberry Pi 5 (GCC 13.3, Release), ASMapCheckStandard went from 42.65 to 39.29 ms (8.6% faster) and ASMapGetMappedASMulti went from 2266 to 2081 ns/address (8.9% faster).
Return before computing the network class when there is no map to search. On a Raspberry Pi 5 (GCC 13.3, Release), ASMapGetGroupNoMap went from 523.82 to 389.93 ns/group (34.3% faster) and AddrManAdd went from 59.40 to 50.57 ms (17.5% faster). The grouping benchmark uses one IPv4 address.
Build the lookup key on the stack. Use the computed network class to select the IPv4 encoding, and copy a native IPv6 address directly into the key. On a Raspberry Pi 5 (GCC 13.3, Release), ASMapGetMappedASMulti went from 2091 to 1934 ns/address (8.1% faster).
Reserve room for the group tag and up to `ADDR_INTERNAL_SIZE` address bytes. This also covers the four-byte ASN of a mapped group. On a Raspberry Pi 5 (GCC 13.3, Release), ASMapGetGroupMapped went from 1744.1 to 1639.8 ns/group (6.4% faster) and ASMapGetGroupNoMap went from 394.11 to 307.28 ns/group (28.3% faster). Both grouping benchmarks use one IPv4 address.
l0rinc
force-pushed
the
l0rinc/asmap-performance
branch
from
November 27, 2026 11:18
13e0803 to
4131eaa
Compare
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Problem: Addrman groups peer addresses by network prefix or (when ASMap finds a match) by autonomous system.
Without ASMap, grouping classifies the address twice.
With ASMap, an IP lookup allocates a temporary key and the decoder calculates a shift distance for each mantissa bit.
Building the group can also take several allocations for just a few bytes.
Fix: When ASMap is disabled, skip the extra address classification in
GetMappedAS.Build ASMap lookup keys on the stack and decode integers by shifting each bit into the mantissa.
Reserve space for the address group before appending its bytes.
Time to group one IPv4 address: (Raspberry Pi 5, ns per call, lower is better)
Across the full series,
AddrManAddis 19.2% faster (59.1 to 49.6 ms).