mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 00:33:57 +00:00
Reduce GOGC to 50
The index used by restic consumes a major part of the total memory usage. This leads to an unnecessarily large amount of memory that contains ephemeral objects that are only used for a short time.
This commit is contained in:
parent
13c32b0fbe
commit
f1b73c9301
@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
godebug "runtime/debug"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/debug"
|
"github.com/restic/restic/internal/debug"
|
||||||
"github.com/restic/restic/internal/options"
|
"github.com/restic/restic/internal/options"
|
||||||
@ -81,7 +82,16 @@ func needsPassword(cmd string) bool {
|
|||||||
|
|
||||||
var logBuffer = bytes.NewBuffer(nil)
|
var logBuffer = bytes.NewBuffer(nil)
|
||||||
|
|
||||||
|
func tweakGoGC() {
|
||||||
|
// lower GOGC from 100 to 50, unless it was manually overwritten by the user
|
||||||
|
oldValue := godebug.SetGCPercent(50)
|
||||||
|
if oldValue != 100 {
|
||||||
|
godebug.SetGCPercent(oldValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
tweakGoGC()
|
||||||
// install custom global logger into a buffer, if an error occurs
|
// install custom global logger into a buffer, if an error occurs
|
||||||
// we can show the logs
|
// we can show the logs
|
||||||
log.SetOutput(logBuffer)
|
log.SetOutput(logBuffer)
|
||||||
|
Loading…
Reference in New Issue
Block a user