Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
a20cc75b
Unverified
Commit
a20cc75b
authored
May 25, 2018
by
rjl493456442
Committed by
Péter Szilágyi
Jun 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth: cap cache allowance
parent
b659718f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
main.go
cmd/geth/main.go
+20
-0
No files found.
cmd/geth/main.go
View file @
a20cc75b
...
...
@@ -19,12 +19,16 @@ package main
import
(
"fmt"
"math"
"os"
"runtime"
godebug
"runtime/debug"
"sort"
"strconv"
"strings"
"time"
"github.com/elastic/gosigar"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
...
...
@@ -188,6 +192,22 @@ func init() {
if
err
:=
debug
.
Setup
(
ctx
);
err
!=
nil
{
return
err
}
// Cap the cache allowance and tune the garbage colelctor
var
mem
gosigar
.
Mem
if
err
:=
mem
.
Get
();
err
==
nil
{
allowance
:=
int
(
mem
.
Total
/
1024
/
1024
/
3
)
if
cache
:=
ctx
.
GlobalInt
(
utils
.
CacheFlag
.
Name
);
cache
>
allowance
{
log
.
Warn
(
"Sanitizing cache to Go's GC limits"
,
"provided"
,
cache
,
"updated"
,
allowance
)
ctx
.
GlobalSet
(
utils
.
CacheFlag
.
Name
,
strconv
.
Itoa
(
allowance
))
}
}
// Ensure Go's GC ignores the database cache for trigger percentage
cache
:=
ctx
.
GlobalInt
(
utils
.
CacheFlag
.
Name
)
gogc
:=
math
.
Max
(
20
,
math
.
Min
(
100
,
100
/
(
float64
(
cache
)
/
1024
)))
log
.
Debug
(
"Sanitizing Go's GC trigger"
,
"percent"
,
int
(
gogc
))
godebug
.
SetGCPercent
(
int
(
gogc
))
// Start system runtime metrics collection
go
metrics
.
CollectProcessMetrics
(
3
*
time
.
Second
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment