Thread (24 messages) 24 messages, 2 authors, 2023-08-29

Re: [RFC PATCH 2/6] bloom: prepare to discard incompatible Bloom filters

flat view

From: Jonathan Tan <hidden>
Date: 2023-08-24 23:06:32

Taylor Blau [off-list ref] writes:
I'm not sure I'm following. Are you saying that we should use
get_bloom_filter_settings() instead of reading the value from
r->settings directly?
quoted
then compare filter->version to version 2 if hash_version is 2, and to
version 1 otherwise.
Hmm. I think we're already doing the right thing here, no? IIUC, you're
saying to do something like:

    struct bloom_filter_settings *s = get_bloom_filter_settings(r);
    struct bloom_filter *f = get_or_compute_bloom_filter(r, c, ...);
    int hash_version;

    if (!f)
      return NULL;

    prepare_repo_settings(r);
    hash_version = r->settings.commit_graph_changed_paths_version;

    if (!(hash_version == -1 || hash_version == s->hash_version))
      return NULL; /* incompatible */
    return f;

?

If so, I think that we're already OK here, since s->hash_version is
always going to take the same value as f->version, since f->version is
assigned in bloom.c::load_bloom_filter_from_graph(), which does:

    filter->version = g->bloom_filter_settings->hash_version;

Or are we talking about two different things entirely? ;-)

Thanks,
Taylor
Ah, sorry for not being clear. What I meant is in how you compute
hash_version after we have found that filter is not NULL.
quoted hunk ↗ jump to hunk
+struct bloom_filter *get_bloom_filter(struct repository *r, struct commit *c)
+{
+	struct bloom_filter *filter;
+	int hash_version;
+
+	filter = get_or_compute_bloom_filter(r, c, 0, NULL, NULL);
+	if (!filter)
+		return NULL;
+
+	prepare_repo_settings(r);
Up to here is fine.
+	hash_version = r->settings.commit_graph_changed_paths_version;
Instead of doing this, do this (well, move the struct declaration to
the top):

  struct bloom_filter_settings *s = get_bloom_filter_settings(r);
  hash_version = s->hash_version == 2 ? 2 : 1;
  
+	if (!(hash_version == -1 || hash_version == filter->version))
No need for the comparison to -1 here.
quoted hunk ↗ jump to hunk
+		return NULL; /* unusable filter */
+	return filter;
+}
This is fine.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help