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 #7568

Merged
merged 2 commits into from
Nov 27, 2022
Merged

Reduce allocations #7568

merged 2 commits into from
Nov 27, 2022

Conversation

shawjef3
Copy link
Contributor

@shawjef3 shawjef3 commented Nov 27, 2022

This reduces allocations due to not boxing every Long in ZScheduler#submittedLocations. I measured the difference by running ZIO.unit.forever and profiling the same way I did at #7365.

benchmarks

before

[info] Benchmark                                            Mode  Cnt     Score    Error  Units
[info] ZSchedulerBenchmarks.catsRuntimeChainedFork         thrpt   15  6207.667 ± 65.372  ops/s
[info] ZSchedulerBenchmarks.catsRuntimeForkMany            thrpt   15   670.941 ±  9.549  ops/s
[info] ZSchedulerBenchmarks.catsRuntimePingPong            thrpt   15   986.860 ± 31.994  ops/s
[info] ZSchedulerBenchmarks.catsRuntimeYieldMany           thrpt   15   855.601 ± 18.382  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolChainedFork  thrpt   15  2735.637 ± 34.485  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolForkMany     thrpt   15   389.630 ±  3.819  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolPingPong     thrpt   15   784.109 ±  6.717  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolYieldMany    thrpt   15    14.408 ±  0.143  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerChainedFork        thrpt   15  2609.220 ±  8.991  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerForkMany           thrpt   15   444.072 ±  3.386  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerPingPong           thrpt   15  1886.767 ±  8.340  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerYieldMany          thrpt   15    67.884 ±  0.189  ops/s

after

[info] Benchmark                                            Mode  Cnt     Score    Error  Units
[info] ZSchedulerBenchmarks.catsRuntimeChainedFork         thrpt   15  6266.270 ±  5.935  ops/s
[info] ZSchedulerBenchmarks.catsRuntimeForkMany            thrpt   15   664.790 ±  1.493  ops/s
[info] ZSchedulerBenchmarks.catsRuntimePingPong            thrpt   15   936.911 ±  9.402  ops/s
[info] ZSchedulerBenchmarks.catsRuntimeYieldMany           thrpt   15   725.193 ±  2.423  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolChainedFork  thrpt   15  2806.162 ±  6.056  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolForkMany     thrpt   15   417.146 ±  1.950  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolPingPong     thrpt   15   715.587 ±  3.365  ops/s
[info] ZSchedulerBenchmarks.zioFixedThreadPoolYieldMany    thrpt   15    14.125 ±  0.080  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerChainedFork        thrpt   15  2917.393 ±  6.393  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerForkMany           thrpt   15   445.130 ±  6.354  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerPingPong           thrpt   15  1863.503 ± 13.140  ops/s
[info] ZSchedulerBenchmarks.zioSchedulerYieldMany          thrpt   15    71.960 ±  0.133  ops/s

allocations

before

before

after

Notice that there are many fewer java.lang.Long allocations.

after2

Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙏

@shawjef3
Copy link
Contributor Author

@adamgfraser you're welcome. It says it's ready to merge, but I'm unable to click the button myself.

@adamgfraser adamgfraser merged commit 70f3da1 into zio:series/2.x Nov 27, 2022
@shawjef3 shawjef3 deleted the reduce-allocations branch November 27, 2022 13:50
jdegoes pushed a commit that referenced this pull request Dec 2, 2022
* Revert "Reduce allocations (#7568)"

This reverts commit 70f3da1.

* clean up scheduler changes
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