Skip to content

perf: reduce linear regression channel allocations - #15

Open
leo1987820 wants to merge 2 commits into
Dragoon4002:mainfrom
leo1987820:codex/perf-linear-regression-channel-2
Open

perf: reduce linear regression channel allocations#15
leo1987820 wants to merge 2 commits into
Dragoon4002:mainfrom
leo1987820:codex/perf-linear-regression-channel-2

Conversation

@leo1987820

Copy link
Copy Markdown

Summary

Refs #2.

This PR optimizes linear_regression_channel without overlapping the existing performance submissions for dashboard grouping, stochastic/RSI/ATR/MACD/OBV, PnL chart rendering, or log buffering.

The previous implementation allocated x = list(range(lookback)) and a full residuals list on every call. This version:

  • computes fixed sx and sxx with arithmetic-series formulas
  • uses enumerate(y) instead of materializing x
  • accumulates residual squared error directly instead of allocating residuals
  • keeps the previous output behavior covered by regression tests

Validation

Because my local environment cannot currently clone this repository over GitHub TLS, I validated the exact touched module in a local minimal workspace.

Manual test invocation passed:

manual statistical_algos tests passed

Micro-benchmark over 2,000 calls on a 5,000-point price series:

lookback=20  old=0.019192s  new=0.012716s  speedup=1.51x
lookback=100 old=0.061628s  new=0.036901s  speedup=1.67x
lookback=500 old=0.284800s  new=0.188338s  speedup=1.51x

Notes

I intentionally avoided duplicating the existing open PRs and focused on a separate statistical strategy hot path.

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@leo1987820 is attempting to deploy a commit to the dragoon4002's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant