ontarget-binary.tex /size: 3756 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/ontarget
2
3\startcomponent ontarget-binary
4
5\environment ontarget-style
6
7\startchapter[title={The binary}]
8
9This is a very short chapter. Because \LUAMETATEX\ is also a script runner, I
10want to keep it lean and mean. So, when the size exceeded 3MB after we'd extended
11the math engine, I decided to (finally) let all the \METAPOST\ number interfaces
12pass pointers which brought down the binary 100K and below the 3MB mark again.
13
14I then became curious about how much of the binary actually is taken by
15\METAPOST, and a bit of calculation indicated that we went from 20.1\percent\ down
16to 18.3\percent. Here is the state per May 13, 2022:
17
18\startluacode
19
20    local bytes = {
21        liblua        =  515156,
22        libluaoptional=  103668,
23        libluarest    =   82492,
24        libluasocket  =  105700,
25        libmimalloc   =  178800,
26        libminiz      =   51584,
27        libmp         =  797636,
28        libmp         =  797636, -- went from 20.1% to 18.3% after going more pointers
29     -- libmp         =  797636 + (3061799 - 2960091),
30        libpplib      =  325162,
31        libtex        = 2207190,
32    }
33
34    local comment = {
35        liblua        = "lua core, tex interfaces",
36        libluaoptional= "framework, several small interfaces, cerf",
37        libluarest    = "general helper libraries",
38        libluasocket  = "helper that interfaces to the os libraries",
39        libmimalloc   = "memory management partial",
40        libminiz      = "minimalistic core",
41        libmp         = "mp graphic core, number libraries, lua interfacing",
42        libpplib      = "pdf reading core, encryption helpers",
43        libtex        = "extended tex core",
44    }
45
46    local luametatex = 2960091
47    local libraries  = 0 for k, v in next, bytes do libraries = libraries + v end
48    local normalizer = luametatex/libraries
49
50    local luastuff   = bytes.liblua
51                     + bytes.libluaoptional
52                     + bytes.libluarest
53                     + bytes.libluasocket
54
55    -------(luametatex) context.par()
56    -------(libraries)  context.par()
57    -------(normalizer) context.par()
58
59    context.starttabulate { "|l|r|r|p|" }
60        context.FL()
61        context.NC() context.bold("component")
62        context.NC() context.bold("pct")
63        context.NC() context.bold("bytes")
64        context.NC() context.bold("comment")
65        context.NC() context.NR()
66        context.ML()
67        for k, v in table.sortedpairs(bytes) do
68            context.NC() context(k)
69            context.NC() context("%.1f",100*v/libraries)
70            context.NC() context(math.round(normalizer*v))
71            context.NC() context(comment[k])
72            context.NC() context.NR()
73        end
74        context.ML()
75        context.NC() context.bold("luametatex")
76        context.NC()
77        context.NC() context.bold(luametatex)
78        context.NC() context("2022-05-13")
79        context.NC() context.NR()
80        context.LL()
81    context.stoptabulate()
82
83    function document.texstuff() context("%.1f\\percent",100 * bytes.libtex  /libraries) end
84    function document.mpsstuff() context("%.1f\\percent",100 * bytes.libmp   /libraries) end
85    function document.pdfstuff() context("%.1f\\percent",100 * bytes.libpplib/libraries) end
86    function document.luastuff() context("%.1f\\percent",100 * luastuff       /libraries) end
87
88\stopluacode
89
90It is clear that the \TEX\ core is good for half of the code (\ctxlua {document .
91texstuff ()}) with the accumulated \LUA\ stuff (\ctxlua {document . luastuff ()})
92and \METAPOST\ being a good second (\ctxlua {document . mpsstuff ()}) and third
93and the \PDF\ interpreting library a decent fourth (\ctxlua {document . pdfstuff
94()}) place.
95
96\stopchapter
97
98\stopcomponent
99
100