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

Re: [PATCH] cherry: cache patch-ids to avoid repeating work

From
Geoffrey Irving <irving@naml.us>
Date
Jul 10, 2008, 14:09 UTC
Message-ID
<7f9d599f0807100709u778f0ab1y28776d7efb831b61@mail.gmail.com>
In-Reply-To
<7f9d599f0807092034n438f0976pf44d4c9305871087@mail.gmail.com>
On Wed, Jul 9, 2008 at 8:34 PM, Geoffrey Irving <irving@naml.us> wrote:
Show 24 quoted lines
> Add cached-sha-map.[ch] implementing a persistent hash map from sha1 to
> sha1.  The map is read with mmap, and completely rewritten if any entries
> change.  It would be good to add incremental update to handle the usual case
> where only a few entries change.
>
> This structure is used by patch-ids.c to cache the mapping from commit to
> patch-id into $GIT_DIR/patch-id-cache.  In the one case I've tested so far,
> this speeds up the second invocation of git-cherry by two orders of
> magnitude.  The caching can be disabled by setting cherry.cachepatchids to
> false.
>
> Original code cannibalized from Johannes Schindelin's notes-index structure.
>
> Signed-off-by: Geoffrey Irving <irving@naml.us>
> ---
>
> Note: there are at least two "holes" in this code.  First, it is impossible
> to verify the validity of the entries (this is impossible to fix).  Second,
> it is possible to write a malicious patch-id-cache file that causes git-cherry
> to go into an infinite loop.  Fixing the loop requires either traversing every
> entry on load (bad) or adding a second loop termination condition to
> find_helper.  Since looping forever is better than returning incorrect
> results, I figured fixing the weaker hole would just result in a false sense
> of security.
Oops: avoiding the infinite loop only requires reading expected O(1)
entries on load, so I can fix that if you like.  It would only be all
of them if it actually did detect the infinite loop.
Geoffrey
Previous: Geoffrey IrvingNext: Johannes Schindelin
Message 7 of 21 in “cherry: cache patch-ids to avoid repeating work”
  1. 1/3 cherry: cache patch-ids to avoid repeating workGeoffrey Irving, Jul 9, 2008
  2. Junio C HamanoJul 9, 2008
  3. Geoffrey IrvingJul 9, 2008
  4. Junio C HamanoJul 9, 2008
  5. Johannes SchindelinJul 9, 2008
  6. cherry: cache patch-ids to avoid repeating workGeoffrey Irving, Jul 10, 2008
  7. Geoffrey IrvingJul 10, 2008
  8. Johannes SchindelinJul 10, 2008
  9. Geoffrey IrvingJul 10, 2008
  10. Johannes SchindelinJul 10, 2008
  11. Junio C HamanoJul 11, 2008
  12. Geoffrey IrvingJul 11, 2008
  13. Johannes SchindelinJul 11, 2008
  14. Geoffrey IrvingJul 11, 2008
  15. Johannes SchindelinJul 11, 2008
  16. Geoffrey IrvingJul 13, 2008
  17. cherry: cache patch-ids to avoid repeating workGeoffrey Irving, Jul 15, 2008
  18. Johannes SchindelinJul 15, 2008
  19. Junio C HamanoJul 15, 2008
  20. Karl HasselströmJul 16, 2008
  21. Johan HerlandJul 16, 2008

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.