Skip to content

Explore ways to reduce size of generated output #513

Open
@nikpivkin

Description

Describe the feature

The files serialize.go, deserialize.go and validators.go contain a lot of generated and uniform code. Using generics will reduce the package size.

The total size of the services is 464 mb:

du -sh service
464M    service

The size of these middleware is 182 mb, which is 40% of the total package size.

find . -type f \( -name "serializers.go" -o -name "deserializers.go" -o -name "validators.go" \) -exec du -ch {} + | grep total$
182M    total

The output of the go-size-analizer for my application:

gsa ./app
+---------+-----------------------------------------------------------------------------+--------+-----------+
| PERCENT | NAME                                                                        | SIZE   | TYPE      |
+---------+-----------------------------------------------------------------------------+--------+-----------+
| 20.63%  | github.com/aws/aws-sdk-go-v2                                                | 57 MB  | vendor    |
| 13.81%  | __gopclntab __DATA_CONST                                                    | 38 MB  | section   |
| 7.59%   | __rodata __TEXT                                                             | 21 MB  | section   |
| 7.22%   | __rodata __DATA_CONST                                                       | 20 MB  | section   |
| 5.60%   | __zdebug_loc __DWARF                                                        | 15 MB  | section   |
| 5.59%   | __zdebug_info __DWARF                                                       | 15 MB  | section   |
| 2.98%   | k8s.io/api                                                                  | 8.2 MB | vendor    |
| 2.23%   | __zdebug_line __DWARF                                                       | 6.1 MB | section   |
| 1.87%   | __zapple_names __DWARF                                                      | 5.1 MB | section   |
| 1.46%   | __zdebug_ranges __DWARF                                                     | 4.0 MB | section   |
| 1.22%   | github.com/alecthomas/chroma                                                | 3.4 MB | vendor    |
| 1.02%   | github.com/aws/aws-sdk-go                                                   | 2.8 MB | vendor    |
| 1.00%   | github.com/open-policy-agent/opa                                            | 2.8 MB | vendor    |
| 0.93%   | __data __DATA                                                               | 2.6 MB | section   |
| 0.85%   | __noptrdata __DATA                                                          | 2.3 MB | section   |
| 0.74%   | __zapple_types __DWARF                                                      | 2.0 MB | section   |
| 0.68%   | __zdebug_str __DWARF                                                        | 1.9 MB | section   |
| 0.64%   |                                                                             | 1.8 MB | generated |
| 0.52%   | __zdebug_frame __DWARF                                                      | 1.4 MB | section   |
| 0.37%   | net                                                                         | 1.0 MB | std       |
| 0.36%   | google.golang.org/protobuf                                                  | 996 kB | vendor    |
| 0.35%   | github.com/google/gnostic-models                                            | 954 kB | vendor    |

Use Case

Reducing the size of Golang binary

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS Go SDK V2 Module Versions Used

Go version used

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions