-
Notifications
You must be signed in to change notification settings - Fork 258
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
Specialize empty key value pairs #576
Specialize empty key value pairs #576
Conversation
421a1aa
to
a814007
Compare
a814007
to
ba272f9
Compare
e05bce3
to
db16ec8
Compare
I have tested the effect on binary size of this PR on
Aside from the I also tested the binary sizes with the
The binary sizes are mostly the same as the previous one, with the exception of I also tested the runtime performance with a hand written benchmark:
You can find the benchmark code here: https://github.com/EFanZh/log/tree/benchmark. I give up using |
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.
Thanks for investigating this @EFanZh! I think we should remove the instantiate_log_function
item, but otherwise this looks good to me.
db16ec8
to
b462186
Compare
Hi @KodrAus, is there anything I need to do to get this PR merged? |
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.
Thanks for your patience on this one @EFanZh 🙇
This looks good to me.
Currently, the
__private_api::log
function takesNone::<&[(&str, _)]>
as thekvs
argument if no key-value pair is provided, but passing aNone
value may have some extra cost. We should be able to avoid this cost by encoding this information into a zero sized type (here I am using()
, not sure if it is better to use a dedicated new type (such asstruct EmptyKVs;
)). Constructing a zero sized value is zero cost, which is less than constructing aNone::<&[(&str, _)]>
.