diff options
author | Jason Song <i@wolfogre.com> | 2024-08-09 10:10:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-09 10:10:30 +0800 |
commit | 33cc5837a655ad544b936d4d040ca36d74092588 (patch) | |
tree | 05b35b4f90f02989c73156bd28d3712f498fa9d0 /modules/packages | |
parent | 791d7fc76aa41370860126e861cf14d98efe710e (diff) | |
download | gitea-33cc5837a655ad544b936d4d040ca36d74092588.tar.gz gitea-33cc5837a655ad544b936d4d040ca36d74092588.zip |
Support compression for Actions logs (#31761)
Support compression for Actions logs to save storage space and
bandwidth. Inspired by
https://github.com/go-gitea/gitea/issues/24256#issuecomment-1521153015
The biggest challenge is that the compression format should support
[seekable](https://github.com/facebook/zstd/blob/dev/contrib/seekable_format/zstd_seekable_compression_format.md).
So when users are viewing a part of the log lines, Gitea doesn't need to
download the whole compressed file and decompress it.
That means gzip cannot help here. And I did research, there aren't too
many choices, like bgzip and xz, but I think zstd is the most popular
one. It has an implementation in Golang with
[zstd](https://github.com/klauspost/compress/tree/master/zstd) and
[zstd-seekable-format-go](https://github.com/SaveTheRbtz/zstd-seekable-format-go),
and what is better is that it has good compatibility: a seekable format
zstd file can be read by a regular zstd reader.
This PR introduces a new package `zstd` to combine and wrap the two
packages, to provide a unified and easy-to-use API.
And a new setting `LOG_COMPRESSION` is added to the config, although I
don't see any reason why not to use compression, I think's it's a good
idea to keep the default with `none` to be consistent with old versions.
`LOG_COMPRESSION` takes effect for only new log files, it adds `.zst` as
an extension to the file name, so Gitea can determine if it needs
decompression according to the file name when reading. Old files will
keep the format since it's not worth converting them, as they will be
cleared after #31735.
<img width="541" alt="image"
src="https://github.com/user-attachments/assets/e9598764-a4e0-4b68-8c2b-f769265183c9">
Diffstat (limited to 'modules/packages')
-rw-r--r-- | modules/packages/conda/metadata.go | 3 | ||||
-rw-r--r-- | modules/packages/conda/metadata_test.go | 3 | ||||
-rw-r--r-- | modules/packages/debian/metadata.go | 2 | ||||
-rw-r--r-- | modules/packages/debian/metadata_test.go | 3 |
4 files changed, 6 insertions, 5 deletions
diff --git a/modules/packages/conda/metadata.go b/modules/packages/conda/metadata.go index 5eb72b8e38..76ba95eace 100644 --- a/modules/packages/conda/metadata.go +++ b/modules/packages/conda/metadata.go @@ -13,8 +13,7 @@ import ( "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/validation" - - "github.com/klauspost/compress/zstd" + "code.gitea.io/gitea/modules/zstd" ) var ( diff --git a/modules/packages/conda/metadata_test.go b/modules/packages/conda/metadata_test.go index 2bb114f030..035d63d4d8 100644 --- a/modules/packages/conda/metadata_test.go +++ b/modules/packages/conda/metadata_test.go @@ -10,8 +10,9 @@ import ( "io" "testing" + "code.gitea.io/gitea/modules/zstd" + "github.com/dsnet/compress/bzip2" - "github.com/klauspost/compress/zstd" "github.com/stretchr/testify/assert" ) diff --git a/modules/packages/debian/metadata.go b/modules/packages/debian/metadata.go index 32460a84ae..e76db63975 100644 --- a/modules/packages/debian/metadata.go +++ b/modules/packages/debian/metadata.go @@ -14,9 +14,9 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/validation" + "code.gitea.io/gitea/modules/zstd" "github.com/blakesmith/ar" - "github.com/klauspost/compress/zstd" "github.com/ulikunitz/xz" ) diff --git a/modules/packages/debian/metadata_test.go b/modules/packages/debian/metadata_test.go index 26c2a6fc68..4864bc89d8 100644 --- a/modules/packages/debian/metadata_test.go +++ b/modules/packages/debian/metadata_test.go @@ -10,8 +10,9 @@ import ( "io" "testing" + "code.gitea.io/gitea/modules/zstd" + "github.com/blakesmith/ar" - "github.com/klauspost/compress/zstd" "github.com/stretchr/testify/assert" "github.com/ulikunitz/xz" ) |