Skip to content

perf: replace O(n²) concat with push in metaculus fetchEvents#572

Merged
realfishsam merged 1 commit into
mainfrom
fix/552-metaculus-fetchevents-perf
May 24, 2026
Merged

perf: replace O(n²) concat with push in metaculus fetchEvents#572
realfishsam merged 1 commit into
mainfrom
fix/552-metaculus-fetchevents-perf

Conversation

@realfishsam

Copy link
Copy Markdown
Contributor

Fixes #552

@realfishsam

Copy link
Copy Markdown
Contributor Author

PR Review: PASS (NOT VERIFIED)

What This Does

Replaces all = all.concat(results) with all.push(...results) in the metaculus fetchEvents.ts pagination loop, mirroring the same O(n^2) fix applied in PR #571.

Blast Radius

  • Core: core/src/exchanges/metaculus/fetchEvents.ts only
  • No OpenAPI, SDK, or type changes

Findings

  1. Same let -> could-be-const note as PR perf: replace O(n²) concat with push in metaculus fetchMarkets #571 (line 31). Non-blocking.
  2. Batch size is 100, safely below V8 spread argument limits.
  3. Both fetchMarkets and fetchEvents share the same fetchPostPages pattern. If these were ever consolidated into a shared helper, only one fix would be needed. Minor tech-debt observation, not blocking.

PMXT Pipeline Check

  • Field propagation: N/A
  • OpenAPI sync: N/A
  • Type safety: OK

Semver Impact

patch -- internal perf improvement, no API or behavioral change

Risk

Not verified against live Metaculus data. Mechanically identical to PR #571.

@realfishsam realfishsam merged commit e6a1f09 into main May 24, 2026
11 of 12 checks passed
@realfishsam realfishsam deleted the fix/552-metaculus-fetchevents-perf branch May 24, 2026 17:04
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.

Unbounded: core/src/exchanges/metaculus/fetchEvents.ts — O(n²) array.concat() with MAX_PAGES=200

1 participant