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(iroh-net): simplify stun::is check #1580

Merged
merged 3 commits into from
Oct 5, 2023
Merged

perf(iroh-net): simplify stun::is check #1580

merged 3 commits into from
Oct 5, 2023

Conversation

dignifiedquire
Copy link
Contributor

This is run on every packet, and showed up in some profiling as not being as cheap as it should be

This is run on every packet, and showed up in some profiling as not being as cheap as it should be
Comment on lines +69 to +70
// const MAGIC_COOKIE: Cookie = Cookie(0x2112_A442);
const COOKIE: [u8; 4] = 0x2112_A442u32.to_be_bytes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the need to copy the constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I can't get it out of the library as constant time

Comment on lines +514 to +516
fn test_stun_cookie() {
assert_eq!(stun_rs::MAGIC_COOKIE, COOKIE);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do this in compile time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the equality check/conversion is not constant time, so not sure how to do that

Copy link
Contributor

@divagant-martian divagant-martian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty I see now the wrapper type. LGTM

@dignifiedquire dignifiedquire added this pull request to the merge queue Oct 5, 2023
Merged via the queue into main with commit 0b28d15 Oct 5, 2023
15 checks passed
@b5 b5 added this to the v0.7.0 milestone Oct 10, 2023
@dignifiedquire dignifiedquire deleted the perf-stun-is branch November 1, 2023 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants