SuperAPI AI Directory

hello-perf

Coding & development

View repository

Updated 10-15 22:12

About this skill

Performance-related code must follow the specifications below.

Before Coding

First locate the performance bottleneck (I/O / computation / memory), then write code.

Query Optimization

  • No N+1 queries: use JOIN, batch loading, dataloader
  • Large datasets must be paginated, do not load everything at once
  • Database indexes cover commonly used query conditions
  • Only query the fields you need (SELECT specific columns, not SELECT *)

Caching Strategy

  • Read-heavy, write-light data → cache (in-memory/Redis)
  • Set a reasonable TTL
  • Cache invalidation strategy: invalidate on write > scheduled expiration
  • Prevent cache penetration (null value caching) and avalanche (random TTL)

Frontend Performance

  • Code splitting + route-level lazy loading
  • Images: WebP/AVIF, lazy loading, responsive srcset
  • Declare width/height or aspect-ratio to prevent layout shift
  • Inline critical CSS, load non-critical CSS asynchronously
  • Use virtual scrolling for lists of 50+ items

Algorithms and Concurrency

  • Mind time complexity, no nested loops processing large datasets (O(n²)+)
  • Map/Set lookup O(1) vs Array.includes O(n)
  • Batch operations are better than item-by-item operations
  • Use debounce/throttle for high-frequency events (scroll/resize/input)

Delivery Checklist

  • No N+1 queries
  • List endpoints are paginated
  • Images are optimized (format/lazy loading/dimension declarations)
  • No nested loops processing large datasets