Topic: Off By 1 in EP system

Nothing major but there appears to be an off-by-1 error somewhere in the EP system.

The Setup: 

1) Have fewer than the required EP to insert a new Extension.  In this case I had 452 EP and 457 EP was required to install the new extension which was Energy Management.

2) Open the Agent Profile window to the extensions section.  the cost of installing the extension in question was in red (correct) no install button displayed (correct).  Leave this window open.

3) Wait till you have exactly the required amount of EP.  In this case I waited 5 minutes till my EP hit 457 as viewed in the Terminal info header when "docked".

What Happens:

When my EP ticked up to 457 the cost of the Energy Management Extension became green and the Install button appeared in the Agent Profile window as expected.  However clicking "Install" resulted in an error box indicating that I didn't have enough EP.

I then waited for 1 minute till I had 458 EP, 1 more than the Extension requires.  Then clicking "Install" works, however after the install I was down to 0 EP which indicates that I either paid 1 more EP than I should have or that the client is showing 1 more EP than I actually had.

Cheers,

-xian

Re: Off By 1 in EP system

Nice catch. Probably just a timing issue, but worth getting on the to-be-polished fix list.

3 (edited by Norrdec 2011-07-05 15:41:51)

Re: Off By 1 in EP system

The EP is counted in 2 spots. One is the internal server clock, the other (the EP you see) is you computer.

If your computer gets at 14:48:50 that your EP is 10, it will wait one minute and change the counter to 11.
In the mean time the server counts EP every whole minute so at it will have different numbers than you. Sometimes when you are waiting for that one point that you think you have, the server still need to cycle the EP.

<GargajCNS> we maim to please

Re: Off By 1 in EP system

Norrdec wrote:

The EP is counted in 2 spots. One is the internal server clock, the other (the EP you see) is you computer.

Yup. That's where the bug is. They did not correctly synchronize the local timer to the server clock or, worse, are using the local clock instead of a timer.

Avatar Creations have a lot to learn about economy
-- Snowman

Re: Off By 1 in EP system

It's not really a bug, more like a mechanic to decrease the traffic between the server and the client. Working as intended.

<GargajCNS> we maim to please

Re: Off By 1 in EP system

Norrdec wrote:

It's not really a bug, more like a mechanic to decrease the traffic between the server and the client. Working as intended.

All is needed is a few small packet exchanges when the client starts. Hardly a traffic issue.

Avatar Creations have a lot to learn about economy
-- Snowman

Re: Off By 1 in EP system

Yeah true if we are only taking about a single synchro. But why make something so simple, more complex?

<GargajCNS> we maim to please

Re: Off By 1 in EP system

Pak wrote:
Norrdec wrote:

It's not really a bug, more like a mechanic to decrease the traffic between the server and the client. Working as intended.

All is needed is a few small packet exchanges when the client starts. Hardly a traffic issue.

Not really...
Your client is subject to lagging, therefore the time counted by your client can be quite off from the server time after playing for 2 hours for example. I encountered that while coding my own game back in early 90's (computers weren't as fast back then as they are now :-)) but seeing as Perp client lags to Hell and back even on my machine I suspect the internal timer lags just as well.
Solution:
1. On client start sync client time with server time using NTP
2. Upon syncing the client sets a constant "offset" variable which is the result of the equation of [Server Time - Client PC BIOS Time]
3. Every 15/30/60 minutes the internal time in client syncs with server again by setting client time to [Client PC BIOS Time + offset]
No network traffic and the client stays more-or-less synced. Please note that BIOS time is hardware-controlled and therefore not subject to lag (however, it's subject to hardware issues that can make it go +/- but only by miliseconds really)

Raavi "The Unforgiven" Arda

Re: Off By 1 in EP system

I'm a developer myself and assumed this was likely the issue...

I had been logged in for probably 4-5 hours so a synchronization on start up would not help as clock drift would negate its usefulness, in fact this probably is already done.

A simple, non-server loading possible fix:

When the extension page in the agent profile is loaded, sync EP with server.

If the extension page is open and a change from "can't install/update" to "can install/upgrade" occurs, check with the server to see if EP is still in sync before decided to display the install/uprade button.

That of course, assumes the controlling logic for the agent profile window allows easy hooking to those events.

As I mentioned in the OP, this isn't a big deal and clearly falls in the polish category.

10

Re: Off By 1 in EP system

Client lagging has nothing to do with clock drifting. Clock drifting on modern hardware should be absolutely negligible even over a long playing session. In any case it can be measured and corrected for. Also re-syncing requires such a small number of bytes on the net that they could just re-do it periodically.

Anyway I just noticed that the client actually does get the server time already, but it increments the "available" EP count on the minute of the client clock, not on the minute of the server clock, so this is actually a bug and it should be pretty easy to fix as the server clock is already available to the client.

Extra hint: intentionally offset the server clock value, as kept on the client, by one second (or a fraction thereof) and update the EP count on this offsetted clock minute instead of using the client clock as is currently the case. There'll never be this problem any more, you do not even need to care too much of precise syncing, jitter, systematic bias due to differing forward and backward routing, drifting etc. etc.

Avatar Creations have a lot to learn about economy
-- Snowman

Re: Off By 1 in EP system

your expecting it to be a synchro issue... i supect it to be a simple rounding-display issue...

some extensions calculate with xxxx.5 - but are displayed either rounded up, or rounded down (i havent figured out why)

*Disclaimer: This post can contain strong sarcasm or cynical remarks. keep that in mind!
Whining - It's amazing how fast your trivial concerns will disappear

12

Re: Off By 1 in EP system

Annihilator wrote:

your expecting it to be a synchro issue... i supect it to be a simple rounding-display issue...

some extensions calculate with xxxx.5 - but are displayed either rounded up, or rounded down (i havent figured out why)

They display rounded down. And if they require more than what is actually displayed, that is a bug (a different one).

There however is a bug with the clocks. Not a synchro bug, but the client is updating the available EP count when the local clock times the minute instead of updating it when the server clock times the minute. Since the client already has both clocks available, there's no reason not to use the server one instead of the local one.

Once they fix this and use the server clock instead of the local clock, then a sync problem may surface. But that's easy to fix too (my suggestion being to intentionally set the server clock, as kept on the clients, one second, or a fraction thereof, later than the actual server clock).

Avatar Creations have a lot to learn about economy
-- Snowman

13 (edited by Norrdec 2011-07-07 07:34:41)

Re: Off By 1 in EP system

How can you be sure that the server clock wasn't synchronised at the beginning?

/edit just tested in on 2 clients, there was a 1s difference in the "server clock"

<GargajCNS> we maim to please

14

Re: Off By 1 in EP system

Yep. It is somewhat synchronized, but it's not über precise. Anyway as long as they change the client to update the available EPs according to the server clock and they make sure the server clock, as kept by the client, is not ahead of the real server clock things will be allright. Small differences between the server clocks of different clients are not a problem, as long as they are all are behind or identical to the real server clock.

Avatar Creations have a lot to learn about economy
-- Snowman

Re: Off By 1 in EP system

You can't have a game fully synchronized. Hell there is a thousand of games that can't fully synchro between 5 lan clients, not to mention a 1000.

<GargajCNS> we maim to please

16

Re: Off By 1 in EP system

1) we are not talking of synchronizing the game (nearly impossible due to lag and jitter), but of synchronizing clocks (possible up to the 1/2 of the systematic difference between up and down packet routing times).

