-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support compression for Actions logs (#31761)
Support compression for Actions logs to save storage space and bandwidth. Inspired by #24256 (comment) 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">
- Loading branch information
Showing
15 changed files
with
615 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package zstd | ||
|
||
import "github.com/klauspost/compress/zstd" | ||
|
||
type WriterOption = zstd.EOption | ||
|
||
var ( | ||
WithEncoderCRC = zstd.WithEncoderCRC | ||
WithEncoderConcurrency = zstd.WithEncoderConcurrency | ||
WithWindowSize = zstd.WithWindowSize | ||
WithEncoderPadding = zstd.WithEncoderPadding | ||
WithEncoderLevel = zstd.WithEncoderLevel | ||
WithZeroFrames = zstd.WithZeroFrames | ||
WithAllLitEntropyCompression = zstd.WithAllLitEntropyCompression | ||
WithNoEntropyCompression = zstd.WithNoEntropyCompression | ||
WithSingleSegment = zstd.WithSingleSegment | ||
WithLowerEncoderMem = zstd.WithLowerEncoderMem | ||
WithEncoderDict = zstd.WithEncoderDict | ||
WithEncoderDictRaw = zstd.WithEncoderDictRaw | ||
) | ||
|
||
type EncoderLevel = zstd.EncoderLevel | ||
|
||
const ( | ||
SpeedFastest EncoderLevel = zstd.SpeedFastest | ||
SpeedDefault EncoderLevel = zstd.SpeedDefault | ||
SpeedBetterCompression EncoderLevel = zstd.SpeedBetterCompression | ||
SpeedBestCompression EncoderLevel = zstd.SpeedBestCompression | ||
) | ||
|
||
type ReaderOption = zstd.DOption | ||
|
||
var ( | ||
WithDecoderLowmem = zstd.WithDecoderLowmem | ||
WithDecoderConcurrency = zstd.WithDecoderConcurrency | ||
WithDecoderMaxMemory = zstd.WithDecoderMaxMemory | ||
WithDecoderDicts = zstd.WithDecoderDicts | ||
WithDecoderDictRaw = zstd.WithDecoderDictRaw | ||
WithDecoderMaxWindow = zstd.WithDecoderMaxWindow | ||
WithDecodeAllCapLimit = zstd.WithDecodeAllCapLimit | ||
WithDecodeBuffersBelow = zstd.WithDecodeBuffersBelow | ||
IgnoreChecksum = zstd.IgnoreChecksum | ||
) |
Oops, something went wrong.