Decrease initial size of symbol cache hash table

Using 2^23 allocates 128MB memory for the hash table. Seems like
a waste of memory, especially for small scripts.

For example, I didn't notice a huge difference in time between 1000
and the old number when compiling most of YSI includes and tests.
Hash tables double in size when they need more space, it's pretty
efficient (at least this implementation does so).
This commit is contained in:
Zeex 2018-01-06 10:13:04 +06:00
parent c4e15a032a
commit 6d65605bb0

View File

@ -903,54 +903,54 @@ static void initglobals(void)
{ {
resetglobals(); resetglobals();
sc_asmfile=FALSE; /* do not create .ASM file */ sc_asmfile=FALSE; /* do not create .ASM file */
sc_listing=FALSE; /* do not create .LST file */ sc_listing=FALSE; /* do not create .LST file */
skipinput=0; /* number of lines to skip from the first input file */ skipinput=0; /* number of lines to skip from the first input file */
sc_ctrlchar=CTRL_CHAR;/* the escape character */ sc_ctrlchar=CTRL_CHAR; /* the escape character */
litmax=sDEF_LITMAX; /* current size of the literal table */ litmax=sDEF_LITMAX; /* current size of the literal table */
errnum=0; /* number of errors */ errnum=0; /* number of errors */
warnnum=0; /* number of warnings */ warnnum=0; /* number of warnings */
optproccall=TRUE; /* support "procedure call" */ optproccall=TRUE; /* support "procedure call" */
verbosity=1; /* verbosity level, no copyright banner */ verbosity=1; /* verbosity level, no copyright banner */
sc_debug=sCHKBOUNDS; /* by default: bounds checking+assertions */ sc_debug=sCHKBOUNDS; /* by default: bounds checking+assertions */
pc_optimize=sOPTIMIZE_NOMACRO; pc_optimize=sOPTIMIZE_NOMACRO;
sc_packstr=FALSE; /* strings are unpacked by default */ sc_packstr=FALSE; /* strings are unpacked by default */
#if AMX_COMPACTMARGIN > 2 #if AMX_COMPACTMARGIN > 2
sc_compress=TRUE; /* compress output bytecodes */ sc_compress=TRUE; /* compress output bytecodes */
#else #else
sc_compress=FALSE; sc_compress=FALSE;
#endif #endif
sc_needsemicolon=FALSE;/* semicolon required to terminate expressions? */ sc_needsemicolon=FALSE; /* semicolon required to terminate expressions? */
sc_dataalign=sizeof(cell); sc_dataalign=sizeof(cell);
pc_stksize=sDEF_AMXSTACK;/* default stack size */ pc_stksize=sDEF_AMXSTACK; /* default stack size */
pc_amxlimit=0; /* no limit on size of the abstract machine */ pc_amxlimit=0; /* no limit on size of the abstract machine */
pc_amxram=0; /* no limit on data size of the abstract machine */ pc_amxram=0; /* no limit on data size of the abstract machine */
sc_tabsize=8; /* assume a TAB is 8 spaces */ sc_tabsize=8; /* assume a TAB is 8 spaces */
sc_rationaltag=0; /* assume no support for rational numbers */ sc_rationaltag=0; /* assume no support for rational numbers */
rational_digits=0; /* number of fractional digits */ rational_digits=0; /* number of fractional digits */
outfname[0]='\0'; /* output file name */ outfname[0]='\0'; /* output file name */
errfname[0]='\0'; /* error file name */ errfname[0]='\0'; /* error file name */
inpf=NULL; /* file read from */ inpf=NULL; /* file read from */
inpfname=NULL; /* pointer to name of the file currently read from */ inpfname=NULL; /* pointer to name of the file currently read from */
outf=NULL; /* file written to */ outf=NULL; /* file written to */
litq=NULL; /* the literal queue */ litq=NULL; /* the literal queue */
glbtab.next=NULL; /* clear global variables/constants table */ glbtab.next=NULL; /* clear global variables/constants table */
loctab.next=NULL; /* " local " / " " */ loctab.next=NULL; /* " local " / " " */
hashmap_init(&symbol_cache_map,hashmap_hash_string,hashmap_compare_string,8388608); /* 2^23 */ hashmap_init(&symbol_cache_map,hashmap_hash_string,hashmap_compare_string,10000);
tagname_tab.next=NULL;/* tagname table */ tagname_tab.next=NULL; /* tagname table */
libname_tab.next=NULL;/* library table (#pragma library "..." syntax) */ libname_tab.next=NULL; /* library table (#pragma library "..." syntax) */
pline[0]='\0'; /* the line read from the input file */ pline[0]='\0'; /* the line read from the input file */
lptr=NULL; /* points to the current position in "pline" */ lptr=NULL; /* points to the current position in "pline" */
curlibrary=NULL; /* current library */ curlibrary=NULL; /* current library */
inpf_org=NULL; /* main source file */ inpf_org=NULL; /* main source file */
wqptr=wq; /* initialize while queue pointer */ wqptr=wq; /* initialize while queue pointer */
#if !defined SC_LIGHT #if !defined SC_LIGHT
sc_documentation=NULL; sc_documentation=NULL;
sc_makereport=FALSE; /* do not generate a cross-reference report */ sc_makereport=FALSE; /* do not generate a cross-reference report */
#endif #endif
} }