@@ -11,6 +11,7 @@ import (
11
11
"sort"
12
12
"time"
13
13
14
+ "github.com/cockroachdb/crlib/crtime"
14
15
"github.com/cockroachdb/errors"
15
16
"github.com/cockroachdb/pebble/internal/base"
16
17
"github.com/cockroachdb/pebble/internal/cache"
@@ -1499,6 +1500,7 @@ func (d *DB) ingest(ctx context.Context, args ingestArgs) (IngestOperationStats,
1499
1500
var mut * memTable
1500
1501
// asFlushable indicates whether the sstable was ingested as a flushable.
1501
1502
var asFlushable bool
1503
+ var waitFlushStart crtime.Mono
1502
1504
prepare := func (seqNum base.SeqNum ) {
1503
1505
// Note that d.commit.mu is held by commitPipeline when calling prepare.
1504
1506
@@ -1607,7 +1609,6 @@ func (d *DB) ingest(ctx context.Context, args ingestArgs) (IngestOperationStats,
1607
1609
d .mu .log .manager .ElevateWriteStallThresholdForFailover ()) &&
1608
1610
! d .opts .Experimental .DisableIngestAsFlushable () && ! hasRemoteFiles &&
1609
1611
(! args .ExciseSpan .Valid () || d .FormatMajorVersion () >= FormatFlushableIngestExcises )
1610
-
1611
1612
if ! canIngestFlushable {
1612
1613
// We're not able to ingest as a flushable,
1613
1614
// so we must synchronously flush.
@@ -1628,6 +1629,7 @@ func (d *DB) ingest(ctx context.Context, args ingestArgs) (IngestOperationStats,
1628
1629
mut = d .mu .mem .mutable
1629
1630
mut .writerRef ()
1630
1631
mem .flushForced = true
1632
+ waitFlushStart = crtime .NowMono ()
1631
1633
d .maybeScheduleFlush ()
1632
1634
return
1633
1635
}
@@ -1642,6 +1644,8 @@ func (d *DB) ingest(ctx context.Context, args ingestArgs) (IngestOperationStats,
1642
1644
}
1643
1645
1644
1646
var ve * manifest.VersionEdit
1647
+ var waitFlushDuration time.Duration
1648
+ var manifestUpdateDuration time.Duration
1645
1649
apply := func (seqNum base.SeqNum ) {
1646
1650
if err != nil || asFlushable {
1647
1651
// An error occurred during prepare.
@@ -1683,11 +1687,12 @@ func (d *DB) ingest(ctx context.Context, args ingestArgs) (IngestOperationStats,
1683
1687
// finish.
1684
1688
if mem != nil {
1685
1689
<- mem .flushed
1690
+ waitFlushDuration = waitFlushStart .Elapsed ()
1686
1691
}
1687
1692
1688
1693
// Assign the sstables to the correct level in the LSM and apply the
1689
1694
// version edit.
1690
- ve , err = d .ingestApply (ctx , jobID , loadResult , mut , args .ExciseSpan , args .ExciseBoundsPolicy , seqNum )
1695
+ ve , manifestUpdateDuration , err = d .ingestApply (ctx , jobID , loadResult , mut , args .ExciseSpan , args .ExciseBoundsPolicy , seqNum )
1691
1696
}
1692
1697
1693
1698
// Only one ingest can occur at a time because if not, one would block waiting
@@ -1724,9 +1729,11 @@ func (d *DB) ingest(ctx context.Context, args ingestArgs) (IngestOperationStats,
1724
1729
var stats IngestOperationStats
1725
1730
if loadResult .fileCount () > 0 {
1726
1731
info := TableIngestInfo {
1727
- JobID : int (jobID ),
1728
- Err : err ,
1729
- flushable : asFlushable ,
1732
+ JobID : int (jobID ),
1733
+ Err : err ,
1734
+ flushable : asFlushable ,
1735
+ WaitFlushDuration : waitFlushDuration ,
1736
+ ManifestUpdateDuration : manifestUpdateDuration ,
1730
1737
}
1731
1738
if len (loadResult .local ) > 0 {
1732
1739
info .GlobalSeqNum = loadResult .local [0 ].SmallestSeqNum
@@ -1905,7 +1912,7 @@ func (d *DB) ingestApply(
1905
1912
exciseSpan KeyRange ,
1906
1913
exciseBoundsPolicy exciseBoundsPolicy ,
1907
1914
exciseSeqNum base.SeqNum ,
1908
- ) (* manifest.VersionEdit , error ) {
1915
+ ) (* manifest.VersionEdit , time. Duration , error ) {
1909
1916
d .mu .Lock ()
1910
1917
defer d .mu .Unlock ()
1911
1918
@@ -1917,6 +1924,7 @@ func (d *DB) ingestApply(
1917
1924
}
1918
1925
var metrics levelMetricsDelta
1919
1926
1927
+ manifestUpdateStart := crtime .NowMono ()
1920
1928
// Determine the target level inside UpdateVersionLocked. This prevents two
1921
1929
// concurrent ingestion jobs from using the same version to determine the
1922
1930
// target level, and also provides serialization with concurrent compaction
@@ -2164,8 +2172,9 @@ func (d *DB) ingestApply(
2164
2172
}, nil
2165
2173
})
2166
2174
if err != nil {
2167
- return nil , err
2175
+ return nil , 0 , err
2168
2176
}
2177
+ manifestUpdateDuration := manifestUpdateStart .Elapsed ()
2169
2178
2170
2179
// Check for any EventuallyFileOnlySnapshots that could be watching for
2171
2180
// an excise on this span. There should be none as the
@@ -2211,7 +2220,7 @@ func (d *DB) ingestApply(
2211
2220
}
2212
2221
}
2213
2222
d .maybeValidateSSTablesLocked (toValidate )
2214
- return ve , nil
2223
+ return ve , manifestUpdateDuration , nil
2215
2224
}
2216
2225
2217
2226
// maybeValidateSSTablesLocked adds the slice of newTableEntrys to the pending
0 commit comments