optimize edje_cc - now betwene 3.5 x and 4x as fast. new options

(-fastcomp and -fastdecomp) -fastcomp makes for faster decompressing
AND faster compressing of edj files, -fastdecomp is a bit slower on
compression but also as fast as -fastcomp in decompression. note that
edje files built with these optiosn will not work on older edje
installations, thus they are options.



SVN revision: 71112
This commit is contained in:
Carsten Haitzler 2012-05-15 12:29:22 +00:00
parent 6d8004a29d
commit efca59d04f
7 changed files with 1109 additions and 724 deletions

View File

@ -448,3 +448,12 @@
2012-05-14 Cedric Bail
* Preserve drag informations during call of edje_object_file_set.
2012-05-15 Carsten Haitzler (The Rasterman)
* Optimize edje_cc to be multi-threaded and compress in parallel
* Remove O(n2) algorithms for O(1) in the parser in edje_cc
* Add options for the new compression modes in Eet. (fastcomp
and fastdecomp - LZ4 and LZ4HC).
* Overall sped up edje_cc by 4x faster (if you use fastcomp)
and about 4.5x faster with old zlib compression.

View File

@ -29,6 +29,7 @@ int no_raw = 0;
int no_save = 0;
int min_quality = 0;
int max_quality = 100;
int compress_mode = EET_COMPRESSION_DEFAULT;
static void
main_help(void)
@ -52,6 +53,8 @@ main_help(void)
"-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n"
"-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n"
"-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n"
"-fastcomp Use a faster compression algorithm (LZ4) (mutually exclusive with -fastdecomp)\n"
"-fastdecomp Use a faster decompression algorithm (LZ4HC) (mutually exclusive with -fastcomp)\n"
,progname);
}
@ -144,6 +147,14 @@ main(int argc, char **argv)
if (max_quality < 0) max_quality = 0;
if (max_quality > 100) max_quality = 100;
}
else if ((!strcmp(argv[i], "-fastcomp")) && (i < (argc - 1)))
{
compress_mode = EET_COMPRESSION_SUPERFAST;
}
else if ((!strcmp(argv[i], "-fastdecomp")) && (i < (argc - 1)))
{
compress_mode = EET_COMPRESSION_VERYFAST;
}
else if (!strncmp(argv[i], "-D", 2))
{
defines = eina_list_append(defines, mem_strdup(argv[i]));

View File

@ -227,6 +227,6 @@ extern Eina_List *defines;
extern Eina_List *aliases;
extern New_Object_Handler object_handlers[];
extern New_Statement_Handler statement_handlers[];
extern int compress_mode;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -119,44 +119,57 @@ err_show(void)
err_show_params();
}
static Eina_Hash *_new_object_hash = NULL;
static Eina_Hash *_new_statement_hash = NULL;
static void
fill_object_statement_hashes(void)
{
int i, n;
if (_new_object_hash) return;
_new_object_hash = eina_hash_string_superfast_new(NULL);
_new_statement_hash = eina_hash_string_superfast_new(NULL);
n = object_handler_num();
for (i = 0; i < n; i++)
{
eina_hash_add(_new_object_hash, object_handlers[i].type,
&(object_handlers[i]));
}
n = statement_handler_num();
for (i = 0; i < n; i++)
{
eina_hash_add(_new_statement_hash, statement_handlers[i].type,
&(statement_handlers[i]));
}
}
static void
new_object(void)
{
char *id;
int i;
int handled = 0;
New_Object_Handler *oh;
New_Statement_Handler *sh;
fill_object_statement_hashes();
id = stack_id();
for (i = 0; i < object_handler_num(); i++)
oh = eina_hash_find(_new_object_hash, id);
if (oh)
{
if (!strcmp(object_handlers[i].type, id))
{
handled = 1;
if (object_handlers[i].func)
{
object_handlers[i].func();
}
break;
}
if (oh->func) oh->func();
}
if (!handled)
else
{
for (i = 0; i < statement_handler_num(); i++)
{
if (!strcmp(statement_handlers[i].type, id))
{
free(id);
return;
}
}
}
if (!handled)
{
ERR("%s: Error. %s:%i unhandled keyword %s",
progname, file_in, line - 1,
(char *)eina_list_data_get(eina_list_last(stack)));
err_show();
exit(-1);
sh = eina_hash_find(_new_statement_hash, id);
if (!sh)
{
ERR("%s: Error. %s:%i unhandled keyword %s",
progname, file_in, line - 1,
(char *)eina_list_data_get(eina_list_last(stack)));
err_show();
exit(-1);
}
}
free(id);
}
@ -165,29 +178,22 @@ static void
new_statement(void)
{
char *id;
int i;
int handled = 0;
New_Statement_Handler *sh;
fill_object_statement_hashes();
id = stack_id();
for (i = 0; i < statement_handler_num(); i++)
sh = eina_hash_find(_new_statement_hash, id);
if (sh)
{
if (!strcmp(statement_handlers[i].type, id))
{
handled = 1;
if (statement_handlers[i].func)
{
statement_handlers[i].func();
}
break;
}
if (sh->func) sh->func();
}
if (!handled)
else
{
ERR("%s: Error. %s:%i unhandled keyword %s",
progname, file_in, line - 1,
(char *)eina_list_data_get(eina_list_last(stack)));
ERR("%s: Error. %s:%i unhandled keyword %s",
progname, file_in, line - 1,
(char *)eina_list_data_get(eina_list_last(stack)));
err_show();
exit(-1);
exit(-1);
}
free(id);
}

View File

@ -228,7 +228,8 @@ source_fetch(void)
int
source_append(Eet_File *ef)
{
return eet_data_write(ef, _srcfile_list_edd, "edje_sources", &srcfiles, 1);
return eet_data_write(ef, _srcfile_list_edd, "edje_sources", &srcfiles,
compress_mode);
}
SrcFile_List *
@ -246,7 +247,8 @@ source_fontmap_save(Eet_File *ef, Eina_List *font_list)
Font_List fl;
fl.list = font_list;
return eet_data_write(ef, _font_list_edd, "edje_source_fontmap", &fl, 1);
return eet_data_write(ef, _font_list_edd, "edje_source_fontmap", &fl,
compress_mode);
}
Font_List *

View File

@ -22,6 +22,7 @@ int _edje_cc_log_dom = -1;
char *progname = NULL;
char *file_in = NULL;
char *file_out = NULL;
int compress_mode = EET_COMPRESSION_DEFAULT;
Edje_File *edje_file = NULL;
SrcFile_List *srcfiles = NULL;