So, after doing some profiling on the timer plugin we use (Zipcore's), I have found out that two functions are slowing down the server a lot.
By a lot, I mean ~690µs/player, 5 times per second, causing the server to have svms spikes up to 100.
These two are:
1st:
PHP Code:
public Native_GetBestRound(Handle:plugin, numParams)
{
new client = GetNativeCell(1);
new style = GetNativeCell(2);
new track = GetNativeCell(3);
decl String:auth[32];
GetClientAuthString(client, auth, sizeof(auth));
if(GetArraySize(g_hCache[style][track]) <= 0)
return false;
for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++)
{
new nCache[RecordCache];
GetArrayArray(g_hCache[style][track], i, nCache[0]);
if (StrEqual(nCache[Auth], auth))
{
SetNativeCellRef(4, nCache[Time]);
SetNativeCellRef(5, nCache[Jumps]);
return true;
}
}
return false;
}
2nd:
PHP Code:
public Native_GetStyleRank(Handle:plugin, numParams)
{
new client = GetNativeCell(1);
new track = GetNativeCell(2);
new style = GetNativeCell(3);
decl String:auth[32];
GetClientAuthString(client, auth, sizeof(auth));
for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++)
{
new nCache[RecordCache];
GetArrayArray(g_hCache[style][track], i, nCache[0]);
if (StrEqual(nCache[Auth], auth))
return i+1;
}
return 0;
}
</span>My suspicion is that the GetArrayArray and String-comparison takes a long time.
Is there a way to optimize them somehow? Or do I have to cache their values somhow (altough this will again cause lags when calling them..
Any help is appreciated!
__________________
Stopped hosting servers as of November 2018, no longer active around here.