Skip to content

Commit

Permalink
8320859: gtest high malloc footprint caused by BufferNodeAllocator st…
Browse files Browse the repository at this point in the history
…ress test

Reviewed-by: ayang, kbarrett
  • Loading branch information
tstuefe committed Nov 29, 2023
1 parent 033cced commit abf2e49
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,30 @@ class BufferNode::TestSupport::ProcessorThread : public JavaTestThread {
};

static void run_test(BufferNode::Allocator* allocator, CompletedList* cbl) {
const uint nthreads = 4;
const uint milliseconds_to_run = 1000;

// deallocation is slower than allocation, so lets create
// more deallocation threads to prevent too large buildup of
// free nodes (footprint)
constexpr uint num_allocator_threads = 4;
constexpr uint num_processor_threads = 6;
constexpr uint milliseconds_to_run = 1000;

Semaphore post;
volatile size_t total_allocations = 0;
volatile bool allocator_running = true;
volatile bool processor_running = true;

ProcessorThread* proc_threads[nthreads] = {};
for (uint i = 0; i < nthreads; ++i) {
ProcessorThread* proc_threads[num_processor_threads] = {};
for (uint i = 0; i < num_processor_threads; ++i) {
proc_threads[i] = new ProcessorThread(&post,
allocator,
cbl,
&processor_running);
proc_threads[i]->doit();
}

AllocatorThread* alloc_threads[nthreads] = {};
for (uint i = 0; i < nthreads; ++i) {
AllocatorThread* alloc_threads[num_allocator_threads] = {};
for (uint i = 0; i < num_allocator_threads; ++i) {
alloc_threads[i] = new AllocatorThread(&post,
allocator,
cbl,
Expand All @@ -219,12 +224,12 @@ static void run_test(BufferNode::Allocator* allocator, CompletedList* cbl) {
this_thread->sleep(milliseconds_to_run);
}
Atomic::release_store(&allocator_running, false);
for (uint i = 0; i < nthreads; ++i) {
for (uint i = 0; i < num_allocator_threads; ++i) {
ThreadInVMfromNative invm(this_thread);
post.wait_with_safepoint_check(this_thread);
}
Atomic::release_store(&processor_running, false);
for (uint i = 0; i < nthreads; ++i) {
for (uint i = 0; i < num_processor_threads; ++i) {
ThreadInVMfromNative invm(this_thread);
post.wait_with_safepoint_check(this_thread);
}
Expand All @@ -234,7 +239,7 @@ static void run_test(BufferNode::Allocator* allocator, CompletedList* cbl) {
}

TEST_VM(BufferNodeAllocatorTest, stress_free_list_allocator) {
const size_t buffer_capacity = 1024;
const size_t buffer_capacity = DEFAULT_CACHE_LINE_SIZE / sizeof(void*);
BufferNode::Allocator allocator("Test Allocator", buffer_capacity);
CompletedList completed;
run_test(&allocator, &completed);
Expand Down

5 comments on commit abf2e49

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on abf2e49 Nov 30, 2023

Choose a reason for hiding this comment

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

@tstuefe The target repository jdk21u-dev is not a valid target for backports.
List of valid target repositories: openjdk/jdk, openjdk/jdk11u, openjdk/jdk11u-dev, openjdk/jdk17u, openjdk/jdk17u-dev, openjdk/jdk19u, openjdk/jdk20u, openjdk/jdk21, openjdk/jdk21u, openjdk/jdk7u, openjdk/jdk8u, openjdk/jdk8u-dev, openjdk/jfx, openjdk/jfx20u, openjdk/jfx21u, openjdk/lilliput-jdk17u, openjdk/lilliput-jdk21u, openjdk/shenandoah-jdk21u, openjdk/shenandoah-jdk8u, openjdk/shenandoah-jdk8u-dev.
Supplying the organization/group prefix is optional.

@openjdk
Copy link

@openjdk openjdk bot commented on abf2e49 Nov 30, 2023

Choose a reason for hiding this comment

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

@tstuefe Could not automatically backport abf2e490 to openjdk/jdk17u-dev due to conflicts in the following files:

  • test/hotspot/gtest/gc/shared/test_ptrQueueBufferAllocator.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b tstuefe-backport-abf2e490

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git abf2e4909733550c228bd66ccebe33a492269e7f

# Backport the commit
$ git cherry-pick --no-commit abf2e4909733550c228bd66ccebe33a492269e7f
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport abf2e4909733550c228bd66ccebe33a492269e7f'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport abf2e4909733550c228bd66ccebe33a492269e7f.

Please sign in to comment.