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

GEODE-10323: Remove schedule threads in MemoryAllocatorImpl constructor #7715

Merged
merged 2 commits into from
Jun 22, 2022

Conversation

albertogpz
Copy link
Contributor

@albertogpz albertogpz commented May 20, 2022

The scheduled executor used in MemoryAllocatorImpl
was scheduled in the constructor. This provoked
intermittent failures in OffHeapStorageJUnitTest testCreateOffHeapStorage
test case due to a race condition.

The scheduling has been moved to a new method (start())
in the MemoryAllocatorImpl class that is in turn
invoked in the create() static method.

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

The scheduled executor used in MemoryAllocatorImpl
was scheduled in the constructor. This provoked
intermittent failures in OffHeapStorageJUnitTest testCreateOffHeapStorage
test cases due to a race condition.

The scheduling has been moved to a new method (start())
in the MemoryAllocatorImpl class that is in turn
invoked in the create() static method.
@albertogpz albertogpz force-pushed the feature/GEODE-10323 branch 2 times, most recently from 9f6c8a4 to a94f1d0 Compare May 24, 2022 17:31
@kirklund
Copy link
Contributor

kirklund commented Jun 3, 2022

I assigned https://issues.apache.org/jira/browse/GEODE-10323 to you since you're working on it. Thanks again!

@albertogpz albertogpz marked this pull request as ready for review June 6, 2022 06:48
@albertogpz albertogpz merged commit 8b85b2e into apache:develop Jun 22, 2022
OffHeapMemoryStats stats, int slabCount, long offHeapMemorySize, long maxSlabSize,
Slab[] slabs, SlabFactory slabFactory, int updateOffHeapStatsFrequencyMs) {
Slab[] slabs, SlabFactory slabFactory,
Supplier<Integer> updateOffHeapStatsFrequencyMsSupplier,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the update frequency "int" should be part of the NonRealTimeStatsUpdater and then you wouldn't need two suppliers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good idea but there is one test case in which you don't pass a Supplier so that the default NonRealTimeStatsUpdater is constructed but you need to specify a smaller frequency so that the test does not need to wait for the default frequency value:
See testUpdateNonRealTimeOffHeapStorageStats() from class OffHeapStorageNonRuntimeStatsJUnitTest.
For this test case I would need to specify the frequency but not the supplier.

}

void start() {
if (nonRealTimeStatsUpdater != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the constructor above it looks like you always initialize nonRealTimeStatsUpdaterSupplier to non-null. So what good are these null checks? Oh I see. Your supplier returns null. That works but I think it would be better to have the supplier returns a dummy NonRealTimeStatsUpdater that does nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. As I was too quick to merge the PR, should I open a new one?

albertogpz added a commit that referenced this pull request Sep 16, 2022
…or (#7715)

* GEODE-10323: Remove schedule threads in MemoryAllocatorImpl

The scheduled executor used in MemoryAllocatorImpl
was scheduled in the constructor. This provoked
intermittent failures in OffHeapStorageJUnitTest testCreateOffHeapStorage
test cases due to a race condition.

The scheduling has been moved to a new method (start())
in the MemoryAllocatorImpl class that is in turn
invoked in the create() static method.

* GEODE-10323: Extract update stats code to new class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants