Skip to content

4.x: Streamable, improved range and collect internals + JMH#8235

Open
akarnokd wants to merge 1 commit into
ReactiveX:4.xfrom
akarnokd:4xStreamableOperatorOptimizationAttempt
Open

4.x: Streamable, improved range and collect internals + JMH#8235
akarnokd wants to merge 1 commit into
ReactiveX:4.xfrom
akarnokd:4xStreamableOperatorOptimizationAttempt

Conversation

@akarnokd

Copy link
Copy Markdown
Member

range improvement

By removing the double tracking and volatile, we are saving 100 cycles per item.

collect improvements

  1. avoid decrementing the wip counter on every next invocation, saving 50 cycles per item.
  2. checking if next returned a completed stage and extracting the value from it is faster than going through the whenComplete callback which allocates an otherwise unused stage for its return.
  3. introduce a synchronous indexer, IndexableSource that can access trivially available or computable elements via index.

These enhancements will be transplanted to similar operators to help synchronous islands perform better.

📓 At one point, it was considered to use a similar indexer access in Flowable and Observable operator fusion but benchmarks yielded equal performance with the existing optimizations within an error bar so it was not pursued further. Streamables reliance of the CompletionStage infrastructure is huge overload for basic synchronous sequences.

@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

Average entropy of changed code: 4.687 bits/char
Verdict: ✅ Mid-4 beauty detected (thoughtful human code!)

Changed files entropy:

build.gradle: 5.009
src/jmh/java/io/reactivex/rxjava4/streamable/StreamableCollectPerf.java: 4.954
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableCollector.java: 4.176
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableHelper.java: 4.413
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRange.java: 4.634
src/main/java/io/reactivex/rxjava4/operators/IndexableSource.java: 4.841
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableCollectorTest.java: 4.781

✅ No secrets or suspicious high-entropy strings found.

Mid-4 beauty heuristic in action — powered by our entropy chats! 😊

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.48780% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.71%. Comparing base (50e5f3e) to head (da49ecf).
⚠️ Report is 2 commits behind head on 4.x.

Files with missing lines Patch % Lines
...rnal/operators/streamable/StreamableCollector.java 80.00% 4 Missing and 2 partials ⚠️
...nternal/operators/streamable/StreamableHelper.java 66.66% 1 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (80.48%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##                4.x    #8235      +/-   ##
============================================
+ Coverage     98.69%   98.71%   +0.01%     
- Complexity     7146     7151       +5     
============================================
  Files           822      822              
  Lines         50375    50405      +30     
  Branches       6819     6825       +6     
============================================
+ Hits          49719    49755      +36     
+ Misses          457      450       -7     
- Partials        199      200       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant