Skip to content

Avoid division operation using _sizeCalssRatioLog - #7918

Merged
babsingh merged 1 commit into
eclipse-omr:masterfrom
dmitripivkine:master
Sep 3, 2025
Merged

Avoid division operation using _sizeCalssRatioLog#7918
babsingh merged 1 commit into
eclipse-omr:masterfrom
dmitripivkine:master

Conversation

@dmitripivkine

Copy link
Copy Markdown
Contributor

_sizeCalssRatioLog is used to calculate log value for desired base: _sizeCalssRatioLog = logf(base);
log_base_for_value = logf(value) / _sizeCalssRatioLog. Division operation can be expensive so code can be optimized by using multiplication operation instead of division. Also I renamed precalculated variable name to _sizeCalssRatioLogInversed to reflect this change:
_sizeCalssRatioLogInversed = 1.0f / logf(base);
log_base_for_value = logf(value) / _sizeCalssRatioLogInversed.

_sizeCalssRatioLog is used to calculate log value for desired base:
_sizeCalssRatioLog = logf(base);
log_base_for_value = logf(value) / _sizeCalssRatioLog.
Division operation can be expensive so code can be optimized by using
multiplication operation instead of division. Also I renamed
precalculated variable name to _sizeCalssRatioLogInversed to reflect
this change:
 _sizeCalssRatioLogInversed = 1.0f / logf(base);
 log_base_for_value = logf(value) / _sizeCalssRatioLogInversed.

Signed-off-by: Dmitri Pivkine <Dmitri_Pivkine@ca.ibm.com>
@@ -238,7 +238,7 @@ class MM_LargeObjectAllocateStats : public MM_Base {
_largeObjectThreshold(0),
_veryLargeEntrySizeClass(0),
_sizeClassRatio(0.0),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can also change this to 0.0f for style consistency

@amicic amicic added the comp:gc label Sep 2, 2025
@amicic

amicic commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

@babsingh please review/merge

@babsingh

babsingh commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

jenkins build all

@babsingh
babsingh merged commit 761c780 into eclipse-omr:master Sep 3, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants