From 015c9e4e630e8319b7f218193bc049eda0bd7f0b Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Thu, 30 Nov 2023 11:37:35 -0800 Subject: [PATCH] Use less memory for sub-sorting --- main.cpp | 4 ++-- sort.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 8b7eddb82..e317da318 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, 0); + fqsort(vertex_readers, sizeof(vertex), vertexcmp, vertex_out, memsize / 20, 0); 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, 0); + fqsort(node_readers, sizeof(node), nodecmp, node_out, memsize / 20, 0); for (size_t i = 0; i < CPUS; i++) { if (fclose(readers[i].nodefile) != 0) { diff --git a/sort.cpp b/sort.cpp index de75d5e87..467466a5a 100644 --- a/sort.cpp +++ b/sort.cpp @@ -10,6 +10,7 @@ void fqsort(std::vector &inputs, size_t width, int (*cmp)(const void *, std::string pivot; FILE *fp1, *fp2; size_t first = 0, second = 0; + fprintf(stderr, "using maximum of %zu bytes of memory for sort\n", mem); { // read some elements into memory to choose a pivot from