Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce allocations #7570

Merged
merged 4 commits into from
Nov 29, 2022
Merged

reduce allocations #7570

merged 4 commits into from
Nov 29, 2022

Conversation

shawjef3
Copy link
Contributor

This reduces allocations by using a Stack instead of a List for ChannelExecutor's doneStack. I measured the difference by running ZStream.unit.forever.runDrain and profiling the same way I did at #7365.

benchmarks

before

[info] Benchmark                                   (chunkCount)  (chunkSize)   Mode  Cnt  Score    Error  Units
[info] StreamBenchmarks.zioChunkChunkFilterMapSum         10000         5000  thrpt   15  3.299 ±  0.026  ops/s
[info] StreamBenchmarks.zioChunkFilterMapSum              10000         5000  thrpt   15  2.466 ±  0.055  ops/s
[info] StreamBenchmarks.zioGroupAdjecentBy                10000         5000  thrpt   15  1.083 ±  0.003  ops/s
[info] StreamBenchmarks.zioGroupByKey                     10000         5000  thrpt   15  2.533 ±  0.021  ops/s
[info] StreamBenchmarks.zioGroupWithin                    10000         5000  thrpt   15  0.033 ±  0.001  ops/s
[info] StreamBenchmarks.zioMapAccum                       10000         5000  thrpt   15  2.227 ±  0.020  ops/s
[info] StreamBenchmarks.zioSliding                        10000         5000  thrpt   15  0.117 ±  0.001  ops/s
[info] StreamBenchmarks.zioTakeWhile                      10000         5000  thrpt   15  3.212 ±  0.013  ops/s

after

[info] Benchmark                                   (chunkCount)  (chunkSize)   Mode  Cnt  Score   Error  Units
[info] StreamBenchmarks.zioChunkChunkFilterMapSum         10000         5000  thrpt   15  3.323 ± 0.042  ops/s
[info] StreamBenchmarks.zioChunkFilterMapSum              10000         5000  thrpt   15  2.512 ± 0.012  ops/s
[info] StreamBenchmarks.zioGroupAdjecentBy                10000         5000  thrpt   15  1.073 ± 0.003  ops/s
[info] StreamBenchmarks.zioGroupByKey                     10000         5000  thrpt   15  2.453 ± 0.187  ops/s
[info] StreamBenchmarks.zioGroupWithin                    10000         5000  thrpt   15  0.032 ± 0.001  ops/s
[info] StreamBenchmarks.zioMapAccum                       10000         5000  thrpt   15  2.194 ± 0.012  ops/s
[info] StreamBenchmarks.zioSliding                        10000         5000  thrpt   15  0.108 ± 0.001  ops/s
[info] StreamBenchmarks.zioTakeWhile                      10000         5000  thrpt   15  3.748 ± 0.025  ops/s

allocations

before

forever before

after

Notice that the $colon$colon allocations disappear, and nothing takes their place.

forever after

@adamgfraser adamgfraser merged commit 17cf592 into zio:series/2.x Nov 29, 2022
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.

None yet

2 participants