Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

More MemoryCache perf improvements#45280

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@adamsitnik
Copy link
Member

@adamsitnikadamsitnik commentedNov 27, 2020
edited
Loading

don't acces expensive CacheEntryHelper.Current if options can't be propagated anyway

CacheEntryHelper.Current uses expensiveAsyncLocal. Before accessing it, we can just check if the options can be propagated and don't use it at all if not.

obraz

+7.5% (+18k) RPS for TechEmpower benchmark!

loadbeforeafter
CPU Usage (%)1921
Cores usage (%)528574
Working Set (MB)4848
Build Time (ms)4,5004,541
Start Time (ms)00
Published Size (KB)76,40176,401
.NET Core SDK Version3.1.4043.1.404
First Request (ms)7678
Requests/sec234,029252,468
Requests3,533,6463,812,090
Mean latency (ms)1.281.18
Max latency (ms)61.3047.33
Bad responses00
Socket errors00
Read throughput (MB/s)736.49794.52
Latency 50th (ms)1.060.99
Latency 75th (ms)1.171.09
Latency 90th (ms)1.331.23
Latency 99th (ms)10.089.10

inline the expiration check hot paths

obraz

loadbeforeafter
CPU Usage (%)2121
Cores usage (%)574580
Working Set (MB)4848
Build Time (ms)4,5414,923
Start Time (ms)00
Published Size (KB)76,40176,401
.NET Core SDK Version3.1.4043.1.404
First Request (ms)7879
Requests/sec252,468259,239
Requests3,812,0903,914,333
Mean latency (ms)1.181.15
Max latency (ms)47.3348.63
Bad responses00
Socket errors00
Read throughput (MB/s)794.52815.83
Latency 50th (ms)0.990.96
Latency 75th (ms)1.091.07
Latency 90th (ms)1.231.19
Latency 99th (ms)9.109.03

iSazonov, tuananh, and AndreyAkinshin reacted with thumbs up emoji
…opagated anyway, +20k RPS for TechEmpower benchmark!
@ghost
Copy link

Tagging subscribers to this area:@eerhardt,@maryamariyan
See info in area-owners.md if you want to be subscribed.

Issue Details

CacheEntryHelper.Current uses expensiveAsyncLocal. Before accessing it, we can just check if the options can be propagated and don't use it at all if not.

obraz

+7.5% (+18k) RPS for TechEmpower benchmark!

loadbeforeafter
CPU Usage (%)1921
Cores usage (%)528574
Working Set (MB)4848
Build Time (ms)4,5004,541
Start Time (ms)00
Published Size (KB)76,40176,401
.NET Core SDK Version3.1.4043.1.404
First Request (ms)7678
Requests/sec234,029252,468
Requests3,533,6463,812,090
Mean latency (ms)1.281.18
Max latency (ms)61.3047.33
Bad responses00
Socket errors00
Read throughput (MB/s)736.49794.52
Latency 50th (ms)1.060.99
Latency 75th (ms)1.171.09
Latency 90th (ms)1.331.23
Latency 99th (ms)10.089.10
Author:adamsitnik
Assignees:-
Labels:

area-Extensions-Caching,tenet-performance

Milestone:6.0.0

@adamsitnikadamsitnik changed the titledon't acces expensive CacheEntryHelper.Current if options can't be propagated anywayMore MemoryCache perf improvementsNov 27, 2020

internalboolCheckExpired(DateTimeOffsetnow)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internalboolCheckExpired(inDateTimeOffsetnow)
Copy link
Member

Choose a reason for hiding this comment

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

How much does the ‘in’ help here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I just wanted to be 100% sure that this struct is not being copied on Linux.

Copy link
Member

Choose a reason for hiding this comment

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

I just wanted to be 100% sure that this struct is not being copied on Linux.

Did this one change make any measurable impact? We should not be sprinkling lots ofins everywhere unless they're actually meaningful.

pentp reacted with thumbs up emoji

if(_slidingExpiration.HasValue
&&(now-LastAccessed)>=_slidingExpiration)
returnSlowPath(now);
Copy link
Member

Choose a reason for hiding this comment

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

Is the idea here that the above check can get inlined, and then the “SlowPath” code remains a normal method call? Is there a good guidance on when this pattern should be used?

Side nit - is “SlowPath” a good name for this method?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Is the idea here that the above check can get inlined, and then the “SlowPath” code remains a normal method call?

Yes, exactly.

Is there a good guidance on when this pattern should be used?

I would say that it should be used when the condtion typically returns false and rarely executes the code inside it (like throwing exceptions) and is ofc on a hot path (small helper methods executed frequently)

Copy link
Member

@eerhardteerhardt left a comment

Choose a reason for hiding this comment

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

This LGTM. Nice work here@adamsitnik! Looks like a good perf win.

cc@Tratcher

_notifyCacheEntryCommit(this);
PropagateOptions(CacheEntryHelper.Current);

if(CanPropagateOptions())
Copy link
Member

Choose a reason for hiding this comment

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

Always leave a comment about why you're doing what appears to be a redundant check.

@adamsitnikadamsitnik merged commita2f81e7 intodotnet:masterDec 1, 2020
@adamsitnikadamsitnik deleted the anotherMemoryCachePerfImprovement branchDecember 1, 2020 05:57
}

privateboolCheckForExpiredTime(DateTimeOffsetnow)
privateboolCheckForExpiredTime(inDateTimeOffsetnow)
Copy link
Member

Choose a reason for hiding this comment

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

Same question.

@ghostghost locked asresolvedand limited conversation to collaboratorsDec 31, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@stephentoubstephentoubstephentoub left review comments

@TratcherTratcherTratcher approved these changes

@eerhardteerhardteerhardt approved these changes

@maryamariyanmaryamariyanAwaiting requested review from maryamariyan

+1 more reviewer

@jnyrupjnyrupjnyrup left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

Projects

None yet

Milestone

6.0.0

Development

Successfully merging this pull request may close these issues.

5 participants

@adamsitnik@jnyrup@Tratcher@stephentoub@eerhardt

[8]ページ先頭

©2009-2025 Movatter.jp