|
6 | 6 | package storage
|
7 | 7 |
|
8 | 8 | import (
|
| 9 | + "bytes" |
9 | 10 | "context"
|
10 | 11 | "encoding/json"
|
11 | 12 | "fmt"
|
@@ -464,17 +465,30 @@ func DefaultPebbleOptions() *pebble.Options {
|
464 | 465 | // once.
|
465 | 466 | opts.TargetByteDeletionRate = 128 << 20 // 128 MB
|
466 | 467 | opts.Experimental.ShortAttributeExtractor = shortAttributeExtractorForValues
|
467 |
| - opts.Experimental.SpanPolicyFunc = pebble.MakeStaticSpanPolicyFunc( |
468 |
| - cockroachkvs.Compare, |
469 |
| - pebble.KeyRange{ |
470 |
| - Start: EncodeMVCCKey(MVCCKey{Key: keys.LocalRangeLockTablePrefix}), |
471 |
| - End: EncodeMVCCKey(MVCCKey{Key: keys.LocalRangeLockTablePrefix.PrefixEnd()}), |
472 |
| - }, |
473 |
| - pebble.SpanPolicy{ |
474 |
| - DisableValueSeparationBySuffix: true, |
475 |
| - ValueStoragePolicy: pebble.ValueStorageLowReadLatency, |
476 |
| - }, |
477 |
| - ) |
| 468 | + |
| 469 | + lockTableStartKey := EncodeMVCCKey(MVCCKey{Key: keys.LocalRangeLockTablePrefix}) |
| 470 | + lockTableEndKey := EncodeMVCCKey(MVCCKey{Key: keys.LocalRangeLockTablePrefix.PrefixEnd()}) |
| 471 | + localEndKey := EncodeMVCCKey(MVCCKey{Key: keys.LocalPrefix.PrefixEnd()}) |
| 472 | + opts.Experimental.SpanPolicyFunc = func(startKey []byte) (policy pebble.SpanPolicy, endKey []byte, _ error) { |
| 473 | + if !bytes.HasPrefix(startKey, keys.LocalPrefix) { |
| 474 | + return pebble.SpanPolicy{}, nil, nil |
| 475 | + } |
| 476 | + // Prefer fast compression for all local keys, since they shouldn't take up |
| 477 | + // a significant part of the space. |
| 478 | + policy.PreferFastCompression = true |
| 479 | + |
| 480 | + // We also disable value separation for lock keys. |
| 481 | + if cockroachkvs.Compare(startKey, lockTableEndKey) >= 0 { |
| 482 | + return policy, localEndKey, nil |
| 483 | + } |
| 484 | + if cockroachkvs.Compare(startKey, lockTableStartKey) < 0 { |
| 485 | + return policy, lockTableStartKey, nil |
| 486 | + } |
| 487 | + policy.DisableValueSeparationBySuffix = true |
| 488 | + policy.ValueStoragePolicy = pebble.ValueStorageLowReadLatency |
| 489 | + return policy, lockTableEndKey, nil |
| 490 | + } |
| 491 | + |
478 | 492 | // Disable multi-level compaction heuristic for now. See #134423
|
479 | 493 | // for why this was disabled, and what needs to be changed to reenable it.
|
480 | 494 | // This issue tracks re-enablement: https://github.com/cockroachdb/pebble/issues/4139
|
|
0 commit comments