diff --git a/internal/rt/asm_amd64.s b/internal/rt/asm_amd64.s index d7abffdd4..8250e38d3 100644 --- a/internal/rt/asm_amd64.s +++ b/internal/rt/asm_amd64.s @@ -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 @@ -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 diff --git a/internal/rt/gcwb.go b/internal/rt/gcwb.go index 2cec9df46..c3217c899 100644 --- a/internal/rt/gcwb.go +++ b/internal/rt/gcwb.go @@ -17,6 +17,7 @@ package rt import ( + `os` `sync/atomic` `unsafe` @@ -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