-
Notifications
You must be signed in to change notification settings - Fork 390
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
Fix/fix json stats report #5831
Conversation
methodStats ??= _currentStats.GetOrAdd(report.Method, _ => new MethodStats()); | ||
allTimeMethodStats ??= _allTimeStats.GetOrAdd(report.Method, _ => new MethodStats()); | ||
// we don't want to block RPC calls any longer than required | ||
return Task.Run(() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could just use
await Task.Yield();
To flip to the threadpool at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to have a lambda sub method in the method; can just use that and make method async rather than Task.Run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok but why would that be better? I don't have async code here (just sync code I want to fire&forget and do in the background), so introducing async code just to do Yield
seems odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with Luk here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so introducing async code just to do
Yield
seems odd.
You've already done all that though? So the additional code for the yield is actually less code: 0a821a3 (delta change) + removing the added indentation from Task.Run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so introducing async code just to do
Yield
seems odd.You've already done all that though? So the additional code for the yield is actually less code: 0a821a3 (delta change) + removing the added indentation from Task.Run
I introduced tasks, but no state machines, no reentrancy. await would be completely artificial.
methodStats ??= _currentStats.GetOrAdd(report.Method, _ => new MethodStats()); | ||
allTimeMethodStats ??= _allTimeStats.GetOrAdd(report.Method, _ => new MethodStats()); | ||
// we don't want to block RPC calls any longer than required | ||
return Task.Run(() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with Luk here
Changes
JsonRpcLocalStats.BuildReport
to avoid conflicts between threads_divider
to static variable, avoiding allocating it each time.StringBuilder
avoiding allocating it each time.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Testing in app logs