On 10/15/2020 5:41 PM, Taylor Blau wrote: > So, we need to be more aggressively checking the Bloom filter settings > in any layer we want to reuse a Bloom filter out of before reusing it > verbatim in the current layer. The patch below the scissors line is > sufficient to do that, and it causes the third test to start passing. I think there are three things we should keep in mind: 1. Incompatible Bloom filter settings between layers should be seen as _inconsistent data_ as Git should not be writing incremental commit-graph files with inconsistent Bloom filter settings. Thus, when reading the commit-graph chain we should prevent incompatible filters from being used. One way to do this is to notice different settings and completely disable Bloom filters. The other way would be to take the settings from the first layer with filters and then clear the chunk_bloom_indexes and chunk_bloom_data fields for the layers that don't agree. This fits with an expectation that lower layers are larger, so more filters can be used in that situation. 2. We should be sure that Git will not agree to write incompatible settings between layers of a commit-graph chain. Even more, it should definitely not re-use filters when merging layers with incompatible filter values. The strategy above to ignore Bloom filters in incompatible upper layers is enough of a guard against the "merge layers" situation. 3. Allowing users (or future Git developers) to adjust the default Bloom filter settings is one that is good to do for future-proofing, but not one that I expect to be widely used (any gains here are minuscule compared to the results already achieved with the defaults). On top of that, including incompatible settings across layers is even less likely to be a real use case. We should not be straining to make the code even worse for this imaginary scenario. With that said... > ...But, teaching the revision machinery how to handle a walk through > commits in multiple commit-graph layers with incompatible Bloom filter > settings is trickier. Right now we compute all of the Bloom keys up > front using the Bloom filter settings in the top layer. I think we'd > probably want to change this to lazily compute those keys by: It would probably be easiest to compute an array of bloom_key structs (per path) where the index corresponds to the depth of the commit-graph layer. You can then access the correct key after you have identified which layer the commit is from. > At least, that's the best way that I can think to do it. It does get > kind of slow, though; we'd have to scan every commit graph layer at each > commit in the worst case to find the actual 'struct commit_graph *' in > order to get its Bloom filter settings. So, I think that's sort of > show-stoppingly slow, and that we should probably think more deeply > about it before taking up that direction. > > Maybe Stolee has some better thoughts about how we can quickly go from a > commit to either (a) the commit-graph struct that that commit is stored > in, or (b) the Bloom filter settings belonging to that struct. We already have code that finds a commit in a commit-graph layer based on its integer position by iterating until num_commits_in_base is below our position. The lexicographic position within that layer is found by subtracting num_commits_in_base. For us, we would simply need: int get_commit_graph_layer(struct commit_graph *g, uint32_t pos) { uint32_t layer_index = 0; while (g && pos < g->num_commits_in_base) { g = g->base_graph; layer_index++; } return layer_index; } You could then use the response from get_commit_graph_layer() to load the correct Bloom key. Again, I strongly suggest _not_ working hard to support this case. We should only put in proper safeguards to prevent data like this being written and protect a Git process that might stumble across data in this shape. Thanks, -Stolee