Skip to content

Conversation

@dichlofos
Copy link
Contributor

Watching perf tool shows large amount of strlen calls. The reason is in often default message construction that requires calculation of the constant string "OK" length.

Here we move this calculation on program start stage.

This prevents strlen() call on std::string ctor.
This prevents strlen() call on std::string ctor.
@dichlofos dichlofos requested review from a team as code owners December 6, 2024 17:46
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 6, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

@michael-myers michael-myers added ready for review Pull requests that are ready to be reviewed by a maintainer performance labels Dec 17, 2024
@michael-myers
Copy link
Contributor

The proposed change looks good to me. Out of curiosity, do you have a rough idea or example of how much this time this optimization saves?

@directionless directionless merged commit 6ac7ffb into osquery:master Dec 17, 2024
22 checks passed
@dichlofos
Copy link
Contributor Author

The proposed change looks good to me. Out of curiosity, do you have a rough idea or example of how much this time this optimization saves?

I recall numbers like 0.5% in perf table for strlen calls, and they often calculated "OK" length as I can see in registers, that's why I dig a bit there. And with help of std::string' SSO entire message construction will turn into 2-3 register-mem mov-s under -O2 opt.

I guess there exist much more interesting opts, but they require more thorough osq codebase learning :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance ready for review Pull requests that are ready to be reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants