⚡ Bolt: optimize synthetic embedding generation#271
Conversation
This commit implements several performance improvements to the synthetic embedding generation process: - Replaces crypto.createHash state machines with Node 22's one-shot crypto.hash. - Replaces expensive Number(val.toFixed(8)) rounding with faster Math.round. - Replaces Array.from/map chains with manual for loops and pre-allocated arrays. - Eliminates redundant text normalization calls in the embedding hot path. Measurable impact: ~2.5x speedup (940ms -> 370ms for 100 embeddings) while maintaining bit-for-bit deterministic output. Co-authored-by: hackerxj2010 <198651211+hackerxj2010@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. |
💡 What
Optimized synthetic embedding generation in
@jeanbot/aiby:crypto.hash).toFixed) with faster mathematical operations.🎯 Why
Synthetic embedding generation is a heavy operation used as a fallback or for testing. Profiling identified significant overhead in:
crypto.Hashobjects repeatedly in loops.normalizeTextpasses on the same input strings.📊 Impact
🔬 Measurement
biome lintand all existing workspace tests.PR created automatically by Jules for task 10311477753374293783 started by @hackerxj2010