Skip to content

4.x: Streamable Operator optimizations 7/18#8239

Merged
akarnokd merged 2 commits into
ReactiveX:4.xfrom
akarnokd:4xStreamableOptimizations0718
Jul 18, 2026
Merged

4.x: Streamable Operator optimizations 7/18#8239
akarnokd merged 2 commits into
ReactiveX:4.xfrom
akarnokd:4xStreamableOptimizations0718

Conversation

@akarnokd

Copy link
Copy Markdown
Member

Methodology

With help from Claude Fable, a new state machine has been implemented for several looping-consuming operators where it is by default synchronous bias and no need for a trampoline because there is only two phase of the async coordination: drain still running vs async completion running.

Plus more sources implement IndexableSource and EnumerableSource sometimes both because some chains may not work with indexable, such as map+filter+collect. Also if an operator is Indexable, it will be also enumerable.

Operators affected

  • collect
  • last, lastOrError
  • filter
  • just
  • empty

Scrabble status

https://github.com/akarnokd/akarnokd-misc/blob/master/src/jmh/java/hu/akarnokd/comparison/scrabble/ShakespearePlaysScrabbleWithRxJava4StreamableOpt.java

New measurements below the ~~~~~~~ markers.

Step Time (ms) Improvement vs Baseline
Baseline 42,512 - -
Avoid whenComplete usage in collect 37,566 -11,65% -
IndexableSource in collect 35,815 -4,66% -15,77%
concatIterable optimizations 31,971 -10,73% -24,81%
map fusions 30,623 -4,22% -27,98%
flattenAsFlowable deferred opt 27,999 -8,57% -34,15%
MutableLong in the bench 26,159 -6,57% -38,48%
lastOrError opt 25,164 -3,80% -40,82%
custom Collector summers 24,885 -1,11% -41,47%
skip optimizations 24,791 -0,38% -41,69%
~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~~
filter opt, filter+map fusion, lastOrError opt 23,566 -4,94% -44,58%
slow path collect optimization 22,392 -4,98% -47,34%
CharStreamer EnumerableSource marker 21,843 -2,45% -48,63%

@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

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

Changed files entropy:

src/jmh/java/io/reactivex/rxjava4/streamable/StreamableCollectPerf.java: 4.948
src/jmh/java/io/reactivex/rxjava4/streamable/StreamableFilterPerf.java: 4.713
src/jmh/java/io/reactivex/rxjava4/streamable/StreamableLastAsSinglePerf.java: 4.948
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableCollector.java: 4.042
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableEmpty.java: 4.805
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableFilter.java: 4.226
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJust.java: 4.670
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableLastAsSingle.java: 4.158
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableMap.java: 4.495
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRange.java: 4.574
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRangeLong.java: 4.535
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableCollectorTest.java: 4.787
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableConcatIterableTest.java: 4.395
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableEmptyTest.java: 4.828
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableFilterTest.java: 4.636
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJustTest.java: 4.852
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableLastAsSingleTest.java: 4.795
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableMapTest.java: 4.731
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRangeTest.java: 4.777

✅ No secrets or suspicious high-entropy strings found.

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

@github-actions

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

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

Changed files entropy:

src/jmh/java/io/reactivex/rxjava4/streamable/StreamableCollectPerf.java: 4.948
src/jmh/java/io/reactivex/rxjava4/streamable/StreamableFilterPerf.java: 4.713
src/jmh/java/io/reactivex/rxjava4/streamable/StreamableLastAsSinglePerf.java: 4.948
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableCollector.java: 4.042
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableEmpty.java: 4.805
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableFilter.java: 4.226
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJust.java: 4.670
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableLastAsSingle.java: 4.158
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableMap.java: 4.495
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRange.java: 4.574
src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRangeLong.java: 4.535
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableCollectorTest.java: 4.787
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableConcatIterableTest.java: 4.395
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableEmptyTest.java: 4.828
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableFilterTest.java: 4.636
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJustTest.java: 4.852
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableLastAsSingleTest.java: 4.795
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableMapTest.java: 4.731
src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableRangeTest.java: 4.777

✅ No secrets or suspicious high-entropy strings found.

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

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.03226% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.59%. Comparing base (8ed1fbc) to head (0712af6).

Files with missing lines Patch % Lines
...nternal/operators/streamable/StreamableFilter.java 89.02% 4 Missing and 5 partials ⚠️
...l/operators/streamable/StreamableLastAsSingle.java 81.48% 2 Missing and 3 partials ⚠️
...rnal/operators/streamable/StreamableCollector.java 88.00% 1 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (89.03%) 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    #8239      +/-   ##
============================================
- Coverage     98.63%   98.59%   -0.04%     
- Complexity     7152     7154       +2     
============================================
  Files           822      822              
  Lines         50543    50625      +82     
  Branches       6862     6879      +17     
============================================
+ Hits          49852    49914      +62     
- Misses          475      481       +6     
- Partials        216      230      +14     

☔ 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.

@akarnokd
akarnokd merged commit 258caeb into ReactiveX:4.x Jul 18, 2026
5 of 6 checks passed
@akarnokd
akarnokd deleted the 4xStreamableOptimizations0718 branch July 18, 2026 10:37
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