Skip to content

⚡ Bolt: [performance improvement]#424

Closed
aafre wants to merge 1 commit into
mainfrom
bolt-perf-promise-all-15059762609156276201
Closed

⚡ Bolt: [performance improvement]#424
aafre wants to merge 1 commit into
mainfrom
bolt-perf-promise-all-15059762609156276201

Conversation

@aafre
Copy link
Copy Markdown
Owner

@aafre aafre commented Mar 28, 2026

💡 What: Changed the sequential await loop in exportIconsForYAML to use Promise.all across concurrently mapped functions.
🎯 Why: I/O bound tasks like FileReader conversions block synchronously when awaited inside iterative loops. Refactoring to parallel map+Promise.all allows the browser to process file conversions concurrently.
📊 Impact: Significantly speeds up resume generation/export for users with dense icon usage. Reduces cumulative task processing delay.
🔬 Measurement: Verify export functionality via pnpm test and code review. Time exportIconsForYAML operations with 10+ icon assets to observe relative duration drops.


PR created automatically by Jules for task 15059762609156276201 started by @aafre

Replaces a sequential `for...of` await loop with an array of Promises mapping to concurrent I/O operations resolved by `Promise.all()`. This dramatically speeds up export tasks involving large icon libraries.

Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request optimizes the icon export process in useIconRegistry.ts by refactoring a sequential for...of loop into a concurrent implementation using Promise.all(). This change significantly reduces export time for resumes with multiple icons. Additionally, a new learning entry was added to .jules/bolt.md documenting this optimization. The review feedback suggests further improving the code by filtering valid filenames before mapping, which would simplify the logic and enhance type safety.

Comment on lines +175 to +195
const exportPromises = targetFilenames.map(async (filename) => {
const entry = registry[filename];
if (entry) {
try {
const base64Data = await fileToBase64(entry.file);
exportData[filename] = {
data: base64Data,
type: entry.file.type,
size: entry.file.size,
uploadedAt: entry.uploadedAt.toISOString(),
return {
filename,
data: {
data: base64Data,
type: entry.file.type,
size: entry.file.size,
uploadedAt: entry.uploadedAt.toISOString(),
}
};
} catch (error) {
console.warn(`Failed to export icon ${filename}:`, error);
return null;
}
}
}
return null;
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For improved readability and separation of concerns, you can first filter the targetFilenames to get only the ones present in the registry, and then map over the valid filenames. This removes the need for the if (entry) check inside the map callback, simplifying its logic. Additionally, using a type guard in the filter improves type safety by ensuring the filename is a valid key, aligning with repository rules regarding specific union types.

    const exportPromises = targetFilenames
      .filter((filename): filename is keyof typeof registry => !!registry[filename])
      .map(async (filename) => {
        const entry = registry[filename];
        try {
          const base64Data = await fileToBase64(entry.file);
          return {
            filename,
            data: {
              data: base64Data,
              type: entry.file.type,
              size: entry.file.size,
              uploadedAt: entry.uploadedAt.toISOString(),
            },
          };
        } catch (error) {
          console.warn("Failed to export icon " + filename + ":", error);
          return null;
        }
      });
References
  1. To improve type safety and eliminate the need for type assertions, use a specific union type for function parameters that determine the return type, rather than a generic string.

@aafre
Copy link
Copy Markdown
Owner Author

aafre commented Apr 11, 2026

Closing: duplicate of the icon parallelization group (superseded by #421). See #457 for the consolidated Jules batch-2 PR.

@aafre aafre closed this Apr 11, 2026
@google-labs-jules
Copy link
Copy Markdown
Contributor

Closing: duplicate of the icon parallelization group (superseded by #421). See #457 for the consolidated Jules batch-2 PR.

Understood. Acknowledging that this PR is a duplicate and stopping work on this task.

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