Reduce tiling memory (#227)

* Trying to reduce memory in tiling

* Let the simplification workers go out of scope earlier

* Bail out quickly once the maximum feature count is reached

* Update changelog and version
This commit is contained in:
Erica Fischer
2024-04-03 07:12:26 -07:00
committed by GitHub
parent 266ef3c286
commit bb4f220678
7 changed files with 656 additions and 526 deletions
+4
View File
@@ -1,3 +1,7 @@
# 2.53.0
* Stop trying to add features to the tile after the feature limit is reached
# 2.52.0 # 2.52.0
* Fix accidental loss (at all zooms) of features that specify an explicit minzoom * Fix accidental loss (at all zooms) of features that specify an explicit minzoom
@@ -9,7 +9,7 @@
"maxzoom": "0", "maxzoom": "0",
"minzoom": "0", "minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles", "name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":1000}]", "strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":201}]",
"type": "overlay", "type": "overlay",
"version": "2" "version": "2"
}, "features": [ }, "features": [
@@ -9,7 +9,7 @@
"maxzoom": "0", "maxzoom": "0",
"minzoom": "0", "minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--drop-densest-as-needed.json.check.mbtiles", "name": "tests/loop/out/-z0_-O200_--drop-densest-as-needed.json.check.mbtiles",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]", "strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
"type": "overlay", "type": "overlay",
"version": "2" "version": "2"
}, "features": [ }, "features": [
@@ -9,7 +9,7 @@
"maxzoom": "0", "maxzoom": "0",
"minzoom": "0", "minzoom": "0",
"name": "tests/loop/out/-z0_-O200_--drop-fraction-as-needed.json.check.mbtiles", "name": "tests/loop/out/-z0_-O200_--drop-fraction-as-needed.json.check.mbtiles",
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]", "strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
"type": "overlay", "type": "overlay",
"version": "2" "version": "2"
}, "features": [ }, "features": [
File diff suppressed because one or more lines are too long
+5 -1
View File
@@ -1875,7 +1875,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
unsigned long long sfindex = sf.index; unsigned long long sfindex = sf.index;
if (sf.geometry.size() > 0) { if (sf.geometry.size() > 0) {
if (lead_features_count > max_tile_size) { if (lead_features_count > max_tile_size || (lead_features_count + other_multiplier_cluster_features_count > max_tile_features && !prevent[P_FEATURE_LIMIT])) {
// Even being maximally conservative, each feature is still going to be // Even being maximally conservative, each feature is still going to be
// at least one byte in the output tile, so this can't possibly work. // at least one byte in the output tile, so this can't possibly work.
skipped++; skipped++;
@@ -2110,6 +2110,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
tasks = 1; tasks = 1;
} }
{
pthread_t pthreads[tasks]; pthread_t pthreads[tasks];
std::vector<simplification_worker_arg> args; std::vector<simplification_worker_arg> args;
args.resize(tasks); args.resize(tasks);
@@ -2140,6 +2141,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
} }
} }
} }
}
for (size_t i = 0; i < features.size(); i++) { for (size_t i = 0; i < features.size(); i++) {
signed char t = features[i].t; signed char t = features[i].t;
@@ -2261,6 +2263,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
} }
if (layer_features[x].geometry.size() == 0) { if (layer_features[x].geometry.size() == 0) {
layer_features[x] = serial_feature();
continue; continue;
} }
@@ -2301,6 +2304,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
} }
layer.features.push_back(std::move(feature)); layer.features.push_back(std::move(feature));
layer_features[x] = serial_feature();
} }
if (layer.features.size() > 0) { if (layer.features.size() > 0) {
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP #ifndef VERSION_HPP
#define VERSION_HPP #define VERSION_HPP
#define VERSION "v2.52.0" #define VERSION "v2.53.0"
#endif #endif