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

Re: [PATCH 1/4] revision: move bloom keyvec precondition into function

From
Jeff King <peff@peff.net>
Date
Jul 18, 2026, 07:57 UTC
Message-ID
<20260718075700.GB22588@coredump.intra.peff.net>
In-Reply-To
<20260717-toon-speed-up-last-modified-v1-1-410418f18614@iotcl.com>
On Fri, Jul 17, 2026 at 05:46:59PM +0200, Toon Claes wrote:
Show 6 quoted lines
> There are currently two callsites calling
> check_maybe_different_in_bloom_filter(). They both check if
> revs->bloom_keyvecs_nr is not zero before they call that function.
> 
> Move bloom_keyvecs_nr precondition into
> check_maybe_different_in_bloom_filter() to simplify the code.
Makes sense, but...
> Note that this changes `bloom_ret` to become -1 when there are no Bloom
> key vectors, which results in `count_bloom_filter_false_positive` not
> being incremented. This is unobservable, as the Bloom statistics are
> only reported when key vectors were set up.

This "-1" return is kind of subtle. The function is really a tristate returning one of:

  0: no, it's definitely not in the filter
  1: yes, it's (probably) in the filter
  -1: we could not even check the filter

But nobody ever cares about the difference between "1" and "-1", because the probabilistic data structure means "we could not check" must err on the side of "it might be in the filter". But that leads to code like:

  if (!bloom_ret)

that _looks_ wrong at first glance (as in "oops, we are not catching -1 and accidentally treating it the same as 1"). But it's is actually correct for the reason above.

The "return -1" you are adding here is not the first (we'd do a similar thing if the commit was not found in the graph file). So it is not really adding to the confusion.

But as we prepare to make this function public, should we consider changing that tristate to a boolean, like:

  false: no, the path is definitely not touched by this commit
  true: the path could be touched by this commit

It's a minor point, but I think this makes the interface much more obvious.

-Peff
Previous: Toon ClaesNext: Toon Claes
Message 3 of 30 in “last-modified: use the pathspec's Bloom key to pre-filter commits”
  1. 0/4 last-modified: use the pathspec's Bloom key to pre-filter commitsToon Claes, Jul 17, 2026
  2. 1/4 revision: move bloom keyvec precondition into functionToon Claes, Jul 17, 2026
  3. Jeff KingJul 18, 2026
  4. Toon ClaesAug 5, 2026
  5. Jeff KingAug 5, 2026
  6. 2/4 revision: expose check for paths maybe changed in Bloom filterToon Claes, Jul 17, 2026
  7. Junio C HamanoJul 17, 2026
  8. Taylor BlauJul 17, 2026
  9. 3/4 last-modified: check pathspec against Bloom filter firstToon Claes, Jul 17, 2026
  10. Taylor BlauJul 17, 2026
  11. Jeff KingJul 18, 2026
  12. Taylor BlauJul 18, 2026
  13. Jeff KingJul 20, 2026
  14. 4/4 last-modified: keep per-path Bloom filters for wildcard pathspecsToon Claes, Jul 17, 2026
  15. Toon ClaesJul 17, 2026
  16. Jeff KingJul 18, 2026
  17. Junio C HamanoAug 4, 2026
  18. Taylor BlauAug 5, 2026
  19. Junio C HamanoAug 5, 2026
  20. Jeff KingAug 5, 2026
  21. Taylor BlauJul 17, 2026
  22. Toon ClaesJul 17, 2026
  23. 0/6 last-modified: use the pathspec's Bloom key to pre-filter commitsToon Claes, Aug 7, 2026
  24. 1/6 revision: move bloom keyvec precondition into functionToon Claes, Aug 7, 2026
  25. 2/6 revision: expose check for paths maybe changed in Bloom filterToon Claes, Aug 7, 2026
  26. 3/6 bloom: add helper to check if any key in a vector is presentToon Claes, Aug 7, 2026
  27. 4/6 revision: add Bloom check that includes parent directoriesToon Claes, Aug 7, 2026
  28. 5/6 last-modified: check pathspec against Bloom filter firstToon Claes, Aug 7, 2026
  29. 6/6 last-modified: keep per-path Bloom filters for wildcard pathspecsToon Claes, Aug 7, 2026
  30. Junio C HamanoAug 8, 2026

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.