commit 5672d305fae0ef2b4e6c9582d45af790a06fa134 from: Stefan Sperling date: Wed Mar 18 16:13:46 2020 UTC waste less time on sending progress messages over the privsep pipe commit - 160bbe2e336908947c078a78e3ae58100a38e9fc commit + 5672d305fae0ef2b4e6c9582d45af790a06fa134 blob - d86b89f565dfeea38e788819fdee0e1e71c6817d blob + 6a3bed95d5319a66b970cafd9a692e11ff2877d6 --- libexec/got-fetch-pack/got-fetch-pack.c +++ libexec/got-fetch-pack/got-fetch-pack.c @@ -420,7 +420,6 @@ static const struct got_error * fetch_progress(struct imsgbuf *ibuf, const char *buf, size_t len) { int i; - if (len == 0) return NULL; @@ -470,7 +469,7 @@ fetch_pack(int fd, int packfd, struct got_object_id *p struct got_object_id *have, *want; int is_firstpkt = 1, nref = 0, refsz = 16; int i, n, req; - off_t packsz; + off_t packsz = 0, last_reported_packsz = 0; char *id_str = NULL, *refname = NULL; char *server_capabilities = NULL, *my_capabilities = NULL; struct got_pathlist_head symrefs; @@ -621,7 +620,6 @@ fetch_pack(int fd, int packfd, struct got_object_id *p strstr(my_capabilities, GOT_CAPA_SIDE_BAND_64K) != NULL) have_sidebands = 1; - packsz = 0; while (1) { ssize_t r = 0, w; int datalen = -1; @@ -709,10 +707,19 @@ fetch_pack(int fd, int packfd, struct got_object_id *p goto done; } packsz += w; - err = got_privsep_send_fetch_download_progress(ibuf, packsz); - if (err) - goto done; + + /* Don't send too many progress privsep messages. */ + if (packsz > last_reported_packsz + 1024) { + err = got_privsep_send_fetch_download_progress(ibuf, + packsz); + if (err) + goto done; + last_reported_packsz = packsz; + } } + err = got_privsep_send_fetch_download_progress(ibuf, packsz); + if (err) + goto done; done: TAILQ_FOREACH(pe, &symrefs, entry) { free((void *)pe->path); blob - b4e4dc21f9308f616d81790239027df7bcacdb7b blob + 1ac94bd4c17f3cabcf5eb316df8b8297a215640d --- libexec/got-index-pack/got-index-pack.c +++ libexec/got-index-pack/got-index-pack.c @@ -562,6 +562,8 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmp ssize_t r, w; int pass, have_ref_deltas = 0, first_delta_idx = -1; size_t mapoff = 0; + int p_indexed = 0, last_p_indexed = -1; + int p_resolved = 0, last_p_resolved = -1; /* Check pack file header. */ if (pack->map) { @@ -649,10 +651,15 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmp */ pass = 1; for (i = 0; i < nobj; i++) { - err = got_privsep_send_index_pack_progress(ibuf, nobj, i + 1, - nloose, 0); - if (err) - goto done; + /* Don't send too many progress privsep messages. */ + p_indexed = ((i + 1) * 100) / nobj; + if (p_indexed != last_p_indexed) { + err = got_privsep_send_index_pack_progress(ibuf, + nobj, i + 1, nloose, 0); + if (err) + goto done; + last_p_indexed = p_indexed; + } obj = &objects[i]; obj->crc = crc32(0L, NULL, 0); @@ -750,10 +757,15 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmp n++; if (have_ref_deltas) update_packidx(&packidx, nobj, obj); - err = got_privsep_send_index_pack_progress(ibuf, - nobj, nobj, nloose, nresolved + n); - if (err) - goto done; + /* Don't send too many progress privsep messages. */ + p_resolved = ((nresolved + n) * 100) / nobj; + if (p_resolved != last_p_resolved) { + err = got_privsep_send_index_pack_progress(ibuf, + nobj, nobj, nloose, nresolved + n); + if (err) + goto done; + last_p_resolved = p_resolved; + } } if (pass++ > 3 && n == 0) {