-
Notifications
You must be signed in to change notification settings - Fork 18
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
Cadence Profiler #178
Comments
I really like this proposal. It will be super useful for understanding Cadence execution. |
Thank you for opening this proposal @m-Peter! We are currently in the process of publishing more developer grants for Cadence and related tooling, guided by importance and impact for the ecosystem, and are planning to get back to reviewing this proposal afterwards. Thank you for your patience |
Thanks for the heads up @turbolent 🙇 |
@franklywatson Since this onflow/flow-emulator#388 is gonna be solved soon, is there any positive sentiment from the Flow team for this grant to proceed? |
I'm definitely in support of this. It would be super useful for me and many others in the ecosystem! |
I just want to make sure this will also be able to estimate gas usage because that really is the metric that most developers care about because they need to know what to set their gas limit at |
@joshuahannan That makes total sense, I will experiment locally, how to calculate the gas for scripts & transactions 🙏 |
I think this computation tracking per statement is amazing feature too. If we can integrate with tools like code-coverage (like @m-Peter did before perfectly), it can make things a bit more predictable. |
Yes, the end goal would to be get general execution metadata, including things like line hits, computation and memory usage. So instead of just coverage report that we have under the Emulator endpoint ( |
This is awesome! I can't wait for this to get integrated into tools. |
Hey gang, hasn't been activity on this thread for over a year, wanted to check what the status on this was :) |
This was actually completed to a good degree. It's bundled in flow-emulator, and can be used for gathering computation reports for scripts & transactions. Since then I've been quite busy with the EVM Gateway, and Flow EVM, so I had no capacity to make tutorials and use it in certain projects 😅 |
cc @j1010001 and @onflow/flow-smart-contracts for potential follow-up work (e.g. tutorial on how to optimize Cadence code) |
This is an exciting feature! I'm wondering if you all have any thoughts about how to expose this in Flow CLI. For instance, it would be helpful to run a script or transaction and output a computation report (maybe behind a flag like |
@sisyphusSmiling That's a good idea, the computation reports are already available on an admin endpoint (http://localhost:8080/emulator/computationReport), where they are grouped by either script / transaction ID. We could also add some extra utility flags, for |
Legend! Going to close this one down :) |
Cadence Profiler for Smart Contracts / Scripts / Transactions
Grant category
Description
Cadence is the native programming language for developing smart contracts / scripts / transactions that run on the Flow Blockchain. The Flow Emulator displays profiling data in logs about scripts and transactions, including
computationUsed
andmemoryEstimate
(this one is currently being added by our team, onflow/flow-emulator#366). These logs, however, are not enough to drill down and get to the source of the bottleneck that is causing execution issues, due to high execution efforts.Hence, I would like to implement a Cadence Profiler, to enable Flow builders to build more robust smart contracts.
Problem statement
When designing smart contracts, one important concern is their performance and ability to scale. In some cases, after a period of time, the smart contract and some of its APIs, might become unwieldy due to their growth in computation & memory usage. This means that developers will not be able to run certain scripts / transactions, as they will reach the maximum execution limit. One such case can be seen here:
Proposed solution
Make use of the existing code that calculates the computation & memory used
and expose these metrics in a readable & accessible format to developers, through the Flow Emulator / Flow CLI.
Impact
Developers will be able to understand why scripts & transactions need a certain amount of computation & memory to run, and in turn they would be able to optimize their contracts.
Milestones and funding
ProfilingReport
ProfilingReport
including all scripts / transactionsProfilingReport
for contractsTotal Cost: 28,500 USD. Of course, I am open to discussion, regarding the cost and timeline 🙂 .
Team
The text was updated successfully, but these errors were encountered: