lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Paige DePol once stated:
> 
> For embedded systems the parser/lexer could just be left out, obviously this
> would require all necessary Lua code be pre-compiled (another good reason
> for adding cross-platform bytecode genereration to 'luac' in my opinion). I
> was also wondering if people who embed Lua precompile the source or not?

  I finally have some time, so I thought I might check the sizes of Lua
source code, compressed Lua source code [1], compiled Lua code and
compressed compiled Lua code, for both 32 bit and 64 bit systems (and yes,
there is a difference in compiled Lua sizes).  I used LuaRocks beacuse it
was
	a) handy
	b) a good mix of module sizes
	c) all in Lua.

  Attached is the full output from a 32-bit run and a 64-bit run, but let's
look at a small sample of the output.

  Here we have sizes from a 32-bit system.

text	ztext	bin	zbin	filename
-----------------------------------------
 4167	 1479	 6107	 2647	add.lua
 3267	 1207	 4830	 2137	admin_remove.lua
15750	 4229	17277	 6352	build.lua
11312	 2888	15600	 5552	builtin.lua
 2178	  886	 2637	 1196	cmake.lua
  932	  389	 1023	  487	command.lua

  You can see that the compiled versions are larger than the text.  And the
same holds true for the compressed versions.  Next up, results from a 64-bit
test:

text	ztext	bin	zbin	filename
-----------------------------------------
 4167	 1479	 6723	 2669	add.lua
 3267	 1207	 5322	 2163	admin_remove.lua
15750	 4229	18889	 6442	build.lua
11312	 2888	17416	 5638	builtin.lua
 2178	  886	 2917	 1211	cmake.lua
  932	  389	 1123	  495	command.lua

  Again, similar results, only the 64-bit compiled versions are larger than
the 32-bit compiled versions.  The trick here is to determine if the size
savings of compression are worth the extra cost of zlib support.  There's
also the question of whether the reduction in Lua size of removing the
parser is worth the larger size of pre-compiled Lua code.

  -spc (Trade-offs, trade-offs)

[1]	Using zlib (lzlib module for Lua) with maximum compression.  I used
	maximum compression because I figure take the hit on time for
	compression on more powerful machines to save space on less powerful
	machines one might embed Lua in.
text	ztext	bin	zbin	filename
-----------------------------------------
 4167	 1479	 6107	 2647	add.lua
 3267	 1207	 4830	 2137	admin_remove.lua
15750	 4229	17277	 6352	build.lua
11312	 2888	15600	 5552	builtin.lua
 2178	  886	 2637	 1196	cmake.lua
  932	  389	 1023	  487	command.lua
 3417	 1141	 3357	 1337	make.lua
 2858	  894	 3738	 1571	cache.lua
24477	 6885	25939	 9963	cfg.lua
 7108	 2440	 9249	 3903	command_line.lua
 1973	  745	 2677	 1212	config_cmd.lua
28517	 7227	25819	 9141	deps.lua
 2570	  957	 2208	  857	dir.lua
 5059	 1586	 7219	 3013	doc.lua
 3409	 1202	 4281	 1884	download.lua
15275	 3871	15081	 5314	fetch.lua
 1832	  755	 2171	 1007	cvs.lua
 3570	 1392	 3880	 1680	git.lua
  792	  403	  588	  324	git_file.lua
 1143	  571	  597	  326	git_http.lua
  357	  219	  198	  134	git_https.lua
 1382	  650	  763	  391	git_ssh.lua
 2098	  833	 2474	 1105	hg.lua
 1004	  510	  575	  317	hg_http.lua
  346	  216	  196	  134	hg_https.lua
  340	  215	  194	  136	hg_ssh.lua
 1840	  830	 1999	  982	sscm.lua
 2140	  847	 2725	 1239	svn.lua
 2139	  869	 3272	 1404	fs.lua
28208	 7156	30616	10290	lua.lua
 5310	 1869	 6169	 2422	tools.lua
 4697	 1661	 4924	 2048	unix.lua
 7808	 2258	 9341	 3175	tools.lua
 9289	 3063	 9954	 3641	win32.lua
 7615	 2160	 8347	 2751	tools.lua
 4593	 1660	 5825	 2437	help.lua
 5492	 1976	 7468	 3260	index.lua
 7272	 1967	 8235	 2939	install.lua
 1527	  694	 1737	  884	lint.lua
 3323	 1078	 4498	 1882	list.lua
 9690	 2992	 7972	 3024	loader.lua
 3831	 1436	 4392	 1944	make.lua
 1871	  754	 2383	 1117	make_manifest.lua
24069	 5285	25293	 7852	manif.lua
 4153	 1283	 3603	 1375	manif_core.lua
 6292	 1964	 7052	 2960	new_version.lua
 7043	 2101	 8466	 3271	pack.lua
