⚡ Bolt: [performance improvement] Optimize map bucketing memory and deduplicate getMapData promises

Co-authored-by: ralksta <16941050+ralksta@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot]
2026-05-05 10:44:12 +00:00
parent 56f0305763
commit 59321d88ca
2 changed files with 90 additions and 62 deletions

View File

@@ -14,3 +14,7 @@
## 2026-04-24 - [OOM prevention through promise chunking]
**Learning:** When fetching unbounded large collections (like photo albums and their assets), using concurrent `Promise.all` over the entire array can cause Node.js Out of Memory (OOM) crashes.
**Action:** Instead of `Promise.all(array.map(...))`, use a chunked data fetching approach (e.g., `Promise.all` within a `for` loop processing chunks of e.g. 10 items) to balance memory constraints with concurrent network speed.
## 2024-05-30 - [O(1) Memory Bucketing for Coordinate Aggregation]
**Learning:** When bucketing or grouping large datasets (e.g., thousands of map coordinates into geographical clusters), array allocations (`[].push()`) followed by `reduce` operations create an O(N) memory overhead per bucket and expensive post-processing loops.
**Action:** Replace memory-heavy array collections with running statistical accumulators (e.g., `latSum`, `lngSum`, `count`) directly on the bucket. This reduces bucket memory from O(N) to O(1).