Skip to content

Comments

Optimize putname function using out-of-bound while loop strlen()#111

Closed
GermanAizek wants to merge 1 commit intoyarrick:masterfrom
GermanAizek:optimize-putname-function-iodine-dns-tunnel
Closed

Optimize putname function using out-of-bound while loop strlen()#111
GermanAizek wants to merge 1 commit intoyarrick:masterfrom
GermanAizek:optimize-putname-function-iodine-dns-tunnel

Conversation

@GermanAizek
Copy link
Contributor

@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

@yarrick
Copy link
Owner

yarrick commented Apr 8, 2025

Please verify the test cases as part of sending the PR

@GermanAizek GermanAizek force-pushed the optimize-putname-function-iodine-dns-tunnel branch 8 times, most recently from d0d5e1e to 899f529 Compare April 8, 2025 21:49
p = *buf;

word = strtok(h, ".");
size_t len_word = strlen(word);
Copy link
Owner

Choose a reason for hiding this comment

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

This mixes declarations and code which we try to avoid. Can you move it into the loop, then also only one call is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@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);
Copy link
Owner

Choose a reason for hiding this comment

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

Is this call needed?

yarrick added a commit that referenced this pull request May 13, 2025
@yarrick
Copy link
Owner

yarrick commented May 13, 2025

As there was no updates here I did my own version in f12d2a5

@yarrick yarrick closed this May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants