Skip to content

perf: Lazy-load loader input/output to reduce data volume by 90%+#1525

Merged
yifancong merged 8 commits intomainfrom
copilot/reduce-loader-data-volume
Feb 10, 2026
Merged

perf: Lazy-load loader input/output to reduce data volume by 90%+#1525
yifancong merged 8 commits intomainfrom
copilot/reduce-loader-data-volume

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

Loader data includes input and result code strings that can reach hundreds of KB per loader, causing transfer sizes of 100+ MB and UI degradation. These fields are rarely viewed but always transmitted.

Changes

API Layer - Strip large fields from detail responses

  • getLoaderFileDetails() now omits input/result fields
  • GetLoaderFileInputAndOutput API correctly fetches code on-demand (fixed implementation bug)
  • Type signature updated: Omit<LoaderTransformData, 'input' | 'result'>

UI Layer - Fetch code when user views it

  • LoaderExecutions component lazy-loads via useEffect when "Loader Details" tab becomes active
  • Loading spinner during fetch
  • Simplified dependency array to avoid stale closures
// Before: input/result always included in loader data
const loader = loaders[currentIndex];
const before = loader.input || '';

// After: fetch on-demand when tab is viewed
useEffect(() => {
  if (activeKey === 'loaderDetails' && dataLoader) {
    dataLoader
      .loadAPI(SDK.ServerAPI.API.GetLoaderFileInputAndOutput, {
        file: resource.path,
        loader: loader.loader,
        loaderIndex: loader.loaderIndex,
      })
      .then(setLoaderCode);
  }
}, [currentIndex, activeKey, resource.path, dataLoader]);

Impact: Initial loader detail requests reduced from ~hundreds of KB to ~10 KB per file. Code still available but fetched only when user switches to code view tab.

Original prompt

This issue occurs because the loader data, including result codes, becomes too large and degrades UI performance, especially when navigating the loader timeline or analysis views in rsdoctor. Large datasets like module graphs, chunk graphs, and loader results can amount to hundreds of megabytes, causing loading times of 30 seconds or more, or even failure under certain modern browsers.

To address this:

  1. Reduce Loader Data Volume: Avoid unnecessarily storing large outputs like loader result codes. Consider stripping or summarizing this information.

  2. Lazy Loading: Implement lazy loading for heavy data blobs. For example, load metadata and indexes upfront, and defer details or render them dynamically when users interact with UI elements like the loader timeline.

  3. Data Compression: Compress the data before shipping to the UI. On the backend side, ensure effective JSON minification and redundant object elimination when possible.

  4. Pagination or Chunking: Break down large data chunks into smaller, more manageable fragments, both on the UI and API endpoints. Enabling pagination could avoid hitting browser memory limits.

  5. Browser Rendering Optimization: Update the UI tooling to render large lists using windowing libraries such as react-window or react-virtualized. These libraries optimize DOM rendering for large datasets.

  6. Profiling Usage: Set up performance benchmarks to confirm areas with maximum lag, particular scenarios that demand higher heap memory (e.g., Chrome Dev Tools) while debugging rsdoctor parser loops.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Related MR: #1521

Copilot AI and others added 4 commits February 4, 2026 06:58
…olume

Co-authored-by: yifancong <18437716+yifancong@users.noreply.github.com>
Co-authored-by: yifancong <18437716+yifancong@users.noreply.github.com>
…dencies

Co-authored-by: yifancong <18437716+yifancong@users.noreply.github.com>
Co-authored-by: yifancong <18437716+yifancong@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve UI performance by reducing loader data volume Lazy-load loader input/output to reduce data volume by 90%+ Feb 4, 2026
Copilot AI requested a review from yifancong February 4, 2026 07:10
@yifancong yifancong marked this pull request as ready for review February 10, 2026 03:43
Copilot AI review requested due to automatic review settings February 10, 2026 03:43
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 10, 2026

Deploying rsdoctor with  Cloudflare Pages  Cloudflare Pages

Latest commit: e36dcfb
Status: ✅  Deploy successful!
Preview URL: https://33ddd113.rsdoctor.pages.dev
Branch Preview URL: https://copilot-reduce-loader-data-v.rsdoctor.pages.dev

View logs

@yifancong yifancong changed the title Lazy-load loader input/output to reduce data volume by 90%+ feat: Lazy-load loader input/output to reduce data volume by 90%+ Feb 10, 2026
@yifancong yifancong changed the title feat: Lazy-load loader input/output to reduce data volume by 90%+ perf: Lazy-load loader input/output to reduce data volume by 90%+ Feb 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces loader-related payload sizes by removing large input/result code blobs from loader detail responses and fetching them only when needed, improving UI responsiveness for large manifests.

Changes:

  • Strip input/result from getLoaderFileDetails() and update the GetLoaderFileDetails response type accordingly.
  • Fix APIDataLoader routing for GetLoaderFileInputAndOutput to correctly fetch per-loader code on demand.
  • Update LoaderExecutions to request loader code via GetLoaderFileInputAndOutput, and add unit tests for the new behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/utils/src/common/loader.ts Omits large input/result fields from loader details response.
packages/utils/src/common/data/index.ts Fixes GetLoaderFileInputAndOutput dispatch to call the correct loader utility with correct params.
packages/types/src/sdk/server/apis/loader.ts Updates API response typing for GetLoaderFileDetails to omit input/result.
packages/components/src/components/Loader/executions.tsx Switches loader code display to on-demand fetching via ServerAPIProvider.
packages/utils/tests/common/loader.test.ts Adds tests asserting stripped fields and on-demand input/output retrieval.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yifancong yifancong force-pushed the copilot/reduce-loader-data-volume branch from 90c5439 to c3ae899 Compare February 10, 2026 06:35
@yifancong yifancong requested a review from fansenze February 10, 2026 06:37
@yifancong yifancong merged commit e12c061 into main Feb 10, 2026
6 checks passed
@yifancong yifancong deleted the copilot/reduce-loader-data-volume branch February 10, 2026 07:09
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.

3 participants