25.07.2014, 09:35
Very good work.Keep up the good work Incognito.
for( new i = 0; i < 10000; i ++ )
{
SetGVarString( "HugeMessageForShowOff", gsBigString, i );
printf( "%d", i );
}
for( new i = 0; i < 10000; i ++ )
{
SetGVarString( "HugeMessageForShowOff", gsBigString, i );
printf( "%d", i );
}
[11/01/2015 23:36:57] [debug] Run time error 7: "Stack underflow"
[11/01/2015 23:36:57] [debug] Stack pointer (STK) is 0x4076BC, stack top (STP) is 0x4076BC
[11/01/2015 23:36:57] [debug] AMX backtrace:
[11/01/2015 23:36:57] [debug] Run time error 7: "Stack underflow"
[11/01/2015 23:36:57] [debug] Stack pointer (STK) is 0x4076BC, stack top (STP) is 0x4076BC
[11/01/2015 23:36:57] [debug] AMX backtrace:
[11/01/2015 23:36:57] [debug] Run time error 7: "Stack underflow"
[11/01/2015 23:36:57] [debug] Stack pointer (STK) is 0x4076BC, stack top (STP) is 0x4076BC
[11/01/2015 23:36:57] [debug] AMX backtrace:
[11/01/2015 23:36:57] [debug] Run time error 7: "Stack underflow"
[11/01/2015 23:36:57] [debug] Stack pointer (STK) is 0x4076BC, stack top (STP) is 0x4076BC
[11/01/2015 23:36:57] [debug] AMX backtrace:
[11/01/2015 23:36:57] [sampgdk] error: Too many callback arguments (at most 32 allowed)
[11/01/2015 23:36:57] [debug] Run time error 7: "Stack underflow"
[11/01/2015 23:36:57] [debug] Stack pointer (STK) is 0x4076BC, stack top (STP) is 0x4076BC
[11/01/2015 23:36:57] [debug] AMX backtrace:
[11/01/2015 23:36:57] [sampgdk] error: Too many callback arguments (at most 32 allowed)
SetTimerEx( "WorkTimer", 2_000, 0, "i", 0 ); // OnFilterScriptInit
forward WorkTimer( number );
public WorkTimer( number )
{
for( new i = number; i < number+10000; i ++ )
{
SetGVarString( "HugeMessageForShowOff", gsBigString, i );
printf( "%d", i );
}
number = number+10000;
SetTimerEx( "WorkTimer", 2_000, 0, "i", number );
return 1;
}
[11/01/2015 23:52:15] [debug] Server crashed while executing maps.amx
[11/01/2015 23:52:15] [debug] AMX backtrace:
[debug] #0 native SetGVarString () from gvar.DLL
[debug] #1 000018ec in public WorkTimer (0x00035b60) from maps.amx
[11/01/2015 23:52:15] [debug] // no information being printed at this debug
Firstly: I know that this looks really really stupid, but I needed to test this plugin under really heavy stress (lots of huge string writing per second), because I have a thing in my mind to script in the future which uses this plugin a lot (SetGVarString), and I want to be sure it handles lots of messages being written in memory.
Code: pawn Код:
When I first "loadfs" in console, it writes fine in memory (verified using task manager), but after few more "reloadfs", it takes only few more kilobytes/megabytes (which is ok), but after ~10 "reloadfs" it starts giving these: pawn Код:
(if I use just one big loop with that gsBigString, it starts giving errors after a few thousands, but at ~90000 (maximum at 99999) it crashes the server) When I tried it with a timer: pawn Код:
pawn Код:
I want to know if this can be solved, or if I should stay at testing it less agressive. |
Notes
|
if (GetGVarInt("g_MySQLcon") == 1)
return 0;
native SetGVarInt(const name[], value, id = 0);
native SetGVarInt(const name[], value, id = 0, id2 = 0);
format( gsString, 64, "HouseItemBuyPrice%d", houseid );
SetGVarInt( gsString, 10000, itemid );
SetGVarInt( "HouseItemBuyPrice", 10000, houseid, itemid );
public OnFilterScriptInit( )
{
new liTick;
#define ITERS 1000000
//============================[ Set Int ]===================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetGVarInt( "TestSI", 69 );
printf( "INT: Set: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetSVarInt( "TestSI", 69 );
printf( "INT: Set: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//============================[ Get Int ]===================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetGVarInt( "TestGI" );
printf( "INT: Get: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetSVarInt( "TestGI" );
printf( "INT: Get: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Set Float ]==================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetGVarFloat( "TestSF", 69.00 );
printf( "FLOAT: Set: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetSVarFloat( "TestSF", 69.00 );
printf( "FLOAT: Set: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Get Float ]==================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetGVarFloat( "TestGF" );
printf( "FLOAT: Get: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetSVarFloat( "TestGF" );
printf( "FLOAT: Get: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Set String ]=================================
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetGVarString( "TestSS", "Sixty Nine" );
printf( "STRING: Set: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
SetSVarString( "TestSS", "Sixty Nine" );
printf( "STRING: Set: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
//===========================[ Get String ]=================================
new lsString[ 16 ];
// GVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetGVarString( "TestGS", lsString, 16 );
printf( "STRING: Get: GVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
// SVar
liTick = GetTickCount( );
for( new i = 0; i < ITERS; i ++ )
GetSVarString( "TestGS", lsString, 16 );
printf( "STRING: Get: SVar speed for %d iterations: %dms", ITERS, GetTickCount( ) - liTick );
return 1;
}
INT: Set: GVar speed for 1000000 iterations: 237ms INT: Set: SVar speed for 1000000 iterations: 170ms INT: Get: GVar speed for 1000000 iterations: 234ms INT: Get: SVar speed for 1000000 iterations: 162ms FLOAT: Set: GVar speed for 1000000 iterations: 229ms FLOAT: Set: SVar speed for 1000000 iterations: 179ms FLOAT: Get: GVar speed for 1000000 iterations: 218ms FLOAT: Get: SVar speed for 1000000 iterations: 167ms STRING: Set: GVar speed for 1000000 iterations: 309ms STRING: Set: SVar speed for 1000000 iterations: 344ms STRING: Get: GVar speed for 1000000 iterations: 223ms STRING: Get: SVar speed for 1000000 iterations: 175ms |
Code used:
pawn Код:
So SVars are slower only at setting strings. |
new names[100000][16];
for (new i = 0; i < 100000; i++)
{
format(names[i], sizeof(names[]), "name_%d", i);
}
new time = GetTickCount();
for (new i = 0; i < 100000; i++)
{
SetGVarInt(names[i], i);
}
printf("Time #1: %d", GetTickCount() - time);
time = GetTickCount();
for (new i = 0; i < 100000; i++)
{
GetGVarInt(names[i]);
}
printf("Time #2: %d", GetTickCount() - time);
[19:03:10] Time #1: 54 [19:03:10] Time #2: 35
new time = GetTickCount();
for (new i = 0; i < 100000; i++)
{
SetSVarInt(names[i], i);
}
printf("Time #1: %d", GetTickCount() - time);
time = GetTickCount();
for (new i = 0; i < 100000; i++)
{
GetSVarInt(names[i], i);
}
printf("Time #2: %d", GetTickCount() - time);
[19:04:05] Time #1: 1089 [19:04:06] Time #2: 1004
I've only tested integers, but here's what I got by allocating 100,000 unique elements:
|
#include <a_samp>
main()
{
static const svar_name_prefix[] = "svar";
new svar_name[sizeof(svar_name_prefix) + 11];
svar_name = svar_name_prefix;
for (new i = 0; i < cellmax; ++i)
{
valstr(svar_name[4], i);
new result = SetSVarInt(svar_name, i);
printf("SVar: %s | Value: %d", svar_name, GetSVarInt(svar_name));
if (0 == result)
{
printf("SVars limit: %d", i);
break;
}
}
}
SVar: 0 | Value: 0 SVar: 1 | Value: 1 ... SVar: 1999 | Value: 1999 SVar: 2000 | Value: 0 SVars limit: 2000