-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db: avoid repeated lookups into IterStatsCollector's map
When creating a top-level *pebble.Iterator, look up the appropriate categorized stats struct once and propagate it to all sstable iterators constructed by the Iterator, rather than looking up on every sstable iterator Close. Recent experiments showed significant time spent in the statsMap Load: ``` 2950.28s 4.24hrs (flat, cum) 3.70% of Total 110.55s 110.56s 144:func (c *CategoryStatsCollector) reportStats( . . 145: p uint64, category Category, qosLevel QoSLevel, stats CategoryStats, . . 146:) { 129.36s 1.30hrs 147: v, ok := c.statsMap.Load(category) 91.69s 91.72s 148: if !ok { . . 149: c.mu.Lock() . . 150: v, _ = c.statsMap.LoadOrStore(category, &shardedCategoryStats{ . . 151: Category: category, . . 152: QoSLevel: qosLevel, . . 153: }) . . 154: c.mu.Unlock() . . 155: } . . 156: 93.55s 93.56s 157: shardedStats := v.(*shardedCategoryStats) 2338.74s 2339.56s 158: s := ((p * 25214903917) >> 32) & (numCategoryStatsShards - 1) 40.75s 1.70hrs 159: shardedStats.shards[s].mu.Lock() 52.07s 295.26s 160: shardedStats.shards[s].stats.aggregate(stats) 45.31s 1465.73s 161: shardedStats.shards[s].mu.Unlock() 48.26s 48.27s 162:} ``` With this change, it's limited to 2.44% across the per-Iterator acquistion of an Accumulator and the per-sstable iterator reporting of the iterator stats: ``` Active filters: focus=Accumulat Showing nodes accounting for 2.78hrs, 2.44% of 114.22hrs total Dropped 103 nodes (cum <= 0.57hrs) Showing top 20 nodes out of 48 flat flat% sum% cum cum% 0.81hrs 0.71% 0.71% 1.31hrs 1.15% github.com/cockroachdb/pebble/sstable.(*categoryStatsWithMu).Accumulate 0.39hrs 0.34% 1.05% 1.46hrs 1.28% github.com/cockroachdb/pebble/sstable.(*CategoryStatsCollector).Accumulator 0.37hrs 0.32% 1.37% 0.72hrs 0.63% runtime.mapaccess2 0.34hrs 0.3% 1.67% 0.36hrs 0.31% sync.(*Mutex).Unlock (inline) 0.20hrs 0.18% 1.84% 0.20hrs 0.18% sync.(*entry).load (inline) 0.10hrs 0.088% 1.93% 1.08hrs 0.94% sync.(*Map).Load 0.08hrs 0.069% 2.00% 0.10hrs 0.089% sync.(*Mutex).lockSlow 0.06hrs 0.056% 2.06% 0.07hrs 0.063% runtime.strequal 0.06hrs 0.056% 2.11% 0.11hrs 0.092% runtime.typehash 0.06hrs 0.049% 2.16% 0.17hrs 0.15% runtime.nilinterhash 0.05hrs 0.047% 2.21% 0.05hrs 0.048% sync.(*Map).loadReadOnly (inline) 0.04hrs 0.037% 2.25% 0.11hrs 0.1% runtime.efaceeq 0.04hrs 0.034% 2.28% 0.15hrs 0.13% runtime.nilinterequal 0.03hrs 0.027% 2.31% 1.35hrs 1.18% github.com/cockroachdb/pebble/sstable.(*iterStatsAccumulator).close 0.03hrs 0.027% 2.33% 0.03hrs 0.027% github.com/cockroachdb/pebble/sstable.(*iterStatsAccumulator).init 0.03hrs 0.025% 2.36% 0.03hrs 0.025% aeshashbody 0.02hrs 0.022% 2.38% 0.13hrs 0.11% sync.(*Mutex).Lock (inline) 0.02hrs 0.02% 2.40% 0.02hrs 0.02% github.com/cockroachdb/pebble/sstable.(*iterStatsAccumulator).reportStats 0.02hrs 0.02% 2.42% 0.02hrs 0.02% github.com/cockroachdb/pebble/sstable.(*CategoryStats).aggregate (inline) 0.02hrs 0.014% 2.44% 0.02hrs 0.014% runtime.add (inline) ```
- Loading branch information
Showing
19 changed files
with
147 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.