6e2536f585
Previously doubles was saved as strings in the string table, with a DoubleLiteral holding a StringReference. This can cause overhead in both computation time (converting the double to and from string) as well as size (e.g. a single usage of the previously unused double 1000000.42 would use (at least) * 10 bytes for the characters * 1 byte for the size * 1 byte for the reference to the string whereas saving it as a double would simply save the 8 bytes. On the other hand the string table doesn't contain duplicates so many usages of the same double will use more space. The SDK dill file size decreases slightly (< 1 KB). On a Dart file with 1M different doubles (0.42, 1.42, ..., 999999.42) added to a list: Before: compile and write via fasta (non-strong-mode): 0:12.18 Reading (via dart, eager): 2500-2600 ms Writing (to null sink) (after reading): 1600-1800 ms Output dill file (via fasta compile): ~62 MB After: compile and write via fasta (non-strong-mode): 0:11.76 Reading (via dart, eager): 2050-2350 ms Writing (to null sink) (after reading): 400-550 ms Output dill file (via fasta compile): ~54 MB Running the dill file is ~the same time, but "Maximum resident set size (kbytes)" (from /usr/bin/time -v) decreases with ~4%. On the other side, if it's 1M of the same doubles (0.42), while compiling is ~the same speed, the output dill goes from 43MB to 50MB. Surprisingly the "Maximum resident set size (kbytes)" still decreases though (~3%). Running flutter test in flutter/packages/flutter: Before: ``` 02:33 +2425 ~18: All tests passed! 02:28 +2425 ~18: All tests passed! 02:28 +2425 ~18: All tests passed! ``` After: ``` 02:12 +2425 ~18: All tests passed! 02:11 +2425 ~18: All tests passed! 02:12 +2425 ~18: All tests passed! ``` So that's -12.0267% +/- 3.15253% File size of a dill file of an arbitrary test using flutter is reduced by ~44 KB (~0.3%). Change-Id: I64151376cde1dae6f0d02b3d96991bc432a994ae Reviewed-on: https://dart-review.googlesource.com/41660 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Kevin Millikin <kmillikin@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>