Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations: Only link used datasets, avoid copies, avoid pkg/errors dependency #26

Merged
merged 7 commits into from
Nov 21, 2023

Conversation

mologie
Copy link
Contributor

@mologie mologie commented Aug 12, 2023

This PR contains various minor optimizations that aim to reduce the overall binary size.

Size/complexity optimizations:

  • Load datasets into individual byte slices, which allows the Go linker to strip out unused ones. This reduces binary size by 10+MB when using only the Provinces10 dataset.
  • Remove github.com/pkg/errors in favor of Go's native error wrapping

Misc cosmetics:

  • Avoid copying data (gzip, slices) where possible, showed up on a memory profile but had no practical impact
  • Use Go 1.21 in CI because 1.19 is EOL

This is achieved by making each dataset a separatge variable, which
can be stripped out by the linker when it is no referenced anywhere.
Also avoids unnecessary copies of gzipped dataset.
Go version in go.mod can remain at 1.19 for compatibility.
@sams96
Copy link
Owner

sams96 commented Nov 21, 2023

Sorry it's taken me a while to get to this, but it all looks good thank you very much.

@sams96 sams96 merged commit f725e83 into sams96:master Nov 21, 2023
@mologie mologie deleted the optimize branch May 12, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants