ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.86k stars 295 forks source link

Investigate reducing size of fast-path.generated.go #296

Closed ugorji closed 5 years ago

ugorji commented 5 years ago

Currently, we generate about 35K LOC in fast-path.generated.go file.

This seems to add up to 10MB to the size of a binary that includes go-codec.

Although this can be prevented by building with the tag notfastpath, there is a corresponding performance loss.

We may be able to reduce the effect by avoiding generating helper functions for some of the less common built in numeric or boolean types.

The candidates for reduction:

The combination of these may reduce that 10MB to about 5MB.

ugorji commented 5 years ago

In theory, removing these may reduce the combinations for maps from 16x16 to 10x11 i.e going from a multiple of 256 functions to 110 functions. In addition, removing canonical support for encoding maps will reduce the size of those encoding functions by half. Taken together, we may be able to reduce that 10MB by over half.

Any changes here MUST be reflected in codecgen seamlessly.