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

Re: RFC: New diff-delta.c implementation

From
Junio C Hamano <junkio@cox.net>
Date
Apr 22, 2006, 17:29 UTC
Message-ID
<7vslo5ikmk.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0604220835190.2215@localhost.localdomain>
Nicolas Pitre <nico@cam.org> writes:
Show 8 quoted lines
> Well, actually I was measuring a 10% speed improvement with a quick and 
> naive (not memory efficient) approach for pack-objects with the current 
> algorithm.
>...
> The idea to avoid memory pressure is to reverse the window processing 
> such that the object to delta against is constant for the entire window 
> instead of the current logic where the target object is constant.  This 
> way there would be only one index in memory at all time.
Your are right.  The first led to the latter unexplored idea.

I expect to be offline most of the day today, and have other things I can work on for the next few days anyway, so if you or somebody else have an inclination and energy to reverse the delta window, I would appreciate that.

Maybe the calling convention of diff-delta.c would become something like this?

struct delta_index; /* opaque to the caller; implementation
		     * defines what's in it.
                     */
/* returns a newly allocated struct delta_index.
 * input "buf" pointer can be stored in the struct, but "buf"
 * does not belong to diff-delta module (i.e. borrowed reference).
 */
struct delta_index *delta_index(
  void *buf,			/* input: from buffer */
  unsigned long size,		/* input: from size */
);
/* ... so free the structure and its internal data, but
 * do not free the borrowed reference!
 */
void free_delta_index(struct delta_index *);
/* Take "from", an already preprocessed delta_index for the
 * traditional from_buffer/from_size, and to_buf/to_size, and
 * produce delta in newly allocated buffer (caller should
 * free() when it is done), and return the result size in
 * *delta_size.  Stop early if the result would exceed max_size.
 */
void *diff_delta(
    struct delta_index *from,	/* input: prepared by delta_index() */
    void *to_buf,		/* input: destination buffer */
    unsigned long to_size,	/* input: destination size */
    unsigned long *delta_size,	/* output: result size */
    unsigned long max_size	/* input: do not waste cycles if
                                   you cannot generate result
                                   smaller than this */
);
and the calling convention would be:
	struct unpacked *s, *d;
	unsigned long max_size;
	/* precompute the index */
	struct delta_index *src = delta_index(s->data, s->entry->size);
	/* do the delta */
        void *delta_buf = diff_delta(src, d->data, d->entry->size,
                                     &sz, max_size);
        /* do useful thing here on delta_buf and sz */
        free(delta_buf);
	/* the caller can reuse *src with other *d,
         * but when it is done...
         */
        free_delta_index(src);
Previous: Geert BoschNext: Nicolas Pitre
Message 13 of 32 in “RFC: New diff-delta.c implementation”
  1. Geert BoschApr 21, 2006
  2. Nicolas PitreApr 22, 2006
  3. Geert BoschApr 22, 2006
  4. Junio C HamanoApr 22, 2006
  5. Geert BoschApr 22, 2006
  6. Nicolas PitreApr 22, 2006
  7. Geert BoschApr 22, 2006
  8. Junio C HamanoApr 22, 2006
  9. Geert BoschApr 22, 2006
  10. Junio C HamanoApr 22, 2006
  11. Nicolas PitreApr 22, 2006
  12. Geert BoschApr 22, 2006
  13. Junio C HamanoApr 22, 2006
  14. Nicolas PitreApr 22, 2006
  15. Davide LibenziApr 22, 2006
  16. Geert BoschApr 22, 2006
  17. Rene ScharfeApr 22, 2006
  18. Geert BoschApr 24, 2006
  19. Nicolas PitreApr 24, 2006
  20. Geert BoschApr 24, 2006
  21. Nicolas PitreApr 24, 2006
  22. Geert BoschApr 24, 2006
  23. Geert BoschApr 24, 2006
  24. Geert BoschApr 24, 2006
  25. Rutger NijlunsingApr 24, 2006
  26. Petr BaudisApr 24, 2006
  27. Geert BoschApr 24, 2006
  28. Rene ScharfeApr 25, 2006
  29. Davide LibenziApr 22, 2006
  30. Geert BoschApr 23, 2006
  31. Davide LibenziApr 24, 2006
  32. Geert BoschApr 24, 2006

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.