-
Notifications
You must be signed in to change notification settings - Fork 379
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
Proposal (Gnovm / Gno test): Implement gno test -profile
#2222
Comments
i think it's good for long term |
Let's not reinvent the wheel and re-use Creating profiling formats and systems is hard. Creating the tooling to make sense of the profiling results is harder. Go developers are used to pprof, so it makes sense to reuse that, also because it already has a plethora of good visualization options. In the meantime, let's make this work only off-chain, as a debugging tool to see where the most VM cycles are being spent, most time allocated, etc. We can then have options to enable it on a node, although I see this as less urgent for the time being. In the implementation, try not to impact run-time performance too much and adding code on hot paths. There are some benchmarks in pkg/gnolang you can run to see performance in the gnovm, very broadly speaking. You can run them as follows:
Please compare the results with master using Please touch base regularly with what you're doing and get feedback early on any design decisions. Ping us on signal if we don't answer on GitHub. Make small PRs as much as possible, use stacking. (In spite of what the page says, you just need to make PRs that are based off the work of the previous ones, so instead of doing UX-wise, re-use what Go has as much as possible. Ie. cc @mvertes for an additional pair of eyes. You can proceed with drafting a technical outline of how this would work (ie. what needs to be added to the gnovm, what changes to do on the CLIs, etc. -- make a plan, this top-level comment does not clarify what you want to do yet.) |
Good profiling is so difficult to implement and so easy to get wrong, so yes, Morgan is right, it is absolutely necessary to consider at least the existing profiling infrastructure already provided by the Go tool chain, which is a top one, even despite issues as in go1.18 golang/go#52912, for example. Possible alternatives:
So let's consider now only the extension of existing Go pprof. To have, let's say, a CPU profiler at GnoVM level, here is what I would consider:
This has to be done while preserving the compatibility of data structures with the profiling analysis and visualisation systems (See pprof protocol definitions). Most of it also apply in big parts to memory profiling as well. Given the current maturity of the GnoVM, it's probably a bit early stage to consider this now. I would advise to wait for the GnoVM to be more stabilised. For example that capturing stack traces would cost a lot, due to the current architecture, as opposed for example to a regular byte code based virtual machine, which has a flatter memory representation. But anyway, this is certainly an interesting topic, and thank you for launching this discussion! |
I've pored over the comments a bunch of times, and tried to get all of it, so I will wait till I can control mostly things (like the eBPF and dtrace), have a deeper view on the GnoVM's architecture to propose something new. Thank you for sharing your though on this topic. It is really help me and others so much. |
This issue is stale because it has been open 6 months with no activity. Remove stale label or comment or this will be closed in 3 months. |
Introduction
This proposal outlines the implementation of a new flag,
-profile
, for the gno test command. This flag will enable developers to profile the execution of their code written in Gno, providing valuable insights into performance characteristics.Motivation
Optimizing smart contract performance is crucial for reducing gas costs and improving user experience. Currently, there's a lack of dedicated profiling tools within the Gno ecosystem. This proposal aims to introduce a built-in profiling functionality for gno test.
Proposed Approach
The gno test -profile flag will initiate profiling during gno file test execution. Here are two potential implementation strategies:
1. On-Chain Instrumentation:
During the Gno compilation process, inject profiling code into the smart contract bytecode.
This code will track metrics like function execution times and gas consumption during test execution on the blockchain.
After test completion, the profiling data will be retrieved and aggregated for analysis.
Due to its broader scope and potential impact on various aspects of the system, this implementation falls outside the boundaries of this proposal.
2. Off-Chain Instrumentation:
Leverage existing testing frameworks to capture performance data during test execution within the Gno environment.
This data could include:
that will be measured locally.
The profiling data will be stored and presented within the test results.
Technical Considerations:
Performance Overhead: The profiling process should have minimal impact on the actual execution time of the smart contract being tested.
Data Granularity: The level of detail exposed in the profiling data needs to balance usefulness with potential privacy concerns.
Success Criteria:
gno test -profile
flag successfully captures and presents profiling data during gno testing.Conclusion
The introduction of
gno test -profile
will empower Gno developers with a valuable tool for gno code performance analysis. This will contribute to the development of more efficient and cost-effective smart contract applications on the Gno platform.Question
Which indexes, informations should (and should not) be exposed during
gno test -profile
?We welcome comments and suggestions from the Gno community to make this proposal even stronger.
The text was updated successfully, but these errors were encountered: