Skip to content

Commit 6add171

Browse files
jasondellalucepoiana
authored andcommitted
fix(sdk/symbols/extract): properly calculate starvation time in async extractor
Signed-off-by: Jason Dellaluce <[email protected]>
1 parent 42bf90c commit 6add171

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/sdk/symbols/extract/async.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const (
3535
)
3636

3737
const (
38-
starvationThresholdNs = 1e6
39-
sleepTimeNs = 1e4 * time.Nanosecond
38+
starvationThresholdNs = int64(1e6)
39+
sleepTimeNs = 1e7 * time.Nanosecond
4040
)
4141

4242
var (
@@ -91,7 +91,7 @@ func StartAsync() {
9191
atomic.StoreInt32((*int32)(&asyncCtx.lock), state_wait)
9292
go func() {
9393
lock := (*int32)(&asyncCtx.lock)
94-
waitStartTime := time.Now().Nanosecond()
94+
waitStartTime := time.Now().UnixNano()
9595

9696
for {
9797
// Check for incoming request, if any, otherwise busy waits
@@ -120,8 +120,8 @@ func StartAsync() {
120120
default:
121121
// busy wait, then sleep after 1ms
122122
if waitStartTime == 0 {
123-
waitStartTime = time.Now().Nanosecond()
124-
} else if time.Now().Nanosecond()-waitStartTime > starvationThresholdNs {
123+
waitStartTime = time.Now().UnixNano()
124+
} else if time.Now().UnixNano()-waitStartTime > starvationThresholdNs {
125125
time.Sleep(sleepTimeNs)
126126
}
127127
}

0 commit comments

Comments
 (0)