1
0
forked from GitHub/gf-core
Files
gf-core/doc/val-optimization.txt
2005-01-11 15:06:12 +00:00

184 lines
5.2 KiB
Plaintext

Idea: in GFC, represent tables as just lists values, without showing
the parameters.
Concrete syntax:
table T [t1 ; ... ; tn]
where t1,...,tn are terms. This is treated as equivalent to
table {p1 => t1 ; ... ; pn => tn}
where p1,...,pn is the canonical listing of patterns of type T.
Advantage: reduce the size of GFC files.
Disadvantages: you don't get the sharing optimization, e.g.
table {A|B => v} instead of table T [v ; v]
Moreover, it is slower to select from the table, because
one first has to look up the position index of the argument.
Usage: when compiling a module, use the -val option:
i -val -src Foo.gf
Summary of results, testing with lib/resource/french/TestVerbesFre.gf:
without -val with -val ratio
compilation time 129 s 84 s 65 %
time to read back gfcm 109 s 32 s 29 %
size of generated gfcm 28 M 9 M 32 %
memory use in compilation 376 M 251 M 67 %
memory use in reading gfcm 1120 M 524 M 47 %
No significant loss in linearization (which needs selection).
Conclusion: for the case at hand (which prompted the experiment
at the first place), the gain is significant: compilation needs
30 % less resources, and using the compiled grammar needs
50-70 % less.
More testing is desirable to find out if -val is always good.
At the moment, reuse is not possible with gfc modules created
with the -val flag (although it is supported by the GF syntax
already).
10/1/2004
Test the generation of course-of-values tables
---------------------
Without:
i -src TestVerbesFre.gf
129160 msec
> gr -cat=V | l -table
650 msec
gf +RTS -K10M -s
8,469,778,952 bytes allocated in the heap
2,779,891,252 bytes copied during GC
133,108,856 bytes maximum residency (36 sample(s))
32295 collections in generation 0 ( 24,25s)
36 collections in generation 1 ( 24,68s)
376 Mb total memory in use
INIT time 0,01s ( 0,04s elapsed)
MUT time 80,21s (499,76s elapsed)
GC time 48,93s ( 50,01s elapsed)
EXIT time 0,00s ( 0,00s elapsed)
Total time 129,15s (549,81s elapsed)
%GC time 37,9% (9,1% elapsed)
Alloc rate 105,581,886 bytes per MUT second
Productivity 62,1% of total user, 14,6% of total elapsed
wc french/*.gfc french/*.gfr
37 2533 44976 french/CategoriesFre.gfc
0 9 62 french/ConjugNancy.gfc
2 29 137 french/MorphoFre.gfc
29 966 7641 french/NumeralsFre.gfc
136 393891 4415193 french/RulesFre.gfc
151 4211 39290 french/StructuralFre.gfc
123 607 3259 french/SyntaxFre.gfc
285 4702 59892 french/TestResourceFre.gfc
6790 27179 184046 french/TestVerbesAbs.gfc
6781 28170 198376 french/TestVerbesFre.gfc
20 214 1245 french/TypesFre.gfc
6494 45458 254878 french/VerbesAbs.gfc
6494 1272600 23438292 french/VerbesFre.gfc
6449 45143 209154 french/Vs.gfc
6278 47836 426316 french/ConjugNancy.gfr
14465 72471 655006 french/MorphoFre.gfr
238250 798560 8973600 french/SyntaxFre.gfr
492 2557 21908 french/TypesFre.gfr
293276 2747136 38933271 total
pm | wf test0.gfcm
55660 msec
wc test0.gfcm
28041 1784674 28669416 test0.gfcm
> i test0.gfcm
+ reading test0.gfcm 103290 msec
109450 msec
1120 Mb total memory in use
----------------------
After:
i -src -val TestVerbesFre.gf
84650 msec
gr -cat=V | l -table
390 msec
gf +RTS -K10M -s
6,061,907,436 bytes allocated in the heap
1,576,739,488 bytes copied during GC
92,700,188 bytes maximum residency (32 sample(s))
23109 collections in generation 0 ( 13,98s)
32 collections in generation 1 ( 12,02s)
251 Mb total memory in use
INIT time 0,01s ( 0,00s elapsed)
MUT time 59,28s (122,35s elapsed)
GC time 26,00s ( 26,91s elapsed)
EXIT time 0,00s ( 0,00s elapsed)
Total time 85,29s (149,26s elapsed)
%GC time 30,5% (18,0% elapsed)
Alloc rate 102,241,650 bytes per MUT second
Productivity 69,5% of total user, 39,7% of total elapsed
wc french/*.gfc french/*.gfr
37 3894 13600 french/CategoriesFre.gfc
0 9 62 french/ConjugNancy.gfc
2 29 137 french/MorphoFre.gfc
29 938 5726 french/NumeralsFre.gfc
136 354450 3097901 french/RulesFre.gfc
151 3738 22354 french/StructuralFre.gfc
123 607 3259 french/SyntaxFre.gfc
285 2437 18664 french/TestResourceFre.gfc
6790 27179 184046 french/TestVerbesAbs.gfc
6781 27694 191696 french/TestVerbesFre.gfc
20 214 1245 french/TypesFre.gfc
6494 45458 254878 french/VerbesAbs.gfc
6494 442149 5078881 french/VerbesFre.gfc
6449 45143 209154 french/Vs.gfc
6278 47836 426316 french/ConjugNancy.gfr
14465 72471 655006 french/MorphoFre.gfr
238250 798560 8973600 french/SyntaxFre.gfr
492 2557 21908 french/TypesFre.gfr
293276 1875363 19158433 total
pm | wf test1.gfcm
13030 msec
wc test1.gfcm
28041 912901 8894578 test1.gfcm
> i test1.gfcm
+ reading test1.gfcm 24220 msec
32720 msec
524 Mb total memory in use