Ghost’s blog » 2007 » March

March 29, 2007

Israel’s foreign relations

In the summer of last year Israel proceeded to war against Hezbollah fighters in Lebanon. In the process they bombed UN facilities killing four UN workers, including Finnish peacekeeper.

Later in the same year Finland received Isreael’s answer to the request of investigation of the incident. The report states that the bombing was “operational mistake” and Israel takes responsibility for it.

It was in the news today, that the Israeli PM’s office is concerned about the court ruling of publishing testimonies of Israeli officials. Allegedly revealing the testimonies would “damage foreign relations“.

“[There] is a real and present concern… over damage to the security of the state, its foreign relations and its relations with various individuals and groups that were involved, and continue to be involved, in managing the state’s security issues” — Isreali PM’s office

After getting away killing four UN workers, wounding several others and killing hundreds of Lebanese civilians with no consequences, it’s hard to see how statements by the officials would “damage foreign relations” more than not. Even the “matter of national security” seems like a excuse for keeping the embarassing statements as a state secret.

The outcome shouldn’t be too much of a surprise though, looking at the Israel’s current “public relations”: On the brink of a war with - how many - 3 to 5 countries?

March 16, 2007

FPS kills faster than a bullet

The game started to CTD (crash to desktop) on me lately. Before that it seemed that the game was getting heavier and heavier and FPS was slowly going down. There wasn’t good explanation why it was happening. Everything had been the same for year(s). The change in gameplay was actually so small, that I hardly noticed any difference in normal play. Only CTDs got me doubt that everything wasn’t fine anymore.

The problem turned out to be my display adapter, Radeon 9800 Pro. More specifically it was its passive cooler that wasn’t functioning efficiently anymore. The heat sink wasn’t firmly attached to the GPU because some screws had got loose.

At least that’s how it seemed.

Tilting the loose heat sink on R9800Pro

[See how the loose heat sink could be tilted]

I’m yet to confirm that everything is working good again. Actually I already got one CTD after fixing the cooler. That might be because the GPU is already f’d up.

[next day]

It’s not the GPU. I got CTD with another R9800Pro. It could be something in the mainboard. When installing chipset drivers (Nforce3, v5.11) it throws bluescreen on ethernet drivers section. I got ethernet drivers (part of the chipset, “integrated” so to speak) installed separately, though.

Tomorrow I’ll downgrade chipset drivers to v5.10 and hope it’ll work better. Obviously there’s something wrong somewhere, beucase the game wasn’t crashing a month ago, but now it does.

[next day]

Downgrading chipset drivers didn’t help. I tried running CPU and memory stress programs, but I didn’t get the system to crash. However, right after I started CS:S and started to play I got BSOD (blue screen of death), which had never happened before. It seems that something is overheating, but when I immediately opened the chassis after the crash all components were just hand warm.

It could be that the CS:S installation itself has somehow managed to mess itself, but it’s quite long shot already. It seems that I’m stuck with low FPS for now.

March 13, 2007

Geolocation on server page

Geolocationing system on the server page would be cool. So let’s do it!

There are several ways to get location information on that page, which way to go?

  1. The easy way: do it by PHP
  2. DB style: fetch info from database
  3. Advanced style: PHP module
  4. Anything, as far as it works

The easy way is to get Maxmind’s GeoIP.dat (used by CountryFilter plugin to block connections from USA, Canada and GB) and use it through “pure” PHP API. On the server page all that is needed is something like $countrycode = geoip_get_country_code($ip) and that’s it. The code must be searched from 700 kB geoip database, which obviously takes some time. Doing the search for nearly 3000 servers on one page slows down generation of the page to about 10 seconds.

DB style thing is to get Maxmind’s IP-to-Country database in CSV format (Comma Separated Value) and load it to database. Then it is possible to query country information while querying all other server information, such as server name and number of players. This should be fast and neat, but it turns out that it’s only neat. Rendering the server page takes over 10 seconds, even though MySQL says it completes the query in 5. Either way, it’s too slow.

Advanced style gets us to real world implementations. Maxmind has C library and PHP module implementation of the IP-to-Country system. Obviously the C implementation of the same system as in “the easy way” is far faster than PHP version. This proves to be true. Compiling C library and managing to install PHP module with PEAR was somewhat tricky to get along, especially the PEAR part, but eventually PHP found GeoIP module and GeoIP module found GeoIP database. For some reason PHP module’s function name was different than on the “pure” PHP API. Luckily I noticed that while messing with the installation. The end result is fast and quite neat, only one line of code to get a country code for certain IP. This method renders the server list page in 2.5 seconds. Well, not something that I’d expect.

