Forum C# Server Performance Bug?

Server Performance Bug?

Postby whitershores » July 19th, 2012, 1:31 pm

I've been running some profiling on the performance of the live server, and generally speaking the Live Server is very fast, code runs even faster than on the debug server! Great!

Code like this is actually 50% faster on the server than on my home Computer!
Code: Select all
long startTime = _stopWatch.ElapsedMilliseconds;
double myRandom = 0;
for (int i = 0; i < 1000000; i++)
{
    myRandom += Math.Sqrt(_builtInRandom.NextDouble() * 10000) ;
}
Console.WriteLine("Square root : " + (_stopWatch.ElapsedMilliseconds - startTime) );
// Square root : 60ms(debug server) / 30ms( live server)


This is true for most calculations (Math functions, generating randoms etc), they are all consistently faster.


However there is one area where the live server seems inexplicably slower than my own computer(debug server):
Code: Select all
long startTime = _stopWatch.ElapsedMilliseconds;
for (int c = 0; c < 12000; ++c)
{
List<Object> tilesArray2 = new List<Object>();
     for (int k = 0; k <= 40; ++k)
    {
    tilesArray2.Add(new Object());
    }
}
Console.WriteLine("Listmanipulation : " + (_stopWatch.ElapsedMilliseconds - startTime) );
// List manipulation : 50ms(debug server) / 120ms(live server)


- also the range of the live server varies quite wildly, from 30 to 300ms(!), but averages around 120ms, which is about 240% slower.

What is really odd is the inconsistency, as I said in all other areas the Server seems to outperform the debug server / home CPU, so it would logically follow that if everything was working properly, this should be faster too. Which is why I think that this a bug?
whitershores
Paid Member
 
Posts: 88
Joined: June 21st, 2011, 4:19 pm

Re: Server Performance Bug?

Postby dreamora » July 19th, 2012, 3:34 pm

Thats up to a given point to expect.
Don't forget that .NET pools memory for fast reuse.

In case of your dev server only a single instance of your server runs in the .NET environment, so the whole amount of pooled objects is at your disposal.
But on the live server there are dozens, potentially even hundreds of rooms exist beside yours are running which might eat up the pooled memory you try to allocate there.

The only way I could think of to 'even out' the field even the slightest bit would likely be heavy manual GC firing.

Also we don't know what backend technology they use.
With black and whitelisting of namespaces, I don't think we can even assume that its MS.NET. Could just as well be Mono 2.10 in which case the deltas there would be absolutely expectable because MS.NET 4 can parallelize the two nested loops, while mono can't
dreamora
 
Posts: 225
Joined: March 2nd, 2012, 9:58 am


Return to C#



cron