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

Gitea binary size #33023

Closed
wxiaoguang opened this issue Dec 28, 2024 · 11 comments
Closed

Gitea binary size #33023

wxiaoguang opened this issue Dec 28, 2024 · 11 comments
Labels
topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile

Comments

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 28, 2024

  • gitea-1.23.0-rc0-linux-amd64 152 MB
  • gitea-1.22.6-linux-amd64 137 MB
  • gitea-1.21.10-linux-amd64 132 MB
  • gitea-1.20.4-linux-amd64 128 MB

go-size-analyzer report: https://gist.github.com/wxiaoguang/3cf40614fd7f0a3ee0cc88bc82aa97e9

The major size increment for 1.23 comes from aws sdk and ClickHouse/ch-go. And it seems that the debug_info is not stripped?

@delvh
Copy link
Member

delvh commented Dec 28, 2024

So, what's your point?
I don't really see anything large in your report that we can get rid of?
Sure, we should avoid bloating the binary, but only when it makes sense.
Removing features simply because "the binary is too large" is a bad idea (it's an entirely different thing if there are other reasons for removing a feature, though).
Stopping development is an equally bad idea.
Am I missing any other option on this tradeoff without an optimal solution?

@delvh delvh added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Dec 28, 2024
@wxiaoguang
Copy link
Contributor Author

So, what's your point?

Still analyzing, updated the issue description. I do not mean "stop", but I think it's good for people to know the details.

Something in my mind at the moment:

  1. Gitea binary is executed on every git push, so I do not think we should make bloating too fast
  2. When introducing a dependency, maybe we could spend more time on analyzing it
  3. Whether the build could be optimized (has the debug info been stripped?)
  4. Pay more attentions to each release.

@wxiaoguang wxiaoguang added topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile and removed issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Dec 28, 2024
@wxiaoguang
Copy link
Contributor Author

One more thing: it doesn't seem right to have github.com/ClickHouse/ch-go in the build. Need to figure out what's wrong.

# github.com/ClickHouse/ch-go
code.gitea.io/gitea/models/unittest
github.com/go-testfixtures/testfixtures/v3
github.com/ClickHouse/clickhouse-go/v2
github.com/ClickHouse/ch-go/compress

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Dec 28, 2024

And one more thing, maybe we should use github.com/goccy/go-json to replace github.com/json-iterator/go , it doesn't make sense to use 2 json package here.

But xorm still hard depends on github.com/json-iterator/go (which is unmaintained for 2 years)

@eeyrjmr
Copy link
Contributor

eeyrjmr commented Dec 28, 2024

V1.22.4 is 90meg on alpine and v1.22.6 is 101meg on Gentoo so there is something in build options outside of actual build dependencies

Alpine build with -O2 against musl while I am using clang with -O3 on Gentoo so the -Ox might explain the 10meg difference but not the 30-40meg from the prebuilt so yes debug is the most likely

@lunny
Copy link
Member

lunny commented Dec 28, 2024

And one more thing, maybe we should use github.com/goccy/go-json to replace github.com/json-iterator/go , it doesn't make sense to use 2 json package here.

But xorm still hard depends on github.com/json-iterator/go (which is unmaintained for 2 years)

I will take a look at xorm side.

@wxiaoguang
Copy link
Contributor Author

The major size increment for 1.23 comes from aws sdk and ClickHouse/ch-go.

To remove unnecessary dependency: Refactor fixture loading for testing #33024

@lunny
Copy link
Member

lunny commented Dec 29, 2024

github.com/json-iterator/go

There are two build flags of xorm which are gojson and jsoniter to support github.com/goccy/go-json and github.com/json-iterator/go. By default, xorm use standard json library without any build tag.

@wxiaoguang
Copy link
Contributor Author

And it seems that the debug_info is not stripped?

@techknowlogick -> Release build misses -s -w flag #33030

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Dec 30, 2024

Now gitea-1.23-nightly-linux-amd64 and gitea-main-nightly-linux-amd64 on https://dl.gitea.com/gitea/ are both around 109.8 MiB.

Much smaller than https://dl.gitea.com/gitea/1.23.0-rc0/

"Remove aws go sdk package dependency #33029" might still save about 1MB more.

lunny added a commit that referenced this issue Dec 30, 2024
This PR removed the dependency of `github.com/aws/aws-sdk-go/aws`

Patially fix for #33023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Dec 30, 2024
This PR removed the dependency of `github.com/aws/aws-sdk-go/aws`

Patially fix for go-gitea#33023
@wxiaoguang
Copy link
Contributor Author

Now: nightly size is 106.8 MiB

Save bandwidth, save energy, save the Earth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile
Projects
None yet
Development

No branches or pull requests

4 participants