Skip to content
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

Higher time resolution for newTimeCache? #146

Open
portnov opened this issue Nov 15, 2017 · 3 comments
Open

Higher time resolution for newTimeCache? #146

portnov opened this issue Nov 15, 2017 · 3 comments

Comments

@portnov
Copy link

portnov commented Nov 15, 2017

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

  1. Am I right that newTimeCache creates a "cache" that refreshes not more often than one time in a second?

  2. 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.

@kazu-yamamoto
Copy link
Owner

Cc: @winterland1989

@winterland1989
Copy link
Contributor

@portnov

  1. Yes you are right, IIRC newTimeCache use auto-update package to achieve this.

  2. 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.

@portnov
Copy link
Author

portnov commented Nov 17, 2017

Thanks for the information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants