Optimize putname function using out-of-bound while loop strlen()#111
Closed
GermanAizek wants to merge 1 commit intoyarrick:masterfrom
Closed
Optimize putname function using out-of-bound while loop strlen()#111GermanAizek wants to merge 1 commit intoyarrick:masterfrom
GermanAizek wants to merge 1 commit intoyarrick:masterfrom
Conversation
yarrick
requested changes
Apr 8, 2025
Owner
|
Please verify the test cases as part of sending the PR |
d0d5e1e to
899f529
Compare
My benchmarks here: yarrick#110
yarrick
requested changes
Apr 10, 2025
| p = *buf; | ||
|
|
||
| word = strtok(h, "."); | ||
| size_t len_word = strlen(word); |
Owner
There was a problem hiding this comment.
This mixes declarations and code which we try to avoid. Can you move it into the loop, then also only one call is needed?
Contributor
Author
There was a problem hiding this comment.
@yarrick, I forked at myself and did a make test and I couldn't do any micro-optimization by putting strlen variable out of loop, assert test errors everywhere.
| *p++ = (char)strlen(word); | ||
| memcpy(p, word, strlen(word)); | ||
| p += strlen(word); | ||
| len_word = strlen(word); |
Owner
|
As there was no updates here I did my own version in f12d2a5 |
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.
@yarrick,
I think it will be very useful, I decided to look for bottlenecks in DNS Tunnel Iodine, I haven't found a minor change yet.
So far, I've only found one minor optimization. In my case, optimization putname execution was reduced by almost 2 times.
My hardware: Lenovo RD450X with latest series E5 Xeon v4
My benchmarks here: #110