Skip to content

Conversation

@cffls
Copy link
Contributor

@cffls cffls commented Jan 17, 2025

Description

Use sync.Pool in Keccak hash operations to reduce memory allocations and GC pressure.

Performance impact:

  • Reduced GC pressure: scanobject decreased from 20.43% to 2.59%
  • Improved memory management: mallocgc reduced to 1.52% (7.38% cumulative)
  • More efficient state operations with less GC overhead
  • Transaction processing shows improved efficiency with less GC interference

While the core Keccak hash computation (keccakF1600) still takes 11.75% CPU time, the overall system performance has improved due to reduced memory allocation overhead and better GC characteristics.

pprof before
Screenshot 2025-01-17 at 11 54 16 AM

pprof after
Screenshot 2025-01-17 at 11 55 10 AM

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply
  • Created a task in Jira and informed the team for implementation in Erigon client (if applicable)
  • Includes RPC methods changes, and the Notion documentation has been updated

Cross repository changes

  • This PR requires changes to heimdall
    • In case link the PR here:
  • This PR requires changes to matic-cli
    • In case link the PR here:

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on mumbai/amoy
  • I have created new e2e tests into express-cli

@cffls cffls requested a review from a team January 17, 2025 19:58
@cffls cffls changed the title Use pool for keccak state Use sync.Pool for keccak state Jan 17, 2025
Copy link
Member

@pratikspatil024 pratikspatil024 left a comment

Choose a reason for hiding this comment

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

Noice!

@cffls cffls merged commit a153663 into 0xPolygon:develop Jan 21, 2025
10 checks passed
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 this pull request may close these issues.

3 participants