Skip to content

Commit

Permalink
optimization: ignore fetching superset metas when unnecessary
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <[email protected]>
  • Loading branch information
owen-d committed Feb 18, 2024
1 parent 0f9920c commit 2d09d20
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/bloomcompactor/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (s *SimpleBloomController) compactTenant(
return nil
}

// fetchSuperSet fetches all metas which overlap the ownership range of the first set of metas we've resolved
func (s *SimpleBloomController) fetchSuperSet(
ctx context.Context,
tenant string,
Expand Down Expand Up @@ -179,12 +180,22 @@ func (s *SimpleBloomController) fetchSuperSet(
superset = union[0]
}

within := superset.Within(ownershipRange)
level.Debug(logger).Log(
"msg", "looking for superset metas",
"superset", superset.String(),
"superset_within", superset.Within(ownershipRange),
"superset_within", within,
)

if within {
// we don't need to fetch any more metas
// NB(owen-d): here we copy metas into the output. This is slightly inefficient, but
// helps prevent mutability bugs by returning the same slice as the input.
results := make([]bloomshipper.Meta, len(metas))
copy(results, metas)
return results, nil
}

supersetMetas, err := s.bloomStore.FetchMetas(
ctx,
bloomshipper.MetaSearchParams{
Expand Down

0 comments on commit 2d09d20

Please sign in to comment.