diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ccf0a70..130e3e94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.37.1 + +* Reduce maximum memory used for vertex sorting + # 2.37.0 * Speed up tile-join overzooming and make it use less memory, by not including empty child tiles in the enumeration diff --git a/main.cpp b/main.cpp index 2c303a99..cb6060a9 100644 --- a/main.cpp +++ b/main.cpp @@ -2041,7 +2041,7 @@ std::pair read_input(std::vector &sources, char *fname, i vertex_readers.push_back(readers[i].vertexfile); rewind(readers[i].vertexfile); } - fqsort(vertex_readers, sizeof(vertex), vertexcmp, vertex_out, memsize / 10); + fqsort(vertex_readers, sizeof(vertex), vertexcmp, vertex_out, memsize / 20); for (size_t i = 0; i < CPUS; i++) { if (fclose(readers[i].vertexfile) != 0) { @@ -2107,7 +2107,7 @@ std::pair read_input(std::vector &sources, char *fname, i rewind(readers[i].nodefile); } - fqsort(node_readers, sizeof(node), nodecmp, node_out, memsize / 10); + fqsort(node_readers, sizeof(node), nodecmp, node_out, memsize / 20); for (size_t i = 0; i < CPUS; i++) { if (fclose(readers[i].nodefile) != 0) { diff --git a/sort.cpp b/sort.cpp index 4edb4959..c5350c8b 100644 --- a/sort.cpp +++ b/sort.cpp @@ -4,12 +4,16 @@ #include #include -#define MAX_MEMORY (10 * 1024 * 1024) +#define MAX_MEMORY (1024 * 1024 * 1024) // 1 GB void fqsort(std::vector &inputs, size_t width, int (*cmp)(const void *, const void *), FILE *out, size_t mem) { std::string pivot; FILE *fp1, *fp2; + if (mem > MAX_MEMORY) { + mem = MAX_MEMORY; + } + { // read some elements into memory to choose a pivot from // diff --git a/version.hpp b/version.hpp index 5cd56cb7..1fbbe1a5 100644 --- a/version.hpp +++ b/version.hpp @@ -1,6 +1,6 @@ #ifndef VERSION_HPP #define VERSION_HPP -#define VERSION "v2.37.0" +#define VERSION "v2.37.1" #endif