-
Notifications
You must be signed in to change notification settings - Fork 312
Open
Description
go-agent/v3/internal/trace_id_generator.go
Lines 52 to 58 in 046b4fc
| func (tg *TraceIDGenerator) generateID(len int) string { | |
| var bits [maxIDByteLen]byte | |
| tg.Lock() | |
| defer tg.Unlock() | |
| tg.rnd.Read(bits[:len]) | |
| return hex.EncodeToString(bits[:len]) | |
| } |
In a heavily used server a lot of segments end at the same time, and from what see in the profiles this lock is a problem.
- Can it be avoided at all? For instance, using some magic "per-thread" generator (as much as that is possible, but possibly just having more than one rand instance might work?)
- If it cannot be avoided, can it be made smaller? I see that it uses
deferto unlock, which means it unlocks after the conversion of the bits to the hex representation needed in the ID. Maybe it can be explicitly unlocked at least before that?
Metadata
Metadata
Assignees
Labels
No labels