Skip to content

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

Merged
merged 2 commits into from
May 10, 2024

Conversation

omerfirmak
Copy link

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:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

@omerfirmak omerfirmak requested review from georgehao and colinlyguo May 9, 2024 09:02
Copy link
Member

@colinlyguo colinlyguo left a 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.

@omerfirmak
Copy link
Author

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.

georgehao
georgehao previously approved these changes May 9, 2024
0xmountaintop
0xmountaintop previously approved these changes May 9, 2024
@github-actions github-actions bot dismissed stale reviews from 0xmountaintop and georgehao via e43ab4c May 9, 2024 09:45
@omerfirmak omerfirmak merged commit 5d0d197 into develop May 10, 2024
@omerfirmak omerfirmak deleted the omerfirmak/ccc-buffer branch May 10, 2024 11:47
@@ -65,13 +67,14 @@ func (ccc *CircuitCapacityChecker) ApplyTransaction(traces *types.BlockTrace) (*
return nil, ErrUnknown
}

tracesByt, err := json.Marshal(traces)
ccc.jsonBuffer.Reset()

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?

Copy link
Author

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants