important Suggestion

Discuss everything strategical about SMR.
Post Reply
Fatman
Quiet One
Posts: 50
Joined: Sun Apr 24, 2005 3:29 am

important Suggestion

Post by Fatman »

I suggest you correct rpoblem causing massive freaking lag when you get when more the 4 or 5 ships are in same sector...I have finally had all this laggy 8) :D than i can stand, so the game has lost yet another long time player....enjoy the dying days of this once great game....
Page
SMR Coder
Posts: 1779
Joined: Sat Dec 07, 2002 9:17 pm

Re: important Suggestion

Post by Page »

This lag is nothing new, the game has always lagged in big fights for as long as I can remember.
The reason it lags with lots of people in the same sector is that for each page load the game locks that sector, so no one else in that sector can do anything whilst the current action is executing and they all end up queuing up behind each other, this is required because otherwise you can get all sorts of crazy things happen where one script reads data, another writes over that data, and then the first writes back on the top and completely ignores the other script, but only for that bit - basically think major bugs.

It is possible to improve the locking mechanism so that less pages grab the sector lock, and even potentially so that it only grabs locks on individual players. Sounds simple right? Well except you get the issue that if it doesn't grab the lock when it does actually need it then you get the same problems as no locking mechanism, also if you try to do it on a more granular level then you can easily get the issue of deadlocks where A has lock 1 and needs lock 2 and B has lock 2 and needs lock 1, this will mean that both get stuck and never end, which would essentially break the game.
Put simply trying to improve the locking system requires a lot of thought and also is likely to break things and you might say to test on beta, but the simple fact is that the worst issues only appear when lots of people are trying to do things at once.

Now it's clearly not impossible to improve the locking mechanism to reduce the amount of lag and the AJAX autorefresh doesn't take the lock, therefore meaning it does not need to wait on other scripts, nor do they need to wait on it, the reason it doesn't take the lock is that it should never take any action that will change any state in the game, this hasn't always been true though, even for just refreshing a loaded page.


TL;DR: It's a hard problem to solve without introducing some very hard to debug bugs, however it is being worked on and a lot of progress has been made towards greatly improving the locking over the course of 1.6, but until all the groundwork is in place it's not really possible to improve the situation significantly.
N.ator
Beginner Spam Artist
Posts: 1611
Joined: Mon Aug 07, 2006 1:23 am
Location: Norway
Contact:

Re: important Suggestion

Post by N.ator »

what happens if you have 5< ships in a sector ajaz/auto refresh will shop, which might make the lagging problem not occur?
ImageImage
Page
SMR Coder
Posts: 1779
Joined: Sat Dec 07, 2002 9:17 pm

Re: important Suggestion

Post by Page »

The AJAX does not acquire the lock, so no pages will have to wait for AJAX to release the lock either. And during the fight earlier I got info on the load of the server as people were complaining about lag and put simply, less than half of the processing power of the server was in use.

I have put a change in to beta that drops the lock before doing the display code, which should be fine in most cases as it shouldn't write data at all (although I did have to fix one place where it actually did), this should reduce the amount of time the lock is held and hence reduce the time waiting for other people to finish with the lock, however it will only be a partial fix, and the more you manually click CS/LM/etc rather than letting AJAX do it's thing then the more locks will be being grabbed and therefore the more "lag" you will experience.

Anyway, the point is this problem is being worked on, but it's a very tricky and dangerous problems (the almost double death of Markus in Warlocked is an example of something that happened because made changes to reduce the chances of the "Failed to acquire sector lock." error.
Fatman
Quiet One
Posts: 50
Joined: Sun Apr 24, 2005 3:29 am

Re: important Suggestion

Post by Fatman »

I apologize page for flipping out
Freon22
Beginner Spam Artist
Posts: 3278
Joined: Wed Apr 17, 2002 10:09 pm
Location: USA
Contact:

Re: important Suggestion

Post by Freon22 »

Hi Page,
You seem to be up to date on locks so I have a question. On MSSQL the database will automatically lock the row being updated and depending on how many rows are being updated it can lock the table. I had a deadlock happen when I was updating a few rows. But before some of the rows could update they had to read some rows which were locked. It broke the system here at the office lol. Since then I have started calling my onw locks for updates and using NOLOCK to read.

UPDATE customer WITH (ROWLOCK) SET cost = @cost WHERE customerID = @customerID
SELECT credit FROM customer WITH (NOLOCK) WHERE customerID = @customerID

Now my sql statements are much more complex then this. But anyway the NOLOCK allows me to read a locked row so it ended my deadlock problems. We are thinking about using a MySQL database on another project and while looking into MySQL I see they have two lock types and three lock levels. Is it possible to call a NOLOCK with MySQL?
Page
SMR Coder
Posts: 1779
Joined: Sat Dec 07, 2002 9:17 pm

Re: important Suggestion

Post by Page »

I have no idea if it's possible to do a "NOLOCK" with MySQL, but I have to say it seems to completely go against every point of locking in the first place as using it will allow for you to read potentially incorrect data, it seems like you should change the order you do things so as to avoid the deadlock in the first place, also if you own the lock on a row you should be able to read from it without a problem.
From what I've just read of NOLOCK you should only really be using it for data that it doesn't matter if the user sees incorrect data or for data which will no longer be being updated (archived data), it does however give a performance benefit for those cases. But using it to get around deadlocks seems very risky and bad practice to me.

Anyway, MySQL does have an equivalent which is "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED", but I'd really recommend to avoid using it, especially for any important data that has any chance of being modified. Essentially it removes the whole point of doing any locking.
Freon22
Beginner Spam Artist
Posts: 3278
Joined: Wed Apr 17, 2002 10:09 pm
Location: USA
Contact:

Re: important Suggestion

Post by Freon22 »

Yes I know it is dirty data. But it is data that normally does not change offen. We have a small system one server with four computers at first I did not know what was causing the problem. Since it did not happen very offen, I noticed that we had the problem when three or more computers were inputing Invoice data at the sametime. Even then it did not happen all the time I think most times was when these computers were working on the same customer file.

Anyway I tryed a few different ways of fixing it without having to do a lot of re-writting. The NOLOCK on some of the SELECT was a fast simple fix. Someday I will re-write the queries but not today or tomorrow.

I have done some reading and searches on NOLOCK with mysql and you are right. So that project for now is on the back burner.

Thanks
Post Reply