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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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"},
  }...,
)

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

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.

2 participants