Optimization: Dividing memory usage by almost 3#189
Optimization: Dividing memory usage by almost 3#189xavierjs wants to merge 2 commits intomapbox:mainfrom
Conversation
|
@mourner Thank you for considering this PR :). It really improves memory usage |
|
@xavierjs thank you for the contribution, this does look very promising! I'll investigate. Worth checking whether the additional nesting can introduce overhead in some situations — maybe we could get away with some other way to store and pass around metrics info that's even less obtrusive. Also, we should benchmark extensively to see how this affects index generation times — there must be some overhead because as far as I remember, creating a typed array is more expensive in terms of CPU time than just an empty array (which is heavily optimized in v8). |
|
Hi @mourner I ran the Maplibre geojson-vt fork benchmarks measuring the duration, and indeed there is a slight performance degradation in the benchmarks (between 5 and 10%) if we set the conversion threshold to -1 (i.e. we always convert to typed array): https://github.com/xavierjs/geojson-vt_mapbox/blob/636a214435167fd25d8ec4db672a0f4918a9b11d/src/feature.js#L40 This is why I set a conversion threshold to 64. With this value there is almost no performance degradation in the benchmarks (less than 3%), but the memory savings are still huge. |
|
Hi @mourner, Just wanted to follow up on this PR when you have a moment. Thank you! |
|
@xavierjs hey, thanks for the reminders — we're looking into this but don't expect us to land it soon, we'll have to explore this extra carefully. There are some things here I'm hesitating about:
I'll let you know after exploring this. |
Hi
Thank you for considering my PR.
This is an implementation of this improvement submitted and merged in Maplibre geojson-vt fork: maplibre/geojson-vt#88
All the tests succeed.