Quite poor result with PHP modules was surprise. Searching 3000 servers’ location shouldn’t be taking 2.5 seconds. Well, it wasn’t. Rendering the page without country information takes 1,5-2 seconds, so retrieving the location information takes some 0,5-1 seconds. Moreover for some reason PHP is slowing down MySQL queries. Querying 3000 servers from some 30 000 servers takes only split second for MySQL to complete. It shouldn’t take seconds to render by PHP.

From the very start it’s been clear that ultimately the fastest way would be to retrieve location information only once for every server and store them somewhere, most preferably to the DB with all other server information. This, however, wouldn’t be very neatly integrated to the current server query system. It would take much more effort to change the current server querier - without breaking it - to use Maxmind’s PERL module (they have APIs for every use) than to do things separately.

The conclusion is that the current server list page is already rendering itself very slow. Somekind of caching could be used to speed up things. Then it wouldn’t matter if rendering the page every now and then would take up to 5 seconds.

Update (15 minutes later :P )

Getting pages cached in PHP seems to be very straightforward. The same method is already being used on server stats images, but they are images. Now we have some HTML cached too. Yeah!

March 4, 2007

Migration from ru to pin

Migrating from rusetti to pinsetti has gone extremely well.

It’s unbelieveable that all MySQL databases with all user privileges were perfectly transferred simply by copying the data directory of MySQL to the new server. The database was running in “production use” all the time when backup was being made. It means that the server query thingie, PS3, PS2 and messageboard were possibly writing or reading stuff from the database as it was being copied. That may have caused, and probably did, that the database file wasn’t the same when copying was started and when it was finished. However, MySQL is flexible little pig and it doesn’t seem to have suffered fatal injuries :).

Also the new server query system worked like a charm on a new server, almost. There was one little problem which took about hour to solve. For some reason it was complaining that there is an error in SQL syntax even though the very same SQL queries were being done on rusetti at the same time. The problem was years old Perl MySQL module - SuSE quality (made in Germany). It took minute to update, but an hour to resolve.

Some compromises had to be done. There are no longer “servers on map” or “masterserver rank” graphs. They were based on the old file based server query thing and are no longer supported. For masterserver rank there is already equivalent database solution, but it has jammed the old server once - even though it worked ten times before that. It could be that the new server is juicier and can handle it better, but it remains to be seen.

Currently there are still open issues in the migration. There are lots of Setti Masterserver users who still use the old system. The old system will disappear in less than two weeks leaving thousands of players without server list. Release groups and 3rd party server browser developers should update their clients to use new IP address for the masterserver. It could be that they don’t realize what’s going to happen, even though there is notification in the old masterserver.

March 1, 2007

Setti MasterServer - Better server browser

New MasterServer - better server browser

Setti MasterServer started humbly in March 2006. It steadily gained popularity by delivering the most comprehensive list of public servers and being extremely reliable. The lift-off for Setti MasterServer happened on mid-April when DigitalZone released CS:S patch including Setti MasterServer. User amounts increased immediately 10 times what they had been. The effect cumulated as other releases started to feature Setti MasterServer too.

Currently Setti MasterServer has approximately 5000 users. There are on average 15 requests per minute in a day. At peak times there is one request every two seconds. Since March 2006 there has been nearly 4 million requests from all over the world.

The server itself is relatively simple. There are couple hundred lines of code written in Perl. Basically the server just gets list of servers, transforms it to compatible format and sends the result data back to a client. Server addresses are encoded with 6 bytes. First four digits of an IP address are formatted in one byte each, and a port number is formatted with two bytes in so called “unsigned network ordered short”. Server addressses are packed in 128 groups before sending them to a client.

Setti MasterServer daily requestsSetti MasterServer yearly requestsSetti MasterServer yearly growth

At this time there are about 2600 servers in Setti server list. That means there will be about 20 packets to be sent to a client. Every packet is 768 bytes in size, so the total cost for sending all servers to one client is 15 kb. Every day there are in total about 20000 requests, so the bandwidth consumption for the service is 320 MB per day. Surprisingly much.