[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ha-dev
Subject: Re: [Linux-ha-dev] Re: hearbeat v1.0.2 on Alpha?
From: Alan Robertson <alanr () unix ! sh>
Date: 2003-06-18 17:12:01
[Download RAW message or body]
Thomas Heiligenmann wrote:
> Alan Robertson wrote:
>
>>
>> Wow! That's way better.
>>
>> It still seems to me there are some inaccuracies that should be
>> corrected... Let me think this through...
>>
>> Let's say we're trying to time 1.5 seconds (1500ms), and Lc_Hz is 1024...
>>
>> Then this code would give us an answer of 1024... But the answer
>> should be
>> 1024+512, which is 1024 + (msec * Lc_Hz) / 1000. I originally
>> computed the ms/tick thing primarily to avoid this extra
>> multiplication - because I saw Lc_Hz/1000 was a constant.
>>
>> But this formula is more accurate as hz gets larger and when 1000
>> isn't evenly divisible by Hz... So, I think maybe I'll drop the
>> "optimization".
>>
>> What if the line were replaced with:
>>
>> result = secs * Lc_Hz + (msec * Lc_Hz)/1000
>>
>> And for most modern processors, an extra multiply is faster than a
>> branch...
>>
>> Wouldn't that do it?
>>
>
> Yes. The formula is kept unchanged and there's no more danger of a
> division by zero.
>
>> Would you test this version for me?
>>
>
> It works with 1.0.2 and 1.1.1 and timing looks fine. Are there any tests
> I can do to see if there's an improvement in accuracy?
>
> BTW in 1.1.1 my compiler complained about ipcsocket.c and I had to add
> an explicit typecast. The whole new diff is attached.
>
>
> Thomas
>
>
> ------------------------------------------------------------------------
>
> diff -urP heartbeat-1.1.1/lib/clplumbing/ipcsocket.c heartbeat-1.1.1-patched/lib/clplumbing/ipcsocket.c
> --- heartbeat-1.1.1/lib/clplumbing/ipcsocket.c Sat May 3 15:27:48 2003
> +++ heartbeat-1.1.1-patched/lib/clplumbing/ipcsocket.c Wed Jun 18 14:11:04 2003
> @@ -795,7 +795,7 @@
>
> if (sendrc != msg->msg_len) {
> cl_perror("Sent %d byte message body: rc = %d"
> - , msg->msg_len, sendrc);
> + , (int)msg->msg_len, sendrc);
> }
>
> #if 0
> diff -urP heartbeat-1.1.1/lib/clplumbing/longclock.c heartbeat-1.1.1-patched/lib/clplumbing/longclock.c
> --- heartbeat-1.1.1/lib/clplumbing/longclock.c Mon Apr 28 18:12:07 2003
> +++ heartbeat-1.1.1-patched/lib/clplumbing/longclock.c Wed Jun 18 14:06:32 2003
> @@ -109,7 +109,7 @@
> if (ms == 0) {
> return (longclock_t)0UL;
> }
> - result = secs * Lc_Hz + (msec/ms_per_tick);
> + result = secs * Lc_Hz + (msec * Lc_Hz)/1000;
>
> if (result == 0) {
> result = 1;
I put these into CVS -- along with removing the ms_per_tick variable.
--
Alan Robertson <alanr@unix.sh>
"Openness is the foundation and preservative of friendship... Let me claim
from you at all times your undisguised opinions." - William Wilberforce
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.community.tummy.com
http://lists.community.tummy.com/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic