parallelize generation and notification paths with Promise.all#1687
parallelize generation and notification paths with Promise.all#1687brdandu wants to merge 1 commit intoproject-chip:masterfrom
Conversation
brdandu
commented
Feb 17, 2026
- Template engine: run iterative iterations (e.g. per-cluster) and deferred blocks in parallel; use per-iteration options to avoid races.
- Generation engine: load template JSON files and package options in parallel; run generateAndWriteFiles for multiple template packages in parallel per .zap file.
- ClustersHelper: fetch cluster details per endpoint in parallel in loadEndpoints().
- helper-endpointconfig: resolve attribute default values in parallel per cluster, then process in order.
- query-session-notification: run deleteNotification and setWarningIfMessageNotExists in parallel where multiple IDs/messages are handled.
- Github ZAP#1659
- Template engine: run iterative iterations (e.g. per-cluster) and deferred blocks in parallel; use per-iteration options to avoid races. - Generation engine: load template JSON files and package options in parallel; run generateAndWriteFiles for multiple template packages in parallel per .zap file. - ClustersHelper: fetch cluster details per endpoint in parallel in loadEndpoints(). - helper-endpointconfig: resolve attribute default values in parallel per cluster, then process in order. - query-session-notification: run deleteNotification and setWarningIfMessageNotExists in parallel where multiple IDs/messages are handled. - Github ZAP#1659
Summary of ChangesHello @brdandu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the performance of various operations across the application by introducing parallel execution using 'Promise.all'. The changes target several key areas, including database notification handling, template generation, cluster data loading, and attribute configuration, to reduce overall processing time and enhance responsiveness. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request successfully parallelizes several asynchronous paths in the template and generation engines, which should improve performance during file generation and notification handling. Key improvements include the use of per-iteration options in produceIterativeContent to avoid race conditions and the parallelization of DB queries for cluster details and attribute defaults. However, some parallelized paths introduce race conditions, specifically in notification creation and generation logging, which need to be addressed to ensure data consistency. Additionally, the parallelization of template loading is currently limited by global database transaction locks.
| await Promise.all( | ||
| warningMessage.map((message) => | ||
| setWarningIfMessageNotExists(db, sessionId, message) | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Parallelizing setWarningIfMessageNotExists introduces a race condition. Since this function performs a "check-then-insert" operation without a database lock or transaction, concurrent calls for the same message (or duplicate messages in the array) can result in multiple identical notifications being created. It is safer to process these sequentially to maintain the uniqueness check.
for (const message of warningMessage) {
await setWarningIfMessageNotExists(db, sessionId, message)
}| const loadResults = await Promise.all( | ||
| filesToLoad.map((jsonFile) => loadGenTemplatesJsonFile(db, jsonFile)) | ||
| ) |
There was a problem hiding this comment.
While Promise.all is used here to parallelize template loading, the underlying loadGenTemplatesJsonFile function is constrained by a global database transaction lock (dbApi.dbBeginTransaction). This results in serialized execution at the database level, with concurrent calls polling the lock every 100ms, which negates the performance benefits of parallelization for the database-heavy portions of the task.