getCachedTimeNs returns the current time in nanoseconds. This function previously used a global cache updated by a background goroutine, but that caused unnecessary CPU usage when the client was idle (ticker waking up the scheduler every 50ms). We now use time.Now() directly, which is fast enough on
()
| 35 | // on modern systems (vDSO on Linux) and only adds ~1-2% overhead in extreme |
| 36 | // high-concurrency benchmarks while eliminating idle CPU usage. |
| 37 | func getCachedTimeNs() int64 { |
| 38 | return time.Now().UnixNano() |
| 39 | } |
| 40 | |
| 41 | // GetCachedTimeNs returns the current time in nanoseconds. |
| 42 | // Exported for use by other packages that need fast time access. |
no outgoing calls
no test coverage detected