⚡ 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:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user