Skip to content

Commit

Permalink
Remove dependency on fjl/memsize library (Fantom-foundation#312)
Browse files Browse the repository at this point in the history
As of Go 1.23, memsize no longer works because of a restriction added by the Go toolchain. The Go 1.23 compiler no longer allows access to runtime symbols via go:linkname, which prevents memsize from accessing the Stop-the-World functionality of the Go runtime.

The only reason for this library use was a Pprof endpoint providing an information about the amount of memory consumed by the node.Node structure created on startup. The usability of the endpoint is questionable and its removal seems to be the simplest way of restoring compatibility with the latest Go toolchain.
  • Loading branch information
jmpike authored Nov 15, 2024
1 parent 18df2cb commit 787d1a1
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 10 deletions.
2 changes: 0 additions & 2 deletions cmd/sonicd/app/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ func lachesisMain(ctx *cli.Context) error {
// startNode boots up the system node and all registered protocols, after which
// it unlocks any requested accounts, and starts the RPC/IPC interfaces.
func startNode(ctx *cli.Context, stack *node.Node) error {
debug.Memsize.Add("node", stack)

// Start up the node itself
if err := stack.Start(); err != nil {
return fmt.Errorf("error starting protocol stack: %w", err)
Expand Down
4 changes: 0 additions & 4 deletions debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/exp"
"github.com/fjl/memsize/memsizeui"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"gopkg.in/urfave/cli.v1"
)

var Memsize memsizeui.Handler

var (
verbosityFlag = cli.IntFlag{
Name: "verbosity",
Expand Down Expand Up @@ -210,7 +207,6 @@ func StartPProf(address string, withMetrics bool) {
if withMetrics {
exp.Exp(metrics.DefaultRegistry)
}
http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize))
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
go func() {
if err := http.ListenAndServe(address, nil); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/docker/docker v27.3.1+incompatible
github.com/dvyukov/go-fuzz v0.0.0-20240924070022-e577bee5275c
github.com/ethereum/go-ethereum v1.14.8
github.com/fjl/memsize v0.0.2
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
github.com/golang/mock v1.6.0
github.com/hashicorp/golang-lru v1.0.2
Expand All @@ -31,6 +30,7 @@ require (
github.com/tyler-smith/go-bip39 v1.1.0
github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/uber/jaeger-lib v2.4.1+incompatible
go.uber.org/mock v0.4.0
golang.org/x/sys v0.25.0
gopkg.in/urfave/cli.v1 v1.20.0
)
Expand Down Expand Up @@ -117,7 +117,6 @@ require (
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/mock v0.4.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.29.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeV
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
Expand Down

0 comments on commit 787d1a1

Please sign in to comment.