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

use nanoTime instead of wall clock time to guarantee monotonicity #213

Closed
gurghet opened this issue Dec 29, 2020 · 1 comment
Closed

use nanoTime instead of wall clock time to guarantee monotonicity #213

gurghet opened this issue Dec 29, 2020 · 1 comment

Comments

@gurghet
Copy link
Contributor

gurghet commented Dec 29, 2020

The reason is nanoTime gives you a monotonic value (representing the number of nanoseconds since system boot) while instant gives you a non-monotonic value (millis since epoch). The latter is subject to changes made to the system clock (including it going backwards), usually as result of NTP adjustments. See also https://medium.com/@kralka/its-about-time-d42e68dbe1df

Originally posted by @sirocchj in #212 (comment)

@sirocchj
Copy link
Member

sirocchj commented Jul 13, 2021

This is now fixed as of v0.9.0.

See

final case class ChunkWithMetadata[V](chunk: Chunk[V], pulledAt: Long = System.nanoTime())
final case class ValueWithMetadata[V](value: V, pulledAt: Long = System.nanoTime())
and
start <- UIO(System.nanoTime())
(values, time) <- process(query, chunkSize, transactor, queue, currentState)
newState <- stateFold(currentState, QueryResult(ResultMetadata(time - start), values.map(_.value)))

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

2 participants