Skip to content

Commit

Permalink
feat: add env option SONIC_STOP_PROFILING to stop traceback on dema…
Browse files Browse the repository at this point in the history
…nds (#361)
  • Loading branch information
AsterDY authored Feb 14, 2023
1 parent 02865de commit fa82a64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/rt/asm_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ _stack_grow:

TEXT ·StopProf(SB), NOSPLIT, $0-0
NO_LOCAL_POINTERS
CMPB github·com∕bytedance∕sonic∕internal∕rt·StopProfiling(SB), $0
JEQ _ret_1
MOVL $1, AX
LEAQ github·com∕bytedance∕sonic∕internal∕rt·yieldCount(SB), CX
LOCK
Expand All @@ -37,6 +39,8 @@ _ret_1:

TEXT ·StartProf(SB), NOSPLIT, $0-0
NO_LOCAL_POINTERS
CMPB github·com∕bytedance∕sonic∕internal∕rt·StopProfiling(SB), $0
JEQ _ret_2
MOVL $-1, AX
LEAQ github·com∕bytedance∕sonic∕internal∕rt·yieldCount(SB), CX
LOCK
Expand Down
6 changes: 6 additions & 0 deletions internal/rt/gcwb.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package rt

import (
`os`
`sync/atomic`
`unsafe`

Expand Down Expand Up @@ -75,6 +76,11 @@ func GcwbAddr() uintptr {
}
}

// StopProfiling is used to stop traceback introduced by SIGPROF while native code is running.
// WARN: this option is only a workaround for traceback issue (https://github.com/bytedance/sonic/issues/310),
// and will be dropped when the issue is fixed.
var StopProfiling = os.Getenv("SONIC_STOP_PROFILING") != ""

// WARN: must be aligned with runtime.Prof
// type Prof struct {
// signalLock uint32
Expand Down

0 comments on commit fa82a64

Please sign in to comment.