[infinispan-dev] [Discussion] TimeService implementation
Manik Surtani
msurtani at redhat.com
Tue May 7 07:47:11 EDT 2013
On 3 May 2013, at 17:00, Mircea Markus <mmarkus at redhat.com> wrote:
>
> On 3 May 2013, at 16:54, Pedro Ruivo wrote:
>
>> On 05/03/2013 04:49 PM, Manik Surtani wrote:
>>>
>>> On 2 May 2013, at 19:01, Pedro Ruivo <pedro at infinispan.org> wrote:
>>>
>>>>
>>>> preciseTime() {return (cached = System.nanoTime());}
>>>> impreciseTime() {return cached;}
>>>
>>> How would you invalidate the cached time?
>>
>> My idea is to have a schedule thread updating the cached time. the
>> preciseTime() is just an optimization to keep the cached value more
>> up-to-date since we are calculating the nanoTime() (and assuming that
>> nanoTime() is more expensive than write in the volatile variable).
>
> Sounds like a good idea but please don't implement that for now. That's a performance optimisation and would require benchmarking to prove it's worth doing
Exactly. You may well find that this is what the JDK does anyway. Plus the cost of a scheduled thread (context switching, volatile write, etc) may not really be worth the perceived benefits.
--
Manik Surtani
manik at jboss.org
twitter.com/maniksurtani
Platform Architect, JBoss Data Grid
http://red.ht/data-grid
More information about the infinispan-dev
mailing list