Skip to content

[K/N] Recursive timing issue with GC Scheduler MutatorAssists when destroying millions of meta objects #5432

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

edisongz
Copy link
Contributor

@edisongz edisongz commented Apr 18, 2025

MoveAndAdvance moved objects were incorrectly counted as freed,
causing totalAllocatedBytes >= targetHeapBytes to persist longer than
necessary. This led to unnecessary GC recursion and degraded performance
in -Xallocator=std mode.

^KT-76851

@edisongz edisongz changed the title [K/N] Recursive timing issue with GC Scheduler MutatorAssists when destroy millions of meta objects [K/N] Recursive timing issue with GC Scheduler MutatorAssists when destroying millions of meta objects Apr 24, 2025
@projedi projedi self-requested a review May 9, 2025 09:25
@projedi
Copy link
Member

projedi commented May 12, 2025

@edisongz edisongz requested review from a team as code owners May 12, 2025 14:33
@dkhalanskyjb
Copy link
Contributor

Asking the whole JetBrains/kotlin for a review is a bit excessive.

@edisongz
Copy link
Contributor Author

edisongz commented May 12, 2025

Asking the whole JetBrains/kotlin for a review is a bit excessive.

So sorry for that, I just submitted a new commit, which automatically triggered a review request.
I have no right to edit reviewers, it's very embarrassing.

@SmialyKot
Copy link
Contributor

SmialyKot commented May 13, 2025

Hey, GitHub CODEOWNERS is a new addition for the project and we're still working out the kinks. The team JetBrains/kotlin was automatically selected for review since it's assigned to *Generated.java files - I will make sure to disable notifications for the review teams

EDIT: All review teams have notifications disabled. Anyone who receives unwanted notifications should verify "Watch" settings on the main page of the repository:
Screenshot 2025-05-14 at 09 23 46

`MoveAndAdvance` moved objects were incorrectly counted as freed,
causing `totalAllocatedBytes >= targetHeapBytes` to persist longer than
necessary. This led to unnecessary GC recursion and degraded performance
 in `-Xallocator=std` mode.

^KT-76851
@projedi
Copy link
Member

projedi commented Jul 7, 2025

@edisongz it seems, runtime tests are failing.

[tid#245982] gc/common/cpp/GCStatistics.cpp:222: runtime assert: Mismatch in statistics: marked 0 objects, while 2 are alive after sweep
0   linux_x64CmsGcTest.kexe             0x2d9167           _ZN12_GLOBAL__N_111PrintAssertEbPKcS1_P13__va_list_tag + 279
1   linux_x64CmsGcTest.kexe             0x2d902d           _ZN6kotlin8internal24RuntimeAssertFailedPanicEbPKcS2_z + 125
2   linux_x64CmsGcTest.kexe             0x2dd883           _ZN6kotlin2gc8GCHandle8finishedEv + 227
3   linux_x64CmsGcTest.kexe             0x2dbeab           _ZN6kotlin2gc8internal8GCThread13PerformFullGCEl + 347
4   linux_x64CmsGcTest.kexe             0x2db93a           _ZN6kotlin13UtilityThread3RunIZNS_2gc8internal8GCThreadC1ER13GCStateHolderRNS2_4mark14ConcurrentMarkERNS_5alloc9AllocatorERNS_11gcScheduler11GCSchedulerEE3$_0JEEENSt13invoke_resultIT_JDpT0_EE4typeEOSI_DpOSJ_ + 90
5   linux_x64CmsGcTest.kexe             0x2dba8d           _ZNSt6thread11_State_implINS_8_InvokerISt5tupleIJPFvN6kotlin12ScopedThread10attributesEOPFvOZNS3_2gc8internal8GCThreadC1ER13GCStateHolderRNS6_4mark14ConcurrentMarkERNS3_5alloc9AllocatorERNS3_11gcScheduler11GCSchedulerEE3$_0ESL_ES5_SN_SK_EEEEE6_M_runEv + 109
6   linux_x64CmsGcTest.kexe             0x3c506d           execute_native_thread_routine + 11
7   libpthread.so.0                     0x7f4b804cd608     0x0 + 139962251793928
8   libc.so.6                           0x7f4b803d7352     clone + 66

Can't tell which exact test is failing, but it looks like the entire suite crashing with an assertion triggered on a GC thread.

You can run all the runtime tests with ./gradlew :kotlin-native:runtime:hostRuntimeTests. Could you please take a look?

`MoveAndAdvance` moved objects were incorrectly counted as freed,
causing `totalAllocatedBytes >= targetHeapBytes` to persist longer than
necessary. This led to unnecessary GC recursion and degraded performance
 in `-Xallocator=std` mode.

^KT-76851
@edisongz
Copy link
Contributor Author

edisongz commented Jul 7, 2025

Can't tell which exact test is failing, but it looks like the entire suite crashing with an assertion triggered on a GC thread.

@projedi In std allocator mode, markedCount_ also needs to be accounted. objects to be finalized are kept alive also need record.
After adding the line sweepHandle.addMarkedObject();, all test cases have 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.

5 participants