Skip to content

Commit

Permalink
docs: gctuner get mem limit in container
Browse files Browse the repository at this point in the history
Signed-off-by: rfyiamcool <[email protected]>
  • Loading branch information
rfyiamcool committed Oct 8, 2023
1 parent 4091d24 commit 70cdb14
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions util/gctuner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ if threshold > 2*inuse, so gcPercent > 100, and GC negatively to reduce GC times
The recommended threshold is 70% of the memory limit.

```go

// Get mem limit from the host machine or cgroup file.
// Get mem limit from the host machine
limit := 4 * 1024 * 1024 * 1024
threshold := limit * 0.7

// Get mem limit from cgroup file.
memstr, err := os.ReadFile("/sys/fs/cgroup/memory/memory.limit_in_bytes")
if err != nil {
// ...
}
memLimit, err := strconv.ParseInt(string(memstr), 10, 64)
if err != nil {
// ...
}
threshold := memLimit * 0.7

gctuner.Tuning(threshold)
```

0 comments on commit 70cdb14

Please sign in to comment.