Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add env option SONIC_STOP_PROFILING to stop profiling on demands #361

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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