He-Pin opened a new pull request, #2981:
URL: https://github.com/apache/pekko/pull/2981

   ## Motivation
   
   Optimize several stream stages by fusing separate InHandler/OutHandler 
objects into the GraphStageLogic itself, reducing per-materialization memory 
allocations.
   
   ## Modification
   
   This PR optimizes 6 stream stages by eliminating unnecessary handler object 
allocations:
   
   1. **DoOnFirst**: Replace separate `InHandler` with boolean `isFirst` flag 
pattern
   2. **Intersperse**: Merge two `InHandler` objects 
(`startInHandler`/`restInHandler`) into single fused handler using `started` 
flag
   3. **Reduce**: Eliminate initial `InHandler` by using `hasFirst` flag
   4. **DropWithin**: Replace post-timeout `InHandler` with `timedOut` flag to 
avoid `System.nanoTime()` call
   5. **Scan**: Remove initial `InHandler`/`OutHandler` pair using 
`initialized` flag
   6. **ScanAsync**: Remove `ZeroHandler` and post-completion `OutHandler` 
using `initialized` flag
   
   ## Result
   
   - Reduced memory allocation per materialization for these stages
   - All existing tests pass (51 tests total)
   - No behavioral changes
   
   ## Tests
   
   - `stream-tests/testOnly FlowDoOnFirstSpec`: 2/2 passed
   - `stream-tests/testOnly FlowIntersperseSpec`: 8/8 passed
   - `stream-tests/testOnly FlowReduceSpec`: 12/12 passed
   - `stream-tests/testOnly FlowDropWithinSpec`: 2/2 passed
   - `stream-tests/testOnly FlowScanSpec`: 8/8 passed
   - `stream-tests/testOnly FlowScanAsyncSpec`: 19/19 passed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to