logger
logger copied to clipboard
Higher time resolution for newTimeCache?
As far as I can see, the whole TimedFastLogger thing is primarily intended for the case when one wants to print time to log with precision of one second only. But, I have some experience with applications where a thousand events in a millisecond is not an exceptional situation. In such applications, it becomes essential to log time with precision of at least a millisecond.
Questions are
-
Am I right that newTimeCache creates a "cache" that refreshes not more often than one time in a second?
-
Do you have any practical insights, if a similar time caching mechanism with update interval of 1 millisecond will give any advantage comparing to directly formatting time each time?
The suggestion is to add new function newTimeCache'
, which would take one additional argument - update interval.
Cc: @winterland1989
@portnov
-
Yes you are right, IIRC
newTimeCache
useauto-update
package to achieve this. -
The time cost are:
- syscall to fetch time, average 1~10 microsecond.
- the formatting processing which convert time to string, average 10~100 microsecond.
It's quite costly if you update the cache every millisecond. auto-update
package use a complicated locking system to avoid unnecessary update(when you don't fetch the cache), but that also add some overhead, especially on multi-ghc-threaded programs.
Thanks for the information.