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

RedisGrainStorage.ReadStateAsync() should use Array.Length instead of Linq.Enumerable.Count() #20

Closed
f-i-x-7 opened this issue Oct 28, 2021 · 0 comments · Fixed by #24
Closed

Comments

@f-i-x-7
Copy link
Contributor

f-i-x-7 commented Oct 28, 2021

There is a possibility for micro perf improvement by replacing this line:

to this:

if (hashEntries.Length == 2)

hashEntries is an array, so this is technically possible, and it should benefit by eliminating virtual call to ICollection<T>.Count that is called by Linq.Enumerable.Count() under the hood (in theory it is possible that due to several inlines made by JIT a possibility for guarded devirtualization can occur, but I think it is better to reduce JIT work anyway and just access Length directly).

This is very simple change, so if you are interested in it, I could submit a PR.

f-i-x-7 added a commit to f-i-x-7/Orleans.Redis that referenced this issue Jan 11, 2022
ReubenBond added a commit that referenced this issue Jan 13, 2022
* Replaced .Count() by .Length (#20)

* Update RedisGrainStorage.cs

Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com>
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 a pull request may close this issue.

1 participant