Skip to content
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

Estimate the memory size of EIP-7702 transactions #7984

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

fab-10
Copy link
Contributor

@fab-10 fab-10 commented Dec 4, 2024

PR description

Estimate the memory size of EIP-7702 transactions and implement the detached copy of code delegation objects to avoid keeping references to big bytes arrays while the tx sits in the txpool

Fixed Issue(s)

fixes #7976

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

Copy link
Contributor

@ahamlat ahamlat left a comment

Choose a reason for hiding this comment

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

Small comments, but nothing really blocking.

@@ -489,6 +509,15 @@ private long sizeOfField(final Object container, final String... excludePaths) {
return size.sum();
}

@SuppressWarnings("unused")
private static void dumpHeap(final String filePath, final boolean live) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the method is not used, why do we need to have it ? with no comment, it looks like a dead code for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

documented how to use this utility

Copy link
Contributor

@ahamlat ahamlat Dec 11, 2024

Choose a reason for hiding this comment

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

Thanks for the detailed documentation, to access JMX mbeans, you need to have a java process running that exposes those Mbeans. I still don't see how can this work in a unit test. Could you give an example how can this work ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just put it wherever you need, no other setup needed

  @Test
  public void baseFrontierAndAccessListTransactionMemorySize() {
    final Transaction txFrontier =
        createTransaction(TransactionType.FRONTIER, 1, Wei.of(500), 0, KEYS1);
    try {
      dumpHeap("/tmp/heap.hprof", true);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    assertThat(baseTransactionMemorySize(txFrontier, FRONTIER_ACCESS_LIST_CONSTANT_FIELD_PATHS))
        .isEqualTo(FRONTIER_AND_ACCESS_LIST_SHALLOW_SIZE);
  }

Copy link
Contributor

@ahamlat ahamlat Dec 11, 2024

Choose a reason for hiding this comment

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

Interesting, I generated two heap dumps, one with live=true and one with lives=false. I think it makes sens to do the test with live=false, as it keeps even objects that will be garbage collected. I could find for the example above the transaction only when live=false

image

@fab-10 fab-10 force-pushed the estimate-memory-size-of-EIP7702-txs branch from d1b2314 to f164dc9 Compare December 10, 2024 17:49
@fab-10 fab-10 force-pushed the estimate-memory-size-of-EIP7702-txs branch from f164dc9 to 26ac71d Compare December 11, 2024 11:04
@fab-10 fab-10 enabled auto-merge (squash) December 11, 2024 11:04
@fab-10 fab-10 force-pushed the estimate-memory-size-of-EIP7702-txs branch from 26ac71d to 7c3955b Compare December 11, 2024 11:08
@fab-10 fab-10 merged commit ea04b25 into hyperledger:main Dec 11, 2024
43 checks passed
@fab-10 fab-10 deleted the estimate-memory-size-of-EIP7702-txs branch December 11, 2024 11:57
daniellehrner pushed a commit to daniellehrner/besu that referenced this pull request Dec 18, 2024
* Estimate the memory size of EIP-7702 transactions

Signed-off-by: Fabio Di Fabio <[email protected]>

* Apply suggestions from code review

Signed-off-by: Fabio Di Fabio <[email protected]>

---------

Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Daniel Lehrner <[email protected]>
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.

Add memory size estimation for EIP-7002 transaction
2 participants