Skip to content

perf: cache static assets and streamline loaders#847

Open
ugcodrr wants to merge 1 commit into
mainfrom
perf/cache-static-assets
Open

perf: cache static assets and streamline loaders#847
ugcodrr wants to merge 1 commit into
mainfrom
perf/cache-static-assets

Conversation

@ugcodrr
Copy link
Copy Markdown
Member

@ugcodrr ugcodrr commented May 12, 2026

Summary

  • memoize static asset image loads in @statsify/assets so repeated logo, game icon, and selected background image requests reuse the same pending/resolved image promise
  • cache Duels mode icons once per process instead of reading the directory and decoding every icon on each /duels render
  • fix leaderboard page caching so page 0 is cached and current page state preserves valid zero values
  • switch command and event loader recursion to readdir({ withFileTypes: true }) to avoid synchronous statSync calls during startup traversal

Why / Benefits

  • Reduces repeated disk reads and image decodes for hot rendering paths while preserving randomized background selection behavior.
  • Lowers memory churn from repeated Duels icon allocation on command runs.
  • Avoids unnecessary rerendering for leaderboard page 0 during pagination.
  • Keeps command/event discovery asynchronous and removes one filesystem syscall per traversed entry.

Validation

  • pnpm --filter @statsify/assets test:types
  • pnpm --filter @statsify/assets lint
  • pnpm --filter @statsify/discord test:types
  • pnpm --filter @statsify/discord lint
  • pnpm --filter discord-bot test:types
  • pnpm --filter discord-bot lint
  • pnpm test
  • pnpm --filter @statsify/assets build
  • pnpm --filter @statsify/discord build
  • pnpm --filter discord-bot build

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
statsify Ready Ready Preview, Comment May 12, 2026 0:20am

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