Skip to content

OAK-12378: Avoid allocating a new Comparator on every PropertyTemplate.compareTo() call - #3095

Merged
nfsantos merged 1 commit into
apache:trunkfrom
nfsantos:OAK-12378
Aug 31, 2026
Merged

OAK-12378: Avoid allocating a new Comparator on every PropertyTemplate.compareTo() call#3095
nfsantos merged 1 commit into
apache:trunkfrom
nfsantos:OAK-12378

Conversation

@nfsantos

@nfsantos nfsantos commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Motivation

OAK-12378: PropertyTemplate.compareTo() builds a fresh Comparator chain (3 objects, via comparingInt() + two thenComparing() calls) on every invocation instead of reusing a single instance. This method runs O(n log n) times when sorting templates during node writes, and is especially hot during compaction.

A Java Flight Recorder analysis found this allocation site responsible for ~81% of sampled allocation weight (~705 GB of allocation pressure) — by far the largest source in the recording. During compaction on a 1.2 GB heap this contributed to significant GC stress: 77 old-generation collections consuming 41.2s within a 300s window (13.7%), plus 200 evacuation failures and 4 concurrent mode failures indicating heap exhaustion.

Summary

  • PropertyTemplate.compareTo() allocated a new Comparator chain on every call. Hoist it into a static final field so it's built once.

Test plan

  • No behavior change; existing PropertyTemplate tests cover compareTo().

@nfsantos
nfsantos merged commit c731214 into apache:trunk Aug 31, 2026
3 of 5 checks passed
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 this pull request may close these issues.

2 participants