-
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
- Loading branch information
1 parent
aea10c8
commit 3643af3
Showing
6 changed files
with
4,171 additions
and
10 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,29 @@ | ||
package traces | ||
|
||
import "sync" | ||
|
||
type spanCache map[string]*Span | ||
|
||
var cache spanCache = nil | ||
var cacheMutex sync.Mutex | ||
|
||
func getCache() spanCache { | ||
if cache == nil { | ||
cache = spanCache{} | ||
} | ||
|
||
return cache | ||
} | ||
|
||
func resetCache() { | ||
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.