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

Enable compression in logs WAL #5408

Merged
merged 5 commits into from
Oct 10, 2023
Merged

Enable compression in logs WAL #5408

merged 5 commits into from
Oct 10, 2023

Conversation

thepalbi
Copy link
Contributor

@thepalbi thepalbi commented Oct 6, 2023

PR Description

This PR enables compression the loki.write WAL. Both snappy and zstd are supported by the reader/writer side, and the reader side checks the compression of each record read (so no compat issues). Snappy was picked because since this it will be used in a WAL, rather than a wire-protocol, we strive more for cpu efficiency (snappy is cpu lighter) rather higher compression rate (which zstd does better, but at a higher CPU cost).

Enabling compression in WAL allowed us in our agents deployment to have a compression rate of ~2.

image

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@thepalbi thepalbi requested a review from a team as a code owner October 6, 2023 17:12
Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this change.

But before we merge, can we check how this affects people who were already using the WAL without compression? Do they need to delete their previous WAL? Do they continue operation normally? Any errors/logs they might see?

In case there's breaking behavior here we'd do well to document it.

@thepalbi
Copy link
Contributor Author

thepalbi commented Oct 9, 2023

@tpaschalis no breaking behaviour expected, and WAL will keep working as is after an agent is restart with compression turned on.

Basically, when an agent restarts, on the writer side, the wlog will start writing in a new segment, so the existing segments with compression disabled will co-exist with the compressed one.

On the other side, from the reader end, the LiveReader checks if each wal entry is compressed or not individually, hence it will handle compressed and uncompressed ones gracefully.

Said all that, this change is completely transparent.

@thepalbi
Copy link
Contributor Author

@tpaschalis is this good to go?

@tpaschalis tpaschalis enabled auto-merge (squash) October 10, 2023 13:12
@tpaschalis tpaschalis merged commit 788b6e0 into main Oct 10, 2023
@tpaschalis tpaschalis deleted the pablo/logs-wal-compression branch October 10, 2023 13:17
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Feb 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants