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

add code to debug resource leak - do not merge #2004

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
"ethers": "^6.6.0",
"hardhat-ignore-warnings": "^0.2.6",
"ten-hardhat-plugin": "^0.0.9"
},
"peerDependencies": {
"@nomicfoundation/hardhat-verify" : "2.0.8"
}
}
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