2) to solve the problem the OP has seen we do not need exact synchronization. All that is needed is that the server clock on the client is guaranteed not to be ahead of the actual server clock (and this is the easiest thing to do when handling remote clocks, you do not even need a synchronization formula or protocol).

Avatar Creations have a lot to learn about economy
-- Snowman

Re: Off By 1 in EP system

but the matter has so marginal impact on gameplay...

unlike that other game, it doesnt matter if you get your extension right on the minute... you dont lose anything...

*Disclaimer: This post can contain strong sarcasm or cynical remarks. keep that in mind!
Whining - It's amazing how fast your trivial concerns will disappear

Re: Off By 1 in EP system

+1 to Annihilator.

<GargajCNS> we maim to please

Re: Off By 1 in EP system

Pak wrote:

Client lagging has nothing to do with clock drifting. Clock drifting on modern hardware should be absolutely negligible even over a long playing session.

Drift is really not negligible and is in fact an issue on many systems, whether its the issue in this case, only the developers know. 

Modern hardware has nothing to do with this, unless you running on a real time kernel your clock is wrong and drifting all over the place with the exception of when your NTP daemon runs.  Windows is particularly bad at this and can be off multiple seconds per minute under heavy CPU load.

20

Re: Off By 1 in EP system

Xianthax wrote:
Pak wrote:

Client lagging has nothing to do with clock drifting. Clock drifting on modern hardware should be absolutely negligible even over a long playing session.

Drift is really not negligible and is in fact an issue on many systems, whether its the issue in this case, only the developers know. 

Modern hardware has nothing to do with this, unless you running on a real time kernel your clock is wrong and drifting all over the place with the exception of when your NTP daemon runs.  Windows is particularly bad at this and can be off multiple seconds per minute under heavy CPU load.

That's why you should use the hardware clock and not the OS clock. But I agree that windows may be stupid enough to update the hardware clock with borked OS values.

Anyway there are multiple solutions for that too. Also an MMOG by definition is networked at least to the game server: resyncing requires just a few bytes.

Besides: the client is updating the available EP count according to the local clock, not according to the server clock despite the fact that it does have knowledge of the server clock. THIS is the bug.

Avatar Creations have a lot to learn about economy
-- Snowman

Re: Off By 1 in EP system

They decided on a one time synchro at best and left it. Time to move one, it's a feature not a bug wink

<GargajCNS> we maim to please

Re: Off By 1 in EP system

Pak wrote:

That's why you should use the hardware clock and not the OS clock.

While entertaining this is extremely slow and reliant on the response time of the handling interrupt.

23

Re: Off By 1 in EP system

Xianthax wrote:
Pak wrote:

That's why you should use the hardware clock and not the OS clock.

While entertaining this is extremely slow and reliant on the response time of the handling interrupt.

You are referring to the very old RTC. I was referring to modern hardware and the HPET. But a friend told me why it is probably not being used: it is not supported by Windows XP. <shrug>

Avatar Creations have a lot to learn about economy
-- Snowman

Re: Off By 1 in EP system

Pak wrote:

You are referring to the very old RTC. I was referring to modern hardware and the HPET. But a friend told me why it is probably not being used: it is not supported by Windows XP. <shrug>

What are you talking about?  HPET doesn't replace the RTC for time tracking,  in fact  it has nothing to do with determining UTC time at all, its an interrupt timer for triggering events.

25

Re: Off By 1 in EP system

Xianthax wrote:
Pak wrote:

You are referring to the very old RTC. I was referring to modern hardware and the HPET. But a friend told me why it is probably not being used: it is not supported by Windows XP. <shrug>

What are you talking about?  HPET doesn't replace the RTC for time tracking,  in fact  it has nothing to do with determining UTC time at all, its an interrupt timer for triggering events.

Which is exactly what you would need to keep a separate clock ticking independently of the system clock if you know the system clock is not reliable.

Avatar Creations have a lot to learn about economy
-- Snowman