Skip to content

Commit

Permalink
DVT-1057 replace block data structure with LRU cache to fix memory le…
Browse files Browse the repository at this point in the history
…ak (#158)

* Revert "Revert "DVT-1057 replace block data structure with LRU cache to fix memory leak (#148)""

This reverts commit f174e63.

* DVT-1057 replace block data structure with LRU cache to fix memory leak
  • Loading branch information
gatsbyz authored Nov 14, 2023
1 parent a49e238 commit 4f69f6e
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 206 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ You can then generate some load to make sure that blocks with transactions are b
$ polycli loadtest --verbosity 700 --chain-id 1337 --concurrency 1 --requests 1000 --rate-limit 5 --mode c --rpc-url http://127.0.0.1:8545
```

## Monitor Debug
`polycli monitor --rpc-url http://34.117.145.249:80 -v 700 &> log.txt`

# Contributing

- If you add a new loadtest mode, don't forget to update the loadtest mode string by running the following command: `cd cmd/loadtest && stringer -type=loadTestMode`. You can install [stringer](https://pkg.go.dev/golang.org/x/tools/cmd/stringer) with `go install golang.org/x/tools/cmd/stringer@latest`.
Expand Down
13 changes: 10 additions & 3 deletions cmd/monitor/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ var (
usage string

// flags
rpcUrl string
batchSizeValue string
intervalStr string
rpcUrl string
batchSizeValue string
blockCacheLimit int
intervalStr string
)

// MonitorCmd represents the monitor command
Expand All @@ -44,6 +45,7 @@ var MonitorCmd = &cobra.Command{
func init() {
MonitorCmd.PersistentFlags().StringVarP(&rpcUrl, "rpc-url", "r", "http://localhost:8545", "The RPC endpoint url")
MonitorCmd.PersistentFlags().StringVarP(&batchSizeValue, "batch-size", "b", "auto", "Number of requests per batch")
MonitorCmd.PersistentFlags().IntVarP(&blockCacheLimit, "cache-limit", "c", 100, "Number of cached blocks for the LRU block data structure (Min 100)")
MonitorCmd.PersistentFlags().StringVarP(&intervalStr, "interval", "i", "5s", "Amount of time between batch block rpc calls")
}

Expand Down Expand Up @@ -73,5 +75,10 @@ func checkFlags() (err error) {
}
}

// Check batch-size flag.
if blockCacheLimit < 100 {
return fmt.Errorf("block-cache can't be less than 100")
}

return nil
}
Loading

0 comments on commit 4f69f6e

Please sign in to comment.