git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] Improve progress display in kB range.

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 22, 2009, 19:44 UTC
Message-ID
<7vljps324a.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<m34owgoj08.fsf@lugabout.jhcloos.org>
James Cloos <cloos@jhcloos.com> writes:
Show 26 quoted lines
> |> Therefore, in practice — and as I have witnessed several thousand times
> |> without ever having seen a contrary example — display_throughput() is
> |> called *durring* a download only when total & 0xFFF == 0xFFF.
>
> Another possibility is an off-by-one error.  The relevant part of fill()
> looks like:
>
> ,----< excerpt from index-pack.c:fill() >
> |   do {
> |     ssize_t ret = xread(input_fd, input_buffer + input_len,
> |                         sizeof(input_buffer) - input_len);
> |     if (ret <= 0) {
> |       if (!ret)
> |         die("early EOF");
> |       die("read error on input: %s", strerror(errno));
> |     }
> |     input_len += ret;
> |     if (from_stdin)
> |       display_throughput(progress, consumed_bytes + input_len);
> |   } while (input_len < min);
> |   return input_buffer;
> | }
> `----
>
> if *(input_buffer + ret) is the last read octet rather than the next
> empty octet, that would also explain what I see.

After checking "ret" from xread(), input_len is incremented by that amount, and the next iteration gives "input_buffer + input_len" to xread(). If input_buffer[ret] _were_ the last octet read, your loop would be discarding that octet when you call more than one xread() to fill the buffer.

Previous: James CloosNext: James Cloos
Message 8 of 13 in “Improve progress display in kB range.”
  1. 0/1 Improve progress display in kB range.James Cloos, Apr 19, 2009
  2. 1/1 Improve progress display in kB range.James Cloos, Apr 19, 2009
  3. Nicolas PitreApr 21, 2009
  4. James CloosApr 21, 2009
  5. Nicolas PitreApr 21, 2009
  6. James CloosApr 21, 2009
  7. James CloosApr 22, 2009
  8. Junio C HamanoApr 22, 2009
  9. James CloosApr 22, 2009
  10. Johannes SixtApr 23, 2009
  11. James CloosApr 24, 2009
  12. Nicolas PitreApr 24, 2009
  13. James CloosApr 24, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.