Skip to content

Conversation

firewave
Copy link
Collaborator

@firewave firewave commented Nov 14, 2023

This regression was introduced in 8abab5c.

std::equal() is supposed to be faster than std::string::compare() and a benchmark even supports this: https://quick-bench.com/q/JkxxUMqC8wLufOw7AUI-l1K-n7Q. But somehow in our code it leads to a big performance regression when using the Clang compiler.

before

Benchmark 1: ./simplecpp -q -D__GNUC__ -D__x86_64__ -DHAVE_CONFIG_H -I ../../xrdp/build ../../xrdp/common/file.c
  Time (mean ± σ):     166.8 ms ±  29.3 ms    [User: 142.4 ms, System: 22.6 ms]
  Range (min … max):   131.9 ms … 218.9 ms    12 runs

after

Benchmark 1: ./simplecpp -q -D__GNUC__ -D__x86_64__ -DHAVE_CONFIG_H -I ../../xrdp/build ../../xrdp/common/file.c
  Time (mean ± σ):      11.5 ms ±   0.6 ms    [User: 9.0 ms, System: 2.6 ms]
  Range (min … max):    10.9 ms …  14.6 ms    216 runs

With GCC this also exists but is much less severe.

@firewave
Copy link
Collaborator Author

firewave commented May 6, 2024

Strangely I can no longer reproduce the issue.

@firewave
Copy link
Collaborator Author

Strangely I can no longer reproduce the issue.

The newly added callgrind step in the CI also shows that there is no regression with the change in question:

g++ - 75,902,589 -> 76,116,419
clang++ - 71,211,551 -> 71,311,304

@firewave firewave closed this Aug 29, 2025
@firewave firewave deleted the endswith branch August 29, 2025 15:27
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.

1 participant