-
Notifications
You must be signed in to change notification settings - Fork 165
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
Conversation
This is run on every packet, and showed up in some profiling as not being as cheap as it should be
// const MAGIC_COOKIE: Cookie = Cookie(0x2112_A442); | ||
const COOKIE: [u8; 4] = 0x2112_A442u32.to_be_bytes(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
fn test_stun_cookie() { | ||
assert_eq!(stun_rs::MAGIC_COOKIE, COOKIE); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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
This is run on every packet, and showed up in some profiling as not being as cheap as it should be