-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: trace unmarshal algorithm performance (#3159)
* fix: trace unmarshal algorithm performance * fix: revert alias code * fix: use mutex
- Loading branch information
1 parent
aea10c8
commit 5443324
Showing
6 changed files
with
4,171 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package traces | ||
|
||
import "sync" | ||
|
||
type spanCache map[string]*Span | ||
|
||
var cache spanCache = nil | ||
var cacheMutex sync.Mutex | ||
|
||
func getCache() spanCache { | ||
cacheMutex.Lock() | ||
defer cacheMutex.Unlock() | ||
|
||
if cache == nil { | ||
cache = spanCache{} | ||
} | ||
|
||
return cache | ||
} | ||
|
||
func resetCache() { | ||
cacheMutex.Lock() | ||
defer cacheMutex.Unlock() | ||
|
||
cache = nil | ||
} | ||
|
||
func (c spanCache) Get(key string) (*Span, bool) { | ||
value, ok := c[key] | ||
return value, ok | ||
} | ||
|
||
func (c spanCache) Set(key string, value *Span) { | ||
c[key] = value | ||
} |
Oops, something went wrong.