Gitea binary size #13891

Closed
opened 2025-11-02 10:56:18 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @wxiaoguang on GitHub (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?

Originally created by @wxiaoguang on GitHub (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?
GiteaMirror added the topic/build label 2025-11-02 10:56:18 -06:00
Author
Owner

@delvh commented on GitHub (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 commented on GitHub (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?
Author
Owner

@wxiaoguang commented on GitHub (Dec 28, 2024):

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 commented on GitHub (Dec 28, 2024): > 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 1. When introducing a dependency, maybe we could spend more time on analyzing it 1. Whether the build could be optimized (has the debug info been stripped?) 1. Pay more attentions to each release.
Author
Owner

@wxiaoguang commented on GitHub (Dec 28, 2024):

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 commented on GitHub (Dec 28, 2024): 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 ```
Author
Owner

@wxiaoguang commented on GitHub (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)

@wxiaoguang commented on GitHub (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)
Author
Owner

@eeyrjmr commented on GitHub (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

@eeyrjmr commented on GitHub (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
Author
Owner

@lunny commented on GitHub (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.

@lunny commented on GitHub (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.
Author
Owner

@wxiaoguang commented on GitHub (Dec 29, 2024):

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

@wxiaoguang commented on GitHub (Dec 29, 2024): > 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
Author
Owner

@lunny commented on GitHub (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.

@lunny commented on GitHub (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.
Author
Owner

@wxiaoguang commented on GitHub (Dec 29, 2024):

And it seems that the debug_info is not stripped?

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

@wxiaoguang commented on GitHub (Dec 29, 2024): > And it seems that the `debug_info` is not stripped? @techknowlogick -> Release build misses `-s -w` flag #33030
Author
Owner

@wxiaoguang commented on GitHub (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.

@wxiaoguang commented on GitHub (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.
Author
Owner

@wxiaoguang commented on GitHub (Dec 30, 2024):

Now: nightly size is 106.8 MiB

Save bandwidth, save energy, save the Earth

@wxiaoguang commented on GitHub (Dec 30, 2024): Now: nightly size is 106.8 MiB Save bandwidth, save energy, save the Earth
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13891