[hibernate-dev] Timestamper

Alex Snaps alex.snaps at gmail.com
Thu Apr 26 12:39:08 EDT 2012


Well you have the same issue with nanoTime(), beyond the fact that you
can't really trust it.
Also, there is no guarantee (iirc) for it to return consistent values
across cores, so it could go backwards.
Also, from a distributed caching perspective, this gives "some" sync
across multiple nodes.

(sorry, replied of replyall)

On Thu, Apr 26, 2012 at 12:27 PM, Sanne Grinovero <sanne at hibernate.org> wrote:
> Would it be possible to use System.nanoTime() instead?
>
> It's not suited to retrieve the absolute time (read the clock) but is
> very efficient to measure time intervals, and never goes back in time.
>
> Cheers,
> Sanne
>
> On 26 April 2012 17:11, Alex Snaps <alex.snaps at gmail.com> wrote:
>> Hey,
>> I wanted to draw your attention to "an issue" we've hit with the
>> nonblocking implementation of Timestamper, that you guys use as well.
>> Basically, if time goes backwards, calling next() would loop until
>> time is passed the last seen value (see
>> http://jira.terracotta.org/jira/browse/EHC-853)
>> Technically, time shouldn't go back. Especially the DST issue is none
>> in my opinion. But NTP daemons that do set clock back might be more
>> common.
>> As every session is timestamped, if I read
>> SessionFactoryImpl.SessionBuilderImpl.openSession correctly, this
>> would be larger issue to you guys now as well. There are obviously
>> more people using Hibernate w/o Ehcache than with it.
>> Anyways, as a solution to that, Chris and I came up with a
>> non-blocking SlewClock implementation that would simply, in case
>> System.currentTimeMillis() returns a value "in the past, slow time
>> down until the wall clock has caught up:
>> http://www.massapi.com/source/ehcache-2.4.3/src/net/sf/ehcache/util/SlewClock.java.html
>> Since Timestamper is again core to 2nd level cache usage in Hibernate,
>> it would make sense to this out of our code base and have it in yours
>> (as well, as we'd still use it in for the 3.x).
>> Should I go ahead and create a jira, pull request, ... ? Cause, based
>> on my experience, blaming it on crappy env. hasn't really worked out
>> for me ;-)
>> Alex
>> --
>> Alex Snaps <alex.snaps at gmail.com>
>> Senior Software Engineer - Terracotta
>> http://twitter.com/alexsnaps
>> http://www.linkedin.com/in/alexsnaps
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev



-- 
Alex Snaps <alex.snaps at gmail.com>
Senior Software Engineer - Terracotta
http://twitter.com/alexsnaps
http://www.linkedin.com/in/alexsnaps


More information about the hibernate-dev mailing list