Sanne Grinovero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-13879 (
https://hibernate.atlassian.net/browse/HHH-13879?atlOrigin=eyJpIjoiMDRiNG...
)
Re: Slow query log should use System#nanoTime not System#currentTimeMillis (
https://hibernate.atlassian.net/browse/HHH-13879?atlOrigin=eyJpIjoiMDRiNG...
)
hi Vlad, careful that’s not a straight forward change. I’m aware that {{
currentTimeMillis }} isn't recommended, but using {{ nanoTime }} might be a worse
choice: it is bound to the time of the specific CPU core, so if the context is switched to
a different CPU while performing the measured operation, the measured delta could be
completely wrong - including possibly negative times as you’re also affected by different
speeds of each core and complex power management of modern OSs.
The problem is that the task “running a query” is a blocking IO operation by nature, so
we’re almost sure that the task will be re-scheduled - we’re just not sure on which
physical CPU it will end up with.
Using `System#currentTimeMillis` is less precise, but all considered is possibly more
suitable in this context.
Neither of them has the precision we would need for a “fast operation”, but the specific
need of logging *slow queries* the milliseconds should be a good fit. At least while not
super precise, it won’t be producing confusing results.
(
https://hibernate.atlassian.net/browse/HHH-13879#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-13879#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100121- sha1:a269fed )