Use 32-bit offsets in the string pool search tree to reduce its size

This commit is contained in:
Eric Fischer
2017-09-06 15:26:19 -07:00
parent 0f8b32c69f
commit 764a8ac17c
5 changed files with 20 additions and 6 deletions
+4
View File
@@ -1,3 +1,7 @@
## 1.24.1
* Limit the size and depth of the string pool for better performance
## 1.24.0 ## 1.24.0
* Add feature filters using the Mapbox GL Style Specification filter syntax * Add feature filters using the Mapbox GL Style Specification filter syntax
+1 -1
View File
@@ -6,7 +6,7 @@ struct memfile {
char *map; char *map;
long long len; long long len;
long long off; long long off;
long long tree; unsigned long tree;
}; };
struct memfile *memfile_open(int fd); struct memfile *memfile_open(int fd);
+11 -1
View File
@@ -35,7 +35,7 @@ int swizzlecmp(const char *a, const char *b) {
} }
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type) { long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type) {
long long *sp = &treefile->tree; unsigned long *sp = &treefile->tree;
size_t depth = 0; size_t depth = 0;
// In typical data, traversal depth generally stays under 2.5x // In typical data, traversal depth generally stays under 2.5x
@@ -95,6 +95,16 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (off >= LONG_MAX || treefile->off >= LONG_MAX) {
// Tree or pool is bigger than 2GB
static bool warned = false;
if (!warned) {
fprintf(stderr, "Warning: string pool is very large.\n");
warned = true;
}
return off;
}
struct stringpool tsp; struct stringpool tsp;
tsp.left = 0; tsp.left = 0;
tsp.right = 0; tsp.right = 0;
+3 -3
View File
@@ -2,9 +2,9 @@
#define POOL_HPP #define POOL_HPP
struct stringpool { struct stringpool {
long long left; unsigned long left;
long long right; unsigned long right;
long long off; unsigned long off;
}; };
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type); long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type);
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP #ifndef VERSION_HPP
#define VERSION_HPP #define VERSION_HPP
#define VERSION "tippecanoe v1.24.0\n" #define VERSION "tippecanoe v1.24.1\n"
#endif #endif