-
Notifications
You must be signed in to change notification settings - Fork 410
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
adds gnark/profile
that outputs pprof compatible circuit profiling data
#352
Conversation
Suggested edit: diff --git a/profile/profile.go b/profile/profile.go
index 6ac2042e..3d3778d9 100644
--- a/profile/profile.go
+++ b/profile/profile.go
@@ -41,19 +41,22 @@ type Profile struct {
chDone chan struct{}
}
-// ProfilePath controls the profile destination file. If blank, profile is not written.
+// Option defines configuration Options for Profile.
+type Option func(*Profile)
+
+// WithPath controls the profile destination file. If blank, profile is not written.
//
// Defaults to ./gnark.pprof.
-func ProfilePath(path string) func(*Profile) {
+func WithPath(path string) Option {
return func(p *Profile) {
p.filePath = path
}
}
-// ProfileNoOutput indicates that the profile is not going to be written to disk.
+// WithNoOutput indicates that the profile is not going to be written to disk.
//
-// This is equivalent to ProfilePath("")
-func ProfileNoOutput() func(*Profile) {
+// This is equivalent to WithPath("")
+func WithNoOutput() Option {
return func(p *Profile) {
p.filePath = ""
}
@@ -65,7 +68,7 @@ func ProfileNoOutput() func(*Profile) {
// All calls to profile.Start() and Stop() are meant to be executed in the same go routine (frontend.Compile).
//
// It is allowed to create multiple overlapping profiling sessions in one circuit.
-func Start(options ...func(*Profile)) *Profile {
+func Start(options ...Option) *Profile {
// start the worker first time a profiling session starts.
onceInit.Do(func() {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Maybe only thing which mildly caught my eye was that for Plonk we don't record if the constraint comes from Add/Mul. But I guess that in the future when custom gates arrive we have to rethink anyway.
I also changed the profile option function signature to look similar with other Option types.
gnark/profile
is a profiling package, which createspprof
compatible profiling files. Once the.pprof
file is generated, one can visualize it usinggo tool pprof
like standard Golang CPU or Memory profiles.A gnark
Profile
measures constraint added in a circuit (for now, all constraints are equal, but we may differentiate them in the future), example output (fromexamples/rollup
):Usage:
This should make
api.Counter
andapi.Tag
useless.