Skip to content
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

Implement issue #3892 Small performance increase obtainable by constructing regular expressions just once. #3893

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

paul-bayleaf
Copy link
Contributor

Make all std::regex definitions "static const" so that they are only constructed once.

Copy link
Contributor

@craigsapp craigsapp left a comment

Choose a reason for hiding this comment

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

The change should be good, but static variables are not necessarily faster if they have to be recalled from slower memory (L2/L3 compared to L1). Static variables can also affect thread performance.

Relative speeds to get to CPU:

memory clock cycles size
L1 3-5 16-64KB
L2 10-20 256kb-2MB
L3 30-50 4-64mb (shared between cores)
RAM 300-500 GB
SSD ~100,000 TB
HD ~10,000,000 TB

So if a variable takes <10 clock cycles to generate, it is not useful to store in L2; or <30 clock cycles if it is stored in L3.

@lpugin
Copy link
Contributor

lpugin commented Dec 16, 2024

Thanks!

@lpugin lpugin merged commit c681d41 into rism-digital:develop Dec 16, 2024
5 checks passed
@paul-bayleaf paul-bayleaf deleted the regex-performance branch December 16, 2024 19:51
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.

3 participants