14996	 3091	15816	 3837	path.lua
 2268	  762	 2677	 1101	path_cmd.lua
 6883	 2014	 6275	 2559	persist.lua
 2614	  966	 3821	 1700	purge.lua
 1061	  452	 1388	  716	refresh_cache.lua
 6594	 2026	 8136	 3195	remove.lua
17202	 4044	19286	 5928	repos.lua
  108	   92	  182	  123	require.lua
18429	 4609	18559	 6303	search.lua
 5636	 1726	 7906	 3090	show.lua
  492	  213	  630	  349	site_config.lua
22010	 5650	23476	 8374	patch.lua
 4804	 1420	 6588	 2485	tar.lua
 8683	 2114	 9252	 3017	zip.lua
11511	 2891	 8778	 3470	type_check.lua
 6135	 1758	 6459	 2487	unpack.lua
 3014	 1057	 3944	 1828	upload.lua
 8674	 2577	12772	 5115	api.lua
 2800	 1052	 4562	 1963	multipart.lua
23374	 7126	22830	 8546	util.lua
 4622	 1310	 7288	 2707	validate.lua
12284	 3664	16503	 6592	write_rockspec.lua
text	ztext	bin	zbin	filename
-----------------------------------------
 4167	 1479	 6723	 2669	add.lua
 3267	 1207	 5322	 2163	admin_remove.lua
15750	 4229	18889	 6442	build.lua
11312	 2888	17416	 5638	builtin.lua
 2178	  886	 2917	 1211	cmake.lua
  932	  389	 1123	  495	command.lua
 3417	 1141	 3689	 1355	make.lua
 2858	  894	 4150	 1592	cache.lua
24477	 6885	28519	10102	cfg.lua
 7108	 2440	10153	 3953	command_line.lua
 1973	  745	 2941	 1235	config_cmd.lua
28517	 7227	28451	 9265	deps.lua
 2570	  957	 2488	  875	dir.lua
 5059	 1586	 7951	 3051	doc.lua
 3409	 1202	 4749	 1909	download.lua
15275	 3871	16581	 5385	fetch.lua
 1832	  755	 2403	 1021	cvs.lua
 3570	 1392	 4256	 1705	git.lua
  792	  403	  656	  330	git_file.lua
 1143	  571	  669	  334	git_http.lua
  357	  219	  210	  133	git_https.lua
 1382	  650	  847	  396	git_ssh.lua
 2098	  833	 2730	 1120	hg.lua
 1004	  510	  643	  323	hg_http.lua
  346	  216	  208	  133	hg_https.lua
  340	  215	  206	  135	hg_ssh.lua
 1840	  830	 2223	  997	sscm.lua
 2140	  847	 3013	 1253	svn.lua
 2139	  869	 3640	 1426	fs.lua
28208	 7156	33960	10461	lua.lua
 5310	 1869	 6853	 2461	tools.lua
 4697	 1661	 5472	 2085	unix.lua
 7808	 2258	10465	 3220	tools.lua
 9289	 3063	11090	 3698	win32.lua
 7615	 2160	 9287	 2796	tools.lua
 4593	 1660	 6333	 2471	help.lua
 5492	 1976	 8172	 3300	index.lua
 7272	 1967	 8991	 2980	install.lua
 1527	  694	 1921	  896	lint.lua
 3323	 1078	 5010	 1909	list.lua
 9690	 2992	 8896	 3073	loader.lua
 3831	 1436	 4712	 1966	make.lua
 1871	  754	 2627	 1130	make_manifest.lua
24069	 5285	27989	 7961	manif.lua
 4153	 1283	 3995	 1399	manif_core.lua
 6292	 1964	 7620	 2995	new_version.lua
 7043	 2101	 9342	 3322	pack.lua
14996	 3091	17564	 3891	path.lua
 2268	  762	 2853	 1111	path_cmd.lua
 6883	 2014	 6975	 2595	persist.lua
 2614	  966	 4221	 1734	purge.lua
 1061	  452	 1528	  725	refresh_cache.lua
 6594	 2026	 9008	 3241	remove.lua
17202	 4044	21294	 6018	repos.lua
  108	   92	  194	  122	require.lua
18429	 4609	20519	 6396	search.lua
 5636	 1726	 8670	 3135	show.lua
  794	  299	 1093	  491	site_config.lua
22010	 5650	25584	 8469	patch.lua
 4804	 1420	 7212	 2519	tar.lua
 8683	 2114	10100	 3062	zip.lua
11511	 2891	 9642	 3520	type_check.lua
 6135	 1758	 7079	 2521	unpack.lua
 3014	 1057	 4268	 1850	upload.lua
 8674	 2577	14168	 5198	api.lua
 2800	 1052	 5082	 1997	multipart.lua
23374	 7126	25382	 8678	util.lua
 4622	 1310	 8064	 2750	validate.lua
12284	 3664	18127	 6686	write_rockspec.lua