Skip to content

Avoid expensive GC during edge accessor destruction while vertex locks are held#3441

Merged
DavIvek merged 6 commits intomasterfrom
avoid-gc-on-edge-accessor-while-holding-locks
Nov 19, 2025
Merged

Avoid expensive GC during edge accessor destruction while vertex locks are held#3441
DavIvek merged 6 commits intomasterfrom
avoid-gc-on-edge-accessor-while-holding-locks

Conversation

@DavIvek
Copy link
Contributor

@DavIvek DavIvek commented Nov 14, 2025

This PR addresses a performance bottleneck caused by skip list garbage collection (GC) occurring during edge accessor destruction while vertex locks are still held.
The skip list GC is not only expensive but also blocks other threads. This becomes critical under high concurrency, especially when queries create edges involving supernodes.

Here’s the scenario:

  • Multiple threads call CreateEdge concurrently.
  • One thread acquires unique locks on the vertices involved in the edge.
  • Inside the locked section, an edge accessor is created.
  • When the accessor goes out of scope, it may trigger skip list GC.
  • If GC runs while vertex locks are still held, all threads attempting related operations are blocked.

This leads to significant performance degradation when operating on supernodes.

@DavIvek
Copy link
Contributor Author

DavIvek commented Nov 14, 2025

Tracking

  • [Link to Epic/Issue]

Standard development

CI Testing Labels

  • Select the appropriate CI test labels (CI -build=build-name -test=test-suite)

Documentation checklist

  • Add the documentation label
  • Add the bug / feature label
  • Add the milestone for which this feature is intended
    • If not known, set for a later milestone
  • Write a release note, including added/changed clauses
    • Edge creation is refactored to ensure skip list GC doesn’t run while vertex locks are held. This results in better throughput and fewer stalls under heavy concurrency. No user action is required to benefit from the improved performance. #3421
  • [ Documentation PR link memgraph/documentation#XXXX ]
    • Is back linked to this development PR

@DavIvek DavIvek self-assigned this Nov 14, 2025
@DavIvek DavIvek added this to the mg-v3.8.0 milestone Nov 14, 2025
@DavIvek DavIvek added Docs - changelog only Docs - changelog only CI -build=release -test=e2e Run release build and e2e tests on push CI -build=debug -test=core Run debug build and core tests on push CI -build=release -test=core Run release build and core tests on push labels Nov 14, 2025
@DavIvek DavIvek marked this pull request as ready for review November 19, 2025 10:00
@sonarqubecloud
Copy link

@DavIvek DavIvek enabled auto-merge November 19, 2025 10:36
@DavIvek DavIvek added this pull request to the merge queue Nov 19, 2025
Merged via the queue into master with commit 1fc7250 Nov 19, 2025
33 checks passed
@DavIvek DavIvek deleted the avoid-gc-on-edge-accessor-while-holding-locks branch November 19, 2025 11:52
@gitbuda gitbuda modified the milestones: mg-v3.8.0, mg-v3.7.1 Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI -build=debug -test=core Run debug build and core tests on push CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push Docs - changelog only Docs - changelog only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants