Skip to content

Commit

Permalink
fix(sdk/symbols/extract): properly calculate starvation time in async…
Browse files Browse the repository at this point in the history
… extractor

Signed-off-by: Jason Dellaluce <[email protected]>
  • Loading branch information
jasondellaluce authored and poiana committed Jun 15, 2022
1 parent 42bf90c commit 6add171
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/sdk/symbols/extract/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const (
)

const (
starvationThresholdNs = 1e6
sleepTimeNs = 1e4 * time.Nanosecond
starvationThresholdNs = int64(1e6)
sleepTimeNs = 1e7 * time.Nanosecond
)

var (
Expand Down Expand Up @@ -91,7 +91,7 @@ func StartAsync() {
atomic.StoreInt32((*int32)(&asyncCtx.lock), state_wait)
go func() {
lock := (*int32)(&asyncCtx.lock)
waitStartTime := time.Now().Nanosecond()
waitStartTime := time.Now().UnixNano()

for {
// Check for incoming request, if any, otherwise busy waits
Expand Down Expand Up @@ -120,8 +120,8 @@ func StartAsync() {
default:
// busy wait, then sleep after 1ms
if waitStartTime == 0 {
waitStartTime = time.Now().Nanosecond()
} else if time.Now().Nanosecond()-waitStartTime > starvationThresholdNs {
waitStartTime = time.Now().UnixNano()
} else if time.Now().UnixNano()-waitStartTime > starvationThresholdNs {
time.Sleep(sleepTimeNs)
}
}
Expand Down

0 comments on commit 6add171

Please sign in to comment.