diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-04-25 10:06:37 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-04-26 05:58:31 +0200 |
| commit | 0ce7569ee76fda7e5a68b0fe14c93a3e8eb7d108 (patch) | |
| tree | 79adf4f1b16a3d58c2b436dceaff2e873e2f51bd /sys/syz-sysgen/sysgen.go | |
| parent | 99b258ddc33e296f07588a15397ae426c6ed236c (diff) | |
pkg/compiler: deduplicate Types in descriptions
Add prog.Ref Type that serves as a proxy for real types
and allows to deduplicate Types in generated descriptions.
The Ref type is effectively an index in an array of types.
Just before serialization pkg/compiler replaces real types
with the Ref types and prepares corresponding array of real types.
When a Target is registered in prog package, we do the opposite
operation and replace Ref's with the corresponding real types.
This brings improvements across the board:
compiler memory consumption is reduced by 15%,
test building time by 25%, descriptions size by 33%.
Before:
$ du -h sys/linux/gen
54M sys/linux/gen
$ time GOMAXPROCS=1 go test -p=1 -c ./prog
real 0m54.200s
real 0m53.883s
$ time GOMAXPROCS=1 go install -p=1 ./tools/syz-execprog
real 0m27.911s
real 0m27.767s
$ TIME="%e %P %M" GOMAXPROCS=1 time go tool compile ./sys/linux/gen
20.59 100% 3200016
20.97 100% 3445976
20.25 100% 3209684
After:
$ du -h sys/linux/gen
36M sys/linux/gen
$ time GOMAXPROCS=1 go test -p=1 -c ./prog
real 0m42.290s
real 0m43.230s
$ time GOMAXPROCS=1 go install -p=1 ./tools/syz-execprog
real 0m24.337s
real 0m24.727s
$ TIME="%e %P %M" GOMAXPROCS=1 time go tool compile ./sys/linux/gen
19.11 100% 2764952
19.66 100% 2787624
19.35 100% 2749376
Update #1580
Diffstat (limited to 'sys/syz-sysgen/sysgen.go')
| -rw-r--r-- | sys/syz-sysgen/sysgen.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index 8043adf9d..a424e1488 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -205,11 +205,11 @@ func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint fmt.Fprintf(out, "\tRegisterTarget(&Target{"+ "OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v, "+ "PageSize: %v, NumPages: %v, DataOffset: %v, Syscalls: syscalls_%v, "+ - "Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}, "+ + "Resources: resources_%v, Structs: structDescs_%v, Types: types_%v, Consts: consts_%v}, "+ "InitTarget)\n}\n\n", target.OS, target.Arch, target.Arch, target.PtrSize, target.PageSize, target.NumPages, target.DataOffset, - target.Arch, target.Arch, target.Arch, target.Arch) + target.Arch, target.Arch, target.Arch, target.Arch, target.Arch) fmt.Fprintf(out, "var resources_%v = ", target.Arch) serializer.Write(out, prg.Resources) @@ -223,6 +223,10 @@ func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint serializer.Write(out, prg.Syscalls) fmt.Fprintf(out, "\n\n") + fmt.Fprintf(out, "var types_%v = ", target.Arch) + serializer.Write(out, prg.Types) + fmt.Fprintf(out, "\n\n") + constArr := make([]prog.ConstValue, 0, len(consts)) for name, val := range consts { constArr = append(constArr, prog.ConstValue{Name: name, Value: val}) |
