Flush stderr after logging progress

This commit is contained in:
Erica Fischer
2022-12-30 12:38:37 -08:00
parent eef29084ec
commit fc8007a2ab
5 changed files with 11 additions and 0 deletions
+6
View File
@@ -335,6 +335,7 @@ static void merge(struct mergelist *merges, size_t nmerges, unsigned char *map,
*progress += (ix.end - ix.start) * 3 / 4; *progress += (ix.end - ix.start) * 3 / 4;
if (!quiet && !quiet_progress && progress_time() && 100 * *progress / *progress_max != *progress_reported) { if (!quiet && !quiet_progress && progress_time() && 100 * *progress / *progress_max != *progress_reported) {
fprintf(stderr, "Reordering geometry: %lld%% \r", 100 * *progress / *progress_max); fprintf(stderr, "Reordering geometry: %lld%% \r", 100 * *progress / *progress_max);
fflush(stderr);
*progress_reported = 100 * *progress / *progress_max; *progress_reported = 100 * *progress / *progress_max;
} }
@@ -795,6 +796,7 @@ void radix1(int *geomfds_in, int *indexfds_in, int inputs, int prefix, int split
*progress += (ix.end - ix.start) / 4; *progress += (ix.end - ix.start) / 4;
if (!quiet && !quiet_progress && progress_time() && 100 * *progress / *progress_max != *progress_reported) { if (!quiet && !quiet_progress && progress_time() && 100 * *progress / *progress_max != *progress_reported) {
fprintf(stderr, "Reordering geometry: %lld%% \r", 100 * *progress / *progress_max); fprintf(stderr, "Reordering geometry: %lld%% \r", 100 * *progress / *progress_max);
fflush(stderr);
*progress_reported = 100 * *progress / *progress_max; *progress_reported = 100 * *progress / *progress_max;
} }
@@ -967,6 +969,7 @@ void radix1(int *geomfds_in, int *indexfds_in, int inputs, int prefix, int split
*progress += (ix.end - ix.start) * 3 / 4; *progress += (ix.end - ix.start) * 3 / 4;
if (!quiet && !quiet_progress && progress_time() && 100 * *progress / *progress_max != *progress_reported) { if (!quiet && !quiet_progress && progress_time() && 100 * *progress / *progress_max != *progress_reported) {
fprintf(stderr, "Reordering geometry: %lld%% \r", 100 * *progress / *progress_max); fprintf(stderr, "Reordering geometry: %lld%% \r", 100 * *progress / *progress_max);
fflush(stderr);
*progress_reported = 100 * *progress / *progress_max; *progress_reported = 100 * *progress / *progress_max;
} }
@@ -1787,6 +1790,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
if (!quiet) { if (!quiet) {
fprintf(stderr, " \r"); fprintf(stderr, " \r");
// (stderr, "Read 10000.00 million features\r", *progress_seq / 1000000.0); // (stderr, "Read 10000.00 million features\r", *progress_seq / 1000000.0);
fflush(stderr);
} }
for (size_t i = 0; i < CPUS; i++) { for (size_t i = 0; i < CPUS; i++) {
@@ -2004,6 +2008,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
progress = nprogress; progress = nprogress;
if (!quiet && !quiet_progress && progress_time()) { if (!quiet && !quiet_progress && progress_time()) {
fprintf(stderr, "Maxzoom: %lld%% \r", progress); fprintf(stderr, "Maxzoom: %lld%% \r", progress);
fflush(stderr);
} }
} }
} }
@@ -2178,6 +2183,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
progress = nprogress; progress = nprogress;
if (!quiet && !quiet_progress && progress_time()) { if (!quiet && !quiet_progress && progress_time()) {
fprintf(stderr, "Base zoom/drop rate: %lld%% \r", progress); fprintf(stderr, "Base zoom/drop rate: %lld%% \r", progress);
fflush(stderr);
} }
} }
+1
View File
@@ -200,6 +200,7 @@ void mbtiles_map_image_to_pmtiles(char *fname, metadata m, bool tile_compression
pmtiles::zxy zxy = pmtiles::tileid_to_zxy(tile_id); pmtiles::zxy zxy = pmtiles::tileid_to_zxy(tile_id);
if (!quiet && !quiet_progress) { if (!quiet && !quiet_progress) {
fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, zxy.z, zxy.x, zxy.y); fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, zxy.z, zxy.x, zxy.y);
fflush(stderr);
} }
sqlite3_bind_int(map_stmt, 1, zxy.z); sqlite3_bind_int(map_stmt, 1, zxy.z);
sqlite3_bind_int(map_stmt, 2, zxy.x); sqlite3_bind_int(map_stmt, 2, zxy.x);
+1
View File
@@ -713,6 +713,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
checkdisk(sst->readers); checkdisk(sst->readers);
if (!quiet && !quiet_progress && progress_time()) { if (!quiet && !quiet_progress && progress_time()) {
fprintf(stderr, "Read %.2f million features\r", *sst->progress_seq / 1000000.0); fprintf(stderr, "Read %.2f million features\r", *sst->progress_seq / 1000000.0);
fflush(stderr);
} }
} }
(*(sst->progress_seq))++; (*(sst->progress_seq))++;
+1
View File
@@ -588,6 +588,7 @@ void handle_tasks(std::map<zxy, std::vector<std::string>> &tasks, std::vector<st
if (ai == tasks.begin()) { if (ai == tasks.begin()) {
if (!quiet) { if (!quiet) {
fprintf(stderr, "%lld/%lld/%lld \r", ai->first.z, ai->first.x, ai->first.y); fprintf(stderr, "%lld/%lld/%lld \r", ai->first.z, ai->first.x, ai->first.y);
fflush(stderr);
} }
} }
} }
+2
View File
@@ -1436,6 +1436,7 @@ serial_feature next_feature(FILE *geoms, std::atomic<long long> *geompos_in, int
if (progress >= *oprogress + 0.1) { if (progress >= *oprogress + 0.1) {
if (!quiet && !quiet_progress && progress_time()) { if (!quiet && !quiet_progress && progress_time()) {
fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty); fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty);
fflush(stderr);
} }
if (logger.json_enabled && progress_time()) { if (logger.json_enabled && progress_time()) {
logger.progress_tile(progress); logger.progress_tile(progress);
@@ -2562,6 +2563,7 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *stri
if (progress >= oprogress + 0.1) { if (progress >= oprogress + 0.1) {
if (!quiet && !quiet_progress && progress_time()) { if (!quiet && !quiet_progress && progress_time()) {
fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty); fprintf(stderr, " %3.1f%% %d/%u/%u \r", progress, z, tx, ty);
fflush(stderr);
} }
if (logger.json_enabled && progress_time()) { if (logger.json_enabled && progress_time()) {
logger.progress_tile(progress); logger.progress_tile(progress);