Skip to content

Conversation

@bitfaster
Copy link
Owner

[SkipLocalsInit] can be used to improve performance - https://github.com/dotnet/roslyn/blob/master/docs/features/skiplocalsinit.md

Runtime applies this attribute on all their assemblies for 5.0 - https://github.com/dotnet/runtime/search?q=SkipLocalsInit

@coveralls
Copy link

coveralls commented Oct 20, 2023

Coverage Status

coverage: 98.58% (+0.04%) from 98.537% when pulling 92530ca on users/alexpeck/skipinit into 5c2a527 on main.

@bitfaster
Copy link
Owner Author

bitfaster commented Oct 21, 2023

Summary:

  • Code size is smaller
  • ConcurrentDictionary was inexplicably fast for the SkipLocalsInit run below, hence ratio makes it look worse but Mean is better. This was the most comparable result I had for LFU.
  • Latency change was not that repeatable but does seem generally faster when running the benchmarks over and over.
  • Everything is a touch faster, biggest difference is for TLru and Atomic (likely they have more things on stack that are not zero'd).
  • Hard to get stable numbers for LFU (some runs have higher deviation). Does also seem to be a touch faster.

Before

Method Mean Error StdDev Ratio Code Size Allocated
ConcurrentDictionary 7.487 ns 0.0159 ns 0.0141 ns 1.00 1,523 B -
FastConcurrentLru 8.727 ns 0.0384 ns 0.0359 ns 1.16 7,312 B -
ConcurrentLru 14.836 ns 0.0186 ns 0.0156 ns 1.98 7,559 B -
AtomicFastLru 20.160 ns 0.0394 ns 0.0369 ns 2.69 NA -
FastConcurrentTLru 11.006 ns 0.0459 ns 0.0383 ns 1.47 7,725 B -
ConcurrentTLru 16.122 ns 0.0143 ns 0.0127 ns 2.15 7,989 B -
ConcurrentLfu 27.731 ns 0.9711 ns 2.8632 ns 4.11 NA -
ClassicLru 43.325 ns 0.0439 ns 0.0411 ns 5.79 NA -

After (with SkipLocalsInit)

Method Mean Error StdDev Ratio Code Size Allocated
ConcurrentDictionary 7.089 ns 0.0445 ns 0.0416 ns 1.00 1,523 B -
FastConcurrentLru 8.109 ns 0.0132 ns 0.0111 ns 1.14 7,235 B -
ConcurrentLru 14.598 ns 0.0154 ns 0.0136 ns 2.06 7,482 B -
AtomicFastLru 19.677 ns 0.0209 ns 0.0186 ns 2.77 NA -
FastConcurrentTLru 11.362 ns 0.0421 ns 0.0373 ns 1.60 6,394 B -
ConcurrentTLru 16.332 ns 0.0933 ns 0.0873 ns 2.30 7,912 B -
ConcurrentLfu 26.238 ns 0.5544 ns 0.9997 ns 3.72 NA -
ClassicLru 43.118 ns 0.0938 ns 0.0877 ns 6.08 NA -

@bitfaster bitfaster marked this pull request as ready for review October 21, 2023 21:30
@bitfaster bitfaster merged commit 551f7f5 into main Oct 21, 2023
@bitfaster bitfaster deleted the users/alexpeck/skipinit branch October 21, 2023 21:33
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.

3 participants