Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: add UserKeyCategories #4210

Merged
merged 1 commit into from
Jan 3, 2025
Merged

Conversation

RaduBerinde
Copy link
Member

Add a way to configure Pebble with an informative partitioning of the
key space. Each partition is a named key category; we use these for
pprof labels.

We currently set these pprof labels for compactions. In the future, we
will allow turning on labels in the read/write paths for specific
investigations.

Sample CRDB configuration code:

var userKeyCategories = pebble.MakeUserKeyCategories(
  EngineComparer.Compare,
  []pebble.UserKeyCategory{
    {Name: "local-1", UpperBound: toEngineKey(keys.LocalRangeIDPrefix.AsRawKey())},
    {Name: "rangeid", UpperBound: toEngineKey(keys.LocalRangeIDPrefix.AsRawKey().PrefixEnd())},
    {Name: "local-2", UpperBound: toEngineKey(keys.LocalRangePrefix)},
    {Name: "range", UpperBound: toEngineKey(keys.LocalRangePrefix.PrefixEnd())},
    {Name: "local-3", UpperBound: toEngineKey(keys.LocalRangeLockTablePrefix)},
    {Name: "lock", UpperBound: toEngineKey(keys.LocalRangeLockTablePrefix.PrefixEnd())},
    {Name: "local-4", UpperBound: toEngineKey(keys.LocalPrefix.PrefixEnd())},
    {Name: "meta", UpperBound: toEngineKey(keys.MetaMax)},
    {Name: "system", UpperBound: toEngineKey(keys.SystemMax)},
    {Name: "tenant"},
  }...,
)

@RaduBerinde RaduBerinde added the o-perf-efficiency Related to performance efficiency label Dec 22, 2024
@RaduBerinde RaduBerinde requested a review from a team as a code owner December 22, 2024 17:11
@RaduBerinde RaduBerinde requested a review from itsbilal December 22, 2024 17:11
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde
Copy link
Member Author

Sample flame graph with -tagroot key-type:
image

Copy link
Collaborator

@jbowens jbowens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm_strong:

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @itsbilal and @RaduBerinde)


options.go line 2209 at r1 (raw file):

// UserKeyCategories describes a partitioning of the user key space. Each
// partition is a category with a name, which is used for informative purposes
// (like pprof labels).

maybe add something explicitly emphasizing that these partitions are not physically materialized


options.go line 2243 at r1 (raw file):

	}
	if categories[n-1].UpperBound != nil {
		panic("last category UperBound must be nil")

nit: UpperBound

Add a way to configure Pebble with an informative partitioning of the
key space. Each partition is a named key category; we use these for
pprof labels.

We currently set these pprof labels for compactions. In the future, we
will allow turning on labels in the read/write paths for specific
investigations.

Sample CRDB configuration code:
```
var userKeyCategories = pebble.MakeUserKeyCategories(
  EngineComparer.Compare,
  []pebble.UserKeyCategory{
    {Name: "local-1", UpperBound: toEngineKey(keys.LocalRangeIDPrefix.AsRawKey())},
    {Name: "rangeid", UpperBound: toEngineKey(keys.LocalRangeIDPrefix.AsRawKey().PrefixEnd())},
    {Name: "local-2", UpperBound: toEngineKey(keys.LocalRangePrefix)},
    {Name: "range", UpperBound: toEngineKey(keys.LocalRangePrefix.PrefixEnd())},
    {Name: "local-3", UpperBound: toEngineKey(keys.LocalRangeLockTablePrefix)},
    {Name: "lock", UpperBound: toEngineKey(keys.LocalRangeLockTablePrefix.PrefixEnd())},
    {Name: "local-4", UpperBound: toEngineKey(keys.LocalPrefix.PrefixEnd())},
    {Name: "meta", UpperBound: toEngineKey(keys.MetaMax)},
    {Name: "system", UpperBound: toEngineKey(keys.SystemMax)},
    {Name: "tenant"},
  }...,
)
```
Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @itsbilal and @jbowens)


options.go line 2209 at r1 (raw file):

Previously, jbowens (Jackson Owens) wrote…

maybe add something explicitly emphasizing that these partitions are not physically materialized

Done.

@RaduBerinde RaduBerinde merged commit 465b9db into cockroachdb:master Jan 3, 2025
23 checks passed
@RaduBerinde RaduBerinde deleted the key-types branch January 3, 2025 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
o-perf-efficiency Related to performance efficiency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants