Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Commit

Permalink
leak detector
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed May 8, 2023
1 parent e79a7b8 commit e8b81de
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions common/dbg/experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,45 @@ func BigRwTxKb() uint {
}

var (
slowCommit time.Duration
getSlowCommit sync.Once
slowCommit time.Duration
slowCommitOnce sync.Once
)

func SlowCommit() time.Duration {
getSlowCommit.Do(func() {
v, _ := os.LookupEnv("DEBUG_SLOW_COMMIT_MS")
slowCommitOnce.Do(func() {
v, _ := os.LookupEnv("SLOW_COMMIT")
if v != "" {
i, err := strconv.Atoi(v)
var err error
slowCommit, err = time.ParseDuration(v)
if err != nil {
panic(err)
}
slowCommit = time.Duration(i) * time.Millisecond
log.Info("[Experiment]", "DEBUG_BIG_RW_TX_KB", slowCommit)
log.Info("[Experiment]", "SLOW_COMMIT", slowCommit.String())
}
})
return slowCommit
}

var (
slowTx time.Duration
slowTxOnce sync.Once
)

func SlowTx() time.Duration {
slowTxOnce.Do(func() {
v, _ := os.LookupEnv("SLOW_TX")
if v != "" {
var err error
slowTx, err = time.ParseDuration(v)
if err != nil {
panic(err)
}
log.Info("[Experiment]", "SLOW_TX", slowTx.String())
}
})
return slowTx
}

var (
stopBeforeStage string
stopBeforeStageFlag sync.Once
Expand Down Expand Up @@ -261,19 +281,3 @@ func StopAfterReconst() bool {
})
return stopAfterReconst
}

var (
detectLeak bool
detectLeakOnce sync.Once
)

func DetectLeak() bool {
detectLeakOnce.Do(func() {
v, _ := os.LookupEnv("DETECT_LEAK")
if v == "true" {
detectLeak = true
log.Info("[Experiment]", "DETECT_LEAK", detectLeak)
}
})
return detectLeak
}

0 comments on commit e8b81de

Please sign in to comment.