[15:06:52] [15:06:52] ======================================= [15:06:52] | | [15:06:52] | YSI version 4.00.0001 | [15:06:52] | By Alex "******" Cole | [15:06:52] | | [15:06:52] ======================================= [15:06:52] [15:17:44] *** YSI Warning: y_malloc set up via "CallLocalFunction", memory corruption is a remote possibility
Originally Posted by ******
PHP код:
|
ParentFunction()
{
inline ChildFunction()
{
}
FunctionToCallInline
}
1 Yes. As far as I know inline works only on a structure like
PHP код:
|
Hello.
When I run my server, it took about 10 mins to load YSI. Local or hosted, it's the same thing. Why? How can I avoid this waiting time? Код:
[15:06:52] [15:06:52] ======================================= [15:06:52] | | [15:06:52] | YSI version 4.00.0001 | [15:06:52] | By Alex "******" Cole | [15:06:52] | | [15:06:52] ======================================= [15:06:52] [15:17:44] *** YSI Warning: y_malloc set up via "CallLocalFunction", memory corruption is a remote possibility CallLocalFunction("OnGameModeExit", ""); ? |
11 minutes?! That's insane. Can you try for me compiling an empty project, only including <YSI\y_text>?
(and see how long does the loading take then) |
---------- Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3.7-R2, ©2005-2015 SA-MP Team [16:12:47] filterscripts = "" (string) [16:12:47] [16:12:47] Server Plugins [16:12:47] -------------- [16:12:47] Loading plugin: sscanf [16:12:47] [16:12:47] =============================== [16:12:47] sscanf plugin loaded. [16:12:47] Version: 2.8.2 [16:12:47] © 2012 Alex "******" Cole [16:12:47] =============================== [16:12:47] Loaded. [16:12:47] Loading plugin: mysql [16:12:47] >> plugin.mysql: R41-4 successfully loaded. [16:12:47] Loaded. [16:12:47] Loaded 2 plugins. [16:12:47] [16:12:47] Filterscripts [16:12:47] --------------- [16:12:47] Loaded 0 filterscripts. [16:12:47] [16:12:47] [16:12:47] [16:12:47] ======================================= [16:12:47] | | [16:12:47] | YSI version 4.00.0001 | [16:12:47] | By Alex "******" Cole | [16:12:47] | | [16:12:47] ======================================= [16:12:47] [16:12:49] *** YSI Error: No languages found - Did you add "Langs_AddLanguage" to the script init (NOT "main")? [16:12:49] main() [16:12:49] Number of vehicle models: 0
I have never seen it take that long, even with full debugging enabled, which hugely reduces load times. What machine are you running on, and how big is your compiled code size?
|
Header size: 19320 bytes Code size: 9205372 bytes Data size: 9758740 bytes Stack/heap size: 16827216 bytes; estimated max. usage=9898 cells (39592 bytes) Total requirements:35810648 bytes
No one mentioned y_hooks there... Also why are you manually calling `OnGameModeInit` like that? That's bound to cause issues!
|
#include <a_samp> // #include <a_mysql> #include <a_http> #include <fixes> #include <crashdetect> #include <streamer> #include <sscanf2> #include <mSelection> #define _DEBUG 7 #define DYNAMIC_MEMORY 12500 #include <YSI\YSI\y_va> #include <YSI\YSI\y_inline> #include <YSF> // #include <YSI\YSI\y_iterate> // not yet #include <a_mysql_yinline> #include <geolocation>
[18:56:56] [18:56:56] ======================================= [18:56:56] | | [18:56:56] | YSI version 4.00.0001 | [18:56:56] | By Alex "******" Cole | [18:56:56] | | [18:56:56] ======================================= [18:56:56] [18:56:57] YVA2_FoundPush: 4 [18:56:57] YVA2_FoundPush: 4 [18:56:57] YVA2_FoundPush: 88 [18:56:57] YVA2_FoundPush: 4 [18:56:57] YVA2_FoundPush: 4 [18:56:57] YVA2_FoundPush: 4 [18:57:05] YVA2_FoundPush: 1156 [19:07:47] Malloc_OnScriptInit called [19:07:47] AMX_Read called: -9218732 -20 [19:07:47] AMX_RawRead called: -9218732 [19:07:47] AMX_Read called: -9213180 -20 [19:07:47] AMX_RawRead called: -9213180 [19:07:47] AMX_Write called: -9119108, 134 [19:07:47] AMX_Write called: -9119104, 134 [19:07:47] AMX_Write called: -9058168, 134 [19:07:47] AMX_Write called: -9058164, 134 [19:07:47] AMX_Write called: -9058036, 134 [19:07:47] AMX_Write called: -9058032, 134 [19:07:47] AMX_Write called: -9057080, 134 [19:07:47] AMX_Write called: -9057076, 134 [19:07:47] AMX_Write called: -9056752, 134 [19:07:47] AMX_Write called: -9056748, 134 [19:07:47] AMX_Write called: -9056572, 134 [19:07:47] AMX_Write called: -9056568, 134 [19:07:47] AMX_Write called: -9056484, 134 [19:07:47] AMX_Write called: -9056480, 134 [19:07:47] AMX_Write called: -9056304, 134 [19:07:47] AMX_Write called: -9056300, 134 [19:07:47] AMX_Write called: -9056120, 134 [19:07:47] AMX_Write called: -9056116, 134 [19:07:47] AMX_Write called: -9056024, 134 [19:07:47] AMX_Write called: -9056020, 134 [19:07:47] AMX_Write called: -9055780, 134 [19:07:47] AMX_Write called: -9055776, 134 [19:07:47] AMX_Write called: -9055704, 134 [19:07:47] AMX_Write called: -9055700, 134 [19:07:47] AMX_Write called: -9055616, 134 [19:07:47] AMX_Write called: -9055612, 134 [19:07:47] AMX_Write called: -9055376, 134 [19:07:47] AMX_Write called: -9055372, 134 [19:07:47] AMX_Write called: -9055084, 134 [19:07:47] AMX_Write called: -9055080, 134 [19:07:47] AMX_Write called: -9054900, 134 [19:07:47] AMX_Write called: -9054896, 134 [19:07:47] AMX_Write called: -9054696, 134 [19:07:47] AMX_Write called: -9054692, 134 [19:07:47] AMX_Write called: -9054592, 134 [19:07:47] AMX_Write called: -9054588, 134 [19:07:47] AMX_Write called: -9054516, 134 [19:07:47] AMX_Write called: -9054512, 134 [19:07:47] AMX_Write called: -9054348, 134 [19:07:47] AMX_Write called: -9054344, 134 [19:07:47] AMX_Write called: -9054280, 134 [19:07:47] AMX_Write called: -9054276, 134 [19:07:47] AMX_Write called: -9054180, 134 [19:07:47] AMX_Write called: -9054176, 134 [19:07:47] AMX_Write called: -9054132, 134 [19:07:47] AMX_Write called: -9054128, 134 [19:07:47] AMX_Write called: -9054056, 134 [19:07:47] AMX_Write called: -9054052, 134 [19:07:47] AMX_Write called: -9053960, 134 [19:07:47] AMX_Write called: -9053956, 134 [19:07:47] AMX_Write called: -9053808, 134 [19:07:47] AMX_Write called: -9053804, 134 [19:07:47] AMX_Write called: -9053704, 134 [19:07:47] AMX_Write called: -9053700, 134 [19:07:47] AMX_Write called: -9053632, 134 [19:07:47] AMX_Write called: -9053628, 134 [19:07:47] AMX_Write called: -9053528, 134 [19:07:47] AMX_Write called: -9053524, 134 [19:07:47] AMX_Write called: -8909128, 134 [19:07:47] AMX_Write called: -8909124, 134 [19:07:47] AMX_Write called: -8908988, 134 [19:07:47] AMX_Write called: -8908984, 134 [19:07:47] AMX_Write called: -2309900, 134 [19:07:47] AMX_Write called: -2309896, 134 [19:07:47] AMX_Write called: -2308744, 134 [19:07:47] AMX_Write called: -2308740, 134 [19:07:47] Malloc_TrySetup called [19:07:47] *** YSI Warning: y_malloc set up via "CallLocalFunction", memory corruption is a remote possibility [19:07:47] Malloc_OnScriptInit: 9763716 16777216 9763716 [19:07:47] Malloc_OnScriptInit: AMX_HEADER_HEA = 9763716, YSI_gMallocMemory = 395020, YSI_g_sHeapStart = 2342174 [19:07:47] Malloc_OnScriptInit: YSI_gMallocMemory + 4 * YSI_g_sHeapStart = 9763716 [19:08:16] [boot] OnGameModeInit launched !
Alright, finally some progress. Now comment out parts of OPCT until you find the offender
|
But not 11 minutes! One of the humongous gamemodes I worked on was 200k lines and took like 30 seconds to load
|
Commands will make no difference to startup - they aren't run then. And you can't optimise without profiling first, how will you know what is slow?
|
Edit: Nope...
Edit 2: 57% of that execution is spent in this function: https://github.com/Zeex/amx_assembly....inc#L243-L277 I can see why it would be so slow - it runs all that code for almost every cell in your code, multiple times! I mean the code was never designed for speed, since it is only run once at startup. I've never been too concerned with startup times, only live execution times, so if there is ever a way to speed up execution at the cost of startup, I will always take it (unless the code is very complex). In this case, however, I might have to rethink. Expecially code that is not too well written - large functions with high cyclomatic complexity will not treat that function well. |
Unfortunately, that's currently the gist of it, yes. I am looking in to making that function faster, but it needs a serious think. Maybe I should do something like this (which I considered last time, but believed was too much effort for the payoff): https://en.wikipedia.org/wiki/Knuth%...ratt_algorithm
Edit: I started looking at the jump targets code, trying to speed it up with a binary search or something else. Then I realised it was TOTALLY unneeded! Even without it, the code will still report the correct stack in 99.999% of cases, and the other cases would be ambiguous even in the server VM anyway, so may as well go with the other version of that ambiguity and report it semi accurate always. So I just deleted all the code dealing with jump targets entirely! |
mysql_format(database, query, sizeof(query), "SELECT * FROM `gtrp_factions_ranks` WHERE `FactionSQLID` = %i ORDER BY `gtrp_factions_ranks`.`Rank` ASC", j);
inline OnRanksLoading(factionID)
{
J::D("Inside inline: %s", FactionInfo[j][fName], j);
new temporary,
num_ranks = cache_num_rows();
if(!num_ranks)
{
CreateRanksForFactions(factionID);
return J::D("No ranks loaded for %s. They have been created.", GetFactionName(factionID));
}
for(new k; k != num_ranks; k++)
{
cache_get_value_int(k, "Rank", temporary);
cache_get_value(k, "RankName", f_RankName[factionID][temporary], MAX_FAC_RANK_NAME);
J::D("Rank %i (%s) loaded for %s", temporary, f_RankName[factionID][temporary], GetFactionName(factionID));
}
}
J::D("Faction \"%s\" (id: %i) loaded | Loading ranks 2.0", FactionInfo[j][fName], j);
mysql_pquery_inline(database, query, using inline OnRanksLoading, "i", j);