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

Code cache allocation changes with Large pages enabled #1206

Closed
SajinaKandy opened this issue Nov 1, 2023 · 8 comments · Fixed by #1242
Closed

Code cache allocation changes with Large pages enabled #1206

SajinaKandy opened this issue Nov 1, 2023 · 8 comments · Fixed by #1242
Assignees

Comments

@SajinaKandy
Copy link

Issue or pull request number:
eclipse-openj9/openj9#18342

Overview:
Where Large page/huge page support is available, if the configured large page size is greater than the size of the total code cache size for JIT, then the page size used for code cache allocation will be selected from the next available lower page size available on the platform.

For e.x, if the large page size is configured as 1 GB and the total code cache size is not modified (using -Xcodecachetotal), then the next available page size value lower than 256MB (default code cache total size) will be used for code cache allocation.

Release target:
Eclipse OpenJ9 0.43

Applies to the following JDK versions:
8 and later

Applies to the following platforms:
All platforms

@SajinaKandy
Copy link
Author

@SajinaKandy
Copy link
Author

@Sreekala-Gopakumar Please let me know if further details are needed regarding this change.

@Sreekala-Gopakumar
Copy link
Contributor

@SajinaKandy - What was the issue because of which this change had to be made? What was happening before? Thanks!

@SajinaKandy
Copy link
Author

@Sreekala-Gopakumar
-Xcodecachetotal<size> is the total JIT code cache size. Assuming it's left to default values, 256 MB (for a 64-bit VM) and large page size of 1GB is enabled on the machine. Then,
Before this fix:
The code cache was allocated as 1 GB, as multiple of the available page size. Which is incorrect as the code cache should have been 256 MB.
After the fix:
If large pages are enabled, then the page size will be recalculated if the current page size is greater than the total code cache size. Ex in this case 1GB > 256 MB. Next available lower size page size will be used to allocate 256 MB for the codecache. Ex if there is 2MB page size available then the page size will be set to 2MB and this page size will be used to allocate the 256 MB for code cache.

@Sreekala-Gopakumar Sreekala-Gopakumar self-assigned this Jan 3, 2024
@Sreekala-Gopakumar
Copy link
Contributor

Sreekala-Gopakumar commented Jan 8, 2024

@Sreekala-Gopakumar -Xcodecachetotal<size> is the total JIT code cache size. Assuming it's left to default values, 256 MB (for a 64-bit VM) and large page size of 1GB is enabled on the machine. Then, Before this fix: The code cache was allocated as 1 GB, as multiple of the available page size. Which is incorrect as the code cache should have been 256 MB. After the fix: If large pages are enabled, then the page size will be recalculated if the current page size is greater than the total code cache size. Ex in this case 1GB > 256 MB. Next available lower size page size will be used to allocate 256 MB for the codecache. Ex if there is 2MB page size available then the page size will be set to 2MB and this page size will be used to allocate the 256 MB for code cache.

In this comment, when you say that "If large pages are enabled, then the page size will be recalculated if the current page size is greater than the total code cache size... Ex if there is 2MB page size available then the page size will be set to 2MB and this page size will be used to allocate the 256 MB for code cache." then:

  • What does "the page size will be set to 2MB" mean? Does the original large page size remain 1 GB or is that changed to 2 MB? If the original large page size is not changed then what is it used for, if not allocated for JIT code cache?
  • If the next available page size lower than the original large page size is 2 MB and that is used to allocate the 256 MB for code cache, then does that mean 128 pages (of 2 MB each) are allocated for the code cache?

Thanks!

@SajinaKandy
Copy link
Author

@Sreekala-Gopakumar

  1. Correct we do not change the large page size. We only change the page size used for allocating the Code cache. The code caches are aligned during allocation using the original large page size.
  2. To map 256 MB of memory, with 2MB page size, 128 pages will be needed. I would say that means your assumption with regards to code cache should be correct.
    @mpirvu do you think this is correct.

@Sreekala-Gopakumar
Copy link
Contributor

@Sreekala-Gopakumar

  1. Correct we do not change the large page size. We only change the page size used for allocating the Code cache. The code caches are aligned during allocation using the original large page size.
  2. To map 256 MB of memory, with 2MB page size, 128 pages will be needed. I would say that means your assumption with regards to code cache should be correct.
    @mpirvu do you think this is correct.

Thanks! What do you mean by "The code caches are aligned during allocation using the original large page size."?

Sreekala-Gopakumar added a commit to Sreekala-Gopakumar/openj9-docs that referenced this issue Jan 9, 2024
eclipse-openj9#1206

Updated the related topics with the information of the change in the large page memory allocation behavior.

Closes eclipse-openj9#1206
Signed-off-by: Sreekala Gopakumar <[email protected]>
@mpirvu
Copy link
Contributor

mpirvu commented Jan 9, 2024

Thanks! What do you mean by "The code caches are aligned during allocation using the original large page size."?

I think she meant that the allocation would be aligned on a 1GB boundary (assuming 1GB pages are available), but we may end-up using 2 MB or 4 KB pages.

Sreekala-Gopakumar added a commit to Sreekala-Gopakumar/openj9-docs that referenced this issue Jan 9, 2024
eclipse-openj9#1206

Updated the related topics with the information of the change in the large page memory allocation behavior.

Closes eclipse-openj9#1206
Signed-off-by: Sreekala Gopakumar <[email protected]>
Sreekala-Gopakumar added a commit to Sreekala-Gopakumar/openj9-docs that referenced this issue Jan 11, 2024
eclipse-openj9#1206

Updated the related topics with the information of the change in the large page memory allocation behavior. Incorporated the review feedback.

Closes eclipse-openj9#1206
Signed-off-by: Sreekala Gopakumar <[email protected]>
Sreekala-Gopakumar added a commit to Sreekala-Gopakumar/openj9-docs that referenced this issue Jan 18, 2024
eclipse-openj9#1206

Updated the related topics with the information of the change in the large page memory allocation behavior. Incorporated the review feedback.

Closes eclipse-openj9#1206
Signed-off-by: Sreekala Gopakumar <[email protected]>
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 a pull request may close this issue.

4 participants