-
Notifications
You must be signed in to change notification settings - Fork 282
feat(ccc): reuse a buffer for json encoding #744
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
Conversation
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.
LGTM. some benchmark of ApplyTransaction
(maybe in a dev machine) would be helpful to show to optimization result.
Profiles show that GC churn decreases, but can't really quantify the improvement since there are a lot going on. |
e43ab4c
@@ -65,13 +67,14 @@ func (ccc *CircuitCapacityChecker) ApplyTransaction(traces *types.BlockTrace) (* | |||
return nil, ErrUnknown | |||
} | |||
|
|||
tracesByt, err := json.Marshal(traces) | |||
ccc.jsonBuffer.Reset() |
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.
What if we encounter an exceptionally large trace, would we just keep the allocated buffer, even though we almost never fully utilize it?
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.
Yeah, that is the trade-off here. Such peaks of memory usage become sticky.
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.
After disabling stack, I think we won't have such large traces as before.
1. Purpose or design rationale of this PR
...
2. PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
3. Deployment tag versioning
Has the version in
params/version.go
been updated?4. Breaking change label
Does this PR have the
breaking-change
label?