etcd icon indicating copy to clipboard operation
etcd copied to clipboard

etcdserver: compact raft log entries more frequently

Open clement2026 opened this issue 1 year ago • 5 comments

Part of #17098

Goal

Compact raft log more frequently to save memory.

Key Changes

  • Added a new function maybeCompactRaftLog to handle raft log compaction.
  • Introduce 2 variables: CompactRaftLogEveryNApplies and DefaultCompactRaftLogEveryNApplies to control how frequently the raft log is compacted.
  • Fix a test

TODO

  • [ ] Add tests for the changes
  • [ ] Run benchmarks

clement2026 avatar Sep 23 '24 15:09 clement2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: clement2026 Once this PR has been reviewed and has the lgtm label, please assign wenjiaswe for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Sep 23 '24 15:09 k8s-ci-robot

Hi @clement2026. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Sep 23 '24 15:09 k8s-ci-robot

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 68.81%. Comparing base (59cfd7a) to head (273905b). :warning: Report is 2106 commits behind head on main.

:warning: Current head 273905b differs from pull request most recent head f1a76a2

Please upload reports for the commit f1a76a2 to get more accurate results.

Additional details and impacted files
Files with missing lines Coverage Δ
server/config/config.go 79.76% <ø> (ø)
server/etcdserver/server.go 81.48% <100.00%> (+0.13%) :arrow_up:

... and 14 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #18622      +/-   ##
==========================================
+ Coverage   68.79%   68.81%   +0.01%     
==========================================
  Files         420      420              
  Lines       35522    35532      +10     
==========================================
+ Hits        24438    24451      +13     
+ Misses       9657     9654       -3     
  Partials     1427     1427              

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 59cfd7a...f1a76a2. Read the comment docs.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Sep 23 '24 15:09 codecov-commenter

This change does to many things, there are two changes here that should be independent:

  • Separate maybeCompactRaftLog function allowing us to compact log independently from snapshots.
  • Run compaction more frequently. As currently compacti is dependent on snapshot, we would first need to confirm that we are ok with lower number of entries.

serathius avatar Sep 24 '24 09:09 serathius

Sure. I'll break down this PR.

clement2026 avatar Sep 24 '24 09:09 clement2026

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Oct 30 '24 19:10 k8s-ci-robot

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 05:04 stale[bot]

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 21 '25 00:07 github-actions[bot]

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Oct 21 '25 00:10 github-actions[bot]