Skip to content

Conversation

jayantk
Copy link
Contributor

@jayantk jayantk commented Mar 11, 2025

Summary

I'm a little concerned that the big data structures in pulse are going to use a lot of gas, so here's a gas benchmark that we can use to measure. I refactored out some of the test utilities into a separate utils class so that I could reuse them in the gas benchmark. You run this benchmark per the existing instructions in the README.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

Copy link

vercel bot commented Mar 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2025 11:18am
component-library ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2025 11:18am
entropy-debugger ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2025 11:18am
insights ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2025 11:18am
proposals ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2025 11:18am
staking ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2025 11:18am

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

Please add the Utils file that you created before merging.

// Subtract this amount from the gas benchmarks to estimate the true usafe of the pulse flow.
function testDataMocking() public {
uint64 timestamp = SafeCast.toUint64(block.timestamp);
createPriceIds();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optimisations might ignore the memory cost of having this.

}

// Estimate how much gas is used by all of the data mocking functionality in the other gas benchmarks.
// Subtract this amount from the gas benchmarks to estimate the true usafe of the pulse flow.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo usafe -> usage

}
}

contract VoidPulseConsumer is IPulseConsumer {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add some documentation here for e.g. this consumer has an empty callback implementation to measure the baseline gas costs

uint64 timestamp = SafeCast.toUint64(block.timestamp);
bytes32[] memory priceIds = createPriceIds();

uint128 callbackGasLimit = 100000;
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we not using the same value used in PulseTestUtils.t.sol CALLBACK_GAS_LIMIT?

if no specific reason then maybe we can just use the constant declared there so as to standardize

Copy link
Contributor

Choose a reason for hiding this comment

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

should we also have more tests such as

  • testMaxPriceFeeds - tests the performance impact of processing maximum number of price feeds
  • testMultipleSequentialRequests - tests the performance impact of the request clearing and sequence number updates
  • testFailingCallback - tests the error handling path in the executeCallback function

@jayantk jayantk merged commit 74ca371 into main Mar 14, 2025
11 checks passed
@jayantk jayantk deleted the pulse_gas2 branch March 14, 2025 16:31
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