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

Re: [PATCH 3/5] Add pack-objects window memory usage limit

From
Nicolas Pitre <nico@cam.org>
Date
Jul 12, 2007, 04:25 UTC
Message-ID
<alpine.LFD.0.999.0707112356330.32552@xanadu.home>
In-Reply-To
<11842100582887-git-send-email-bdowning@lavos.net>
On Wed, 11 Jul 2007, Brian Downing wrote:
Show 11 quoted lines
> +		while (window_memory_limit &&
> +		       window_memory_usage > window_memory_limit &&
> +		       count > 1) {
> +			uint32_t tail = idx - count;
> +			if (tail > idx) {
> +				tail += window + 1;
> +				tail %= window;
> +			}
> +			free_unpacked(array + tail);
> +			count--;
> +		}

This is bogus. Suppose window = 10 and only array entries 8, 9, 0, 1 and 2 are populated. In that case idx = 2 and count should be 4 (not counting the current entry yet). You want to evict entry 8.

	-- tail = 2 - 4 = -2 (or a big uint32_t value)
	-- tail > idx is true
	-- tail += window + 1 -> -2 + 10 + 1 = 9
	-- tail %= window is useless
	-- you free entry 9 instead of entry 8.
Instead, you should do:
	tail = idx - count;
	if (tail > idx)
		tail += window;
or even:
	tail = (idx + window - count) % window;
>  		next:
>  		idx++;
> +		if (count < window)
> +			count++;
And of course you want:
	if (count + 1 < window)
		count++;
So not to count the new entry when the window gets full.
Nicolas
Previous: Brian DowningNext: Brian Downing
Message 5 of 10 in “Memory-limited pack-object window support”
  1. 0/5 Memory-limited pack-object window supportBrian Downing, Jul 12, 2007
  2. 1/5 Don't try to delta if target is much smaller than sourceBrian Downing, Jul 12, 2007
  3. 2/5 Support fetching the memory usage of a delta indexBrian Downing, Jul 12, 2007
  4. 3/5 Add pack-objects window memory usage limitBrian Downing, Jul 12, 2007
  5. Nicolas PitreJul 12, 2007
  6. Brian DowningJul 12, 2007
  7. 4/5 Add --window-bytes option to git-repackBrian Downing, Jul 12, 2007
  8. 5/5 Add documentation for --window-bytes, pack.windowBytesBrian Downing, Jul 12, 2007
  9. Nicolas PitreJul 12, 2007
  10. Nicolas PitreJul 12, 2007

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.