⚡ Bolt: optimize risk signals insertion in RiskRepository#23649
⚡ Bolt: optimize risk signals insertion in RiskRepository#23649BrianCLong merged 1 commit intomainfrom
Conversation
- Hoisted default `new Date()` creation out of the batch loop to reduce redundant object allocations. - Removed unnecessary `RETURNING *` clause and mapping loop for risk signals, as they are not used in the final return value of `saveRiskScore`. - Reduced database overhead and application memory usage during high-volume risk signal ingestion. Co-authored-by: BrianCLong <6404035+BrianCLong@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request optimizes the RiskRepository by hoisting the default timestamp creation for risk signals to avoid redundant object allocations during batched inserts. Additionally, it removes the RETURNING * clause and the subsequent mapping loop for inserted signals, as they are not required for the return value. I have no feedback to provide.
This PR implements a performance optimization in
RiskRepository.tsto improve the efficiency of risk signal ingestion.💡 What
new Date()) outside of the signal processing loops.RETURNING *clause from therisk_signalsbatchINSERTquery.savedSignalsarray and the subsequent loop that was mapping database results to JavaScript objects.🎯 Why
Dateobject was instantiated for every signal without adetectedAttimestamp. For large batches (e.g., 100+ signals), this created unnecessary GC pressure.saveRiskScoremethod only returns theRiskScoreobject, not the signals.📊 Impact
RETURNINGclause.🔬 Measurement
node --checkto ensure syntax validity.server/src/db/repositories/__tests__/RiskRepository.test.tsshould be run to confirm functional parity.PR created automatically by Jules for task 13584210523542231955 started by @BrianCLong