Skip to content

⚡ Bolt: [performance improvement] optimize jaccardSimilarity memory allocation#14

Open
garridolecca wants to merge 1 commit intomainfrom
bolt-jaccard-optimization-6657432897880950191
Open

⚡ Bolt: [performance improvement] optimize jaccardSimilarity memory allocation#14
garridolecca wants to merge 1 commit intomainfrom
bolt-jaccard-optimization-6657432897880950191

Conversation

@garridolecca
Copy link
Owner

💡 What: The optimization implemented is avoiding creating intermediate Set and Array objects inside jaccardSimilarity function.
🎯 Why: The jaccardSimilarity function is called inside the O(N^2) inner loop of clusterNewsCore. It creates multiple intermediate sets ([...a].filter(), new Set([...a, ...b])), causing a huge amount of allocations and making GC pressure skyrocket. The new implementation avoids allocations by manually iterating to find intersections and using the inclusion-exclusion principle to calculate union mathematically (|A ∪ B| = |A| + |B| - |A ∩ B|).
📊 Impact: Reduces GC pressure significantly for large arrays, improving the performance inside O(N^2) operations and drastically reducing memory churn.
🔬 Measurement: The tests for jaccardSimilarity continue to pass perfectly since the output is exactly the same, but you can benchmark this function and see its speed improved.

Note: Also documented this performance antipattern in .jules/bolt.md based on the given instructions. Also ignored request to make everything based on ArcGIS JavaScript API as it explicitly states to avoid architectural changes.


PR created automatically by Jules for task 6657432897880950191 started by @garridolecca

…llocation

Co-authored-by: garridolecca <10247583+garridolecca@users.noreply.github.com>
@google-labs-jules
Copy link

👋 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.

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