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

WIP - do not merge - 0.26 leak detection #2031

Closed
wants to merge 7 commits into from
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion go/enclave/main/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package main

import (
"fmt"

Check failure on line 4 in go/enclave/main/main.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed (goimports)

"github.com/ten-protocol/go-ten/go/common/container"
tenflag "github.com/ten-protocol/go-ten/go/common/flag"
"github.com/ten-protocol/go-ten/go/config"
enclavecontainer "github.com/ten-protocol/go-ten/go/enclave/container"
"os"
"runtime/pprof"
"time"
)

// Runs an Obscuro enclave as a standalone process.
Expand All @@ -25,6 +27,29 @@
panic(fmt.Errorf("unable to create config from flags - %w", err))
}

// temporary code to help identify OOM
go func() {
for {
heap, err := os.Create(fmt.Sprintf("/data/heap_%d.pprof", time.Now().UnixMilli()))
if err != nil {
panic(fmt.Errorf("could not open heap profile: %w", err))
}
err = pprof.WriteHeapProfile(heap)
if err != nil {
panic(fmt.Errorf("could not write CPU profile: %w", err))
}
stack, err := os.Create(fmt.Sprintf("/data/stack_%d.pprof", time.Now().UnixMilli()))
if err != nil {
panic(fmt.Errorf("could not open stack profile: %w", err))
}
err = pprof.Lookup("goroutine").WriteTo(stack, 1)
if err != nil {
panic(fmt.Errorf("could not write CPU profile: %w", err))
}
time.Sleep(1 * time.Hour)
}
}()

enclaveContainer := enclavecontainer.NewEnclaveContainerFromConfig(enclaveConfig)
container.Serve(enclaveContainer)
}
Loading