Repository navigation
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR optimizes element byte size observation on hot paths by adding a primitive update(long) overload to ElementByteSizeObserver, replacing java.util.Observable's synchronized Vector in ElementByteSizeObservableIterator with an unsynchronized single-observer fast path, and lazily allocating the observer list in ElementByteSizeObservableIterable. The changes are clean, preserve Observable's behavioral contract (including reverse notification order and deduplication), and are well-covered by unit tests and JMH benchmarks.
🔍 General Feedback
- The single-observer fast path in
ElementByteSizeObservableIteratorandElementByteSizeObserverextension inIterableLikeCoder.IteratorObservereffectively eliminateLongautoboxing and synchronization overhead during iteration. - Edge cases for
Observablemethods (addObserver,deleteObserver,notifyObservers,changedflag semantics) are thoroughly tested inElementByteSizeObservableIteratorTest.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @ahmedabu98 for label java. This pull request likely touches a core component ("core" label). Please review with scrutiny. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41537 +/- ##
=========================================
Coverage 58.66% 58.66%
Complexity 2292 2292
=========================================
Files 1134 1134
Lines 170223 170223
Branches 1487 1487
=========================================
Hits 99856 99856
Misses 67826 67826
Partials 2541 2541 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…teSizeObserver - ElementByteSizeObserver: add primitive update(long) overload to avoid Long boxing. - ElementByteSizeObservableIterator: replace java.util.Observable's synchronized Vector with an unsynchronized single-observer fast path (plus lazy ArrayList overflow) and dispatch directly to ElementByteSizeObserver.update(long). - ElementByteSizeObservableIterable: lazily allocate observer list. - IterableLikeCoder: avoid per-element Long boxing when observing element sizes. - Add ElementByteSizeObservableIteratorTest and ElementByteSizeObservableBenchmark. comments comments
9f3e794 to
0fe6864
Compare
Eliminate synchronized Observable/Vector and Long boxing in ElementByteSizeObserver
for primitive update(long) dispatch via primary supertype checks (avoiding JDK-8180450).
fast path (exact long arithmetic when scalingFactor == 1.0), and remove class-level
nullness suppression.
with an unsynchronized single-observer fast path plus immutable copy-on-write Observer[]
snapshots, dispatching directly to ElementByteSizeObserver / PrimitiveByteSizeObserver
and using exact Observer[].class checks.
Observer / deduplicated Observer[] storage.
per-element overhead while preserving Observable forwarding on legacy update(Observable, Object).
benchmarks + smoke tests (ElementByteSizeObservableBenchmark[Test]).