-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace time.Now
with lower precision time source
#51
Comments
Do you know any cache library have this optimization? |
I have proposed to replace wall time |
Seems reasonable to me. |
@pheepi @bartle-stripe Did you implement the background goroutine @coocood For reference, this is what the pprof data looks like when trying to set tens of millions of entries in an AWS Fargate task. Roughly 60% of the CPU for setting items is being spent in |
I don't believe I ever did. |
This resulted in ~50% speedup for calls to
|
@coocood Do you think the performance improvement from this is worth replacing the existing default implementation? |
The And We could create a well-implemented builtin lowResClock, but I think the default should still be |
Optimized timer with cached value is now part of the code passed as a custom parameter of |
time.Now()
will sometimes result in a full system call (this is the default on AWS EC2 instances). I think for an LRU you can probably get away with second precision. One option would be to have a background goroutine that calledtime.Now()
every second and cached the result globally.The text was updated successfully, but these errors were encountered: