Skip to content

refactor: replace VividCortex/ewma with inline EWMA math - #22029

Draft
davdhacs wants to merge 2 commits into
masterfrom
davdhacs/remove-ewma
Draft

refactor: replace VividCortex/ewma with inline EWMA math#22029
davdhacs wants to merge 2 commits into
masterfrom
davdhacs/remove-ewma

Conversation

@davdhacs

Copy link
Copy Markdown
Contributor

Description

Replace github.com/VividCortex/ewma with 3 lines of inline exponentially weighted moving average math. The library was used in a single file (roxctl/central/db/restore/v2_restorer.go) for a progress bar speed display.

The EWMA formula with default age=30: value += (2/31) * (sample - value). Three lines of arithmetic replacing a full module import.

VividCortex/ewma demoted from direct to indirect (still needed transitively by vbauerster/mpb).

User-facing documentation

  • CHANGELOG.md is updated OR update is not needed
  • documentation PR is created and is linked above OR is not needed

No user-facing behavior changes.

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • modified existing tests

How I validated my change

  • go build ./roxctl/... passes
  • The EWMA formula is mathematically identical to the library's SimpleEWMA implementation

davdhacs added 2 commits July 30, 2026 11:35
Single use in restore progress display. The exponentially weighted
moving average with age=30 is: value += (2/31) * (sample - value).
Three lines of arithmetic vs a whole dependency.

Generated with AI assistance.
VividCortex/ewma stays as indirect — still needed by vbauerster/mpb
which is used by the restore progress bar.

Generated with AI assistance.
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 61c65639-8b4e-4461-b4d8-530dd56ac2b1

📥 Commits

Reviewing files that changed from the base of the PR and between b07a7ca and 24fa0d5.

📒 Files selected for processing (2)
  • go.mod
  • roxctl/central/db/restore/v2_restorer.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved restore progress speed and ETA calculations for more reliable transfer estimates.
    • Preserved existing restore behavior while refining throughput reporting.

Walkthrough

The restore progress speed calculation no longer imports github.com/VividCortex/ewma; it maintains an inline EWMA for ETA and throughput formatting. The dependency remains in go.mod as an indirect requirement.

Changes

Restore speed estimation

Layer / File(s) Summary
Inline EWMA restore progress
roxctl/central/db/restore/v2_restorer.go, go.mod
updateTransferStatus computes transfer speed with a floating-point EWMA and preserves ETA/status formatting; github.com/VividCortex/ewma is recorded as an indirect dependency.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: guzalv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing the ewma dependency with inline EWMA math.
Description check ✅ Passed The description matches the template well and includes the change summary, user-facing docs, testing, and validation details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch davdhacs/remove-ewma

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Build Images Ready

Images are ready for commit 24fa0d5. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.12.x-622-g24fa0d5f29

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.19%. Comparing base (fb7220b) to head (24fa0d5).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
roxctl/central/db/restore/v2_restorer.go 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22029      +/-   ##
==========================================
- Coverage   51.23%   51.19%   -0.04%     
==========================================
  Files        2864     2865       +1     
  Lines      178713   178809      +96     
==========================================
- Hits        91560    91550      -10     
- Misses      79117    79198      +81     
- Partials     8036     8061      +25     
Flag Coverage Δ
go-unit-tests 51.19% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davdhacs
davdhacs requested a review from janisz July 31, 2026 16:22
@davdhacs

Copy link
Copy Markdown
Contributor Author

@janisz I am pursuing this because I have been looking for dependencies to remove. This looks like a good candidate for removal because it is only used here and doesn't do much (math we can inline that won't change (no external service)). What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant