1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef XPCOM_BASE_CYCLECOLLECTORSTATS_H_
8 #define XPCOM_BASE_CYCLECOLLECTORSTATS_H_
11 #include "mozilla/TimeStamp.h"
15 struct CycleCollectorStats
{
16 // Return the statistics struct for the current cycle-collecting thread, which
17 // will have initialized it during startup.
18 static CycleCollectorStats
* Get();
20 CycleCollectorStats();
22 void PrepareForCycleCollection(TimeStamp aNow
);
23 void AfterPrepareForCycleCollectionSlice(TimeStamp aDeadline
,
25 TimeStamp aMaybeAfterGCTime
);
26 void AfterCycleCollectionSlice();
27 void AfterSyncForgetSkippable(TimeStamp beginTime
);
28 void AfterForgetSkippable(TimeStamp aStartTime
, TimeStamp aEndTime
,
29 uint32_t aRemovedPurples
, bool aInIdle
);
30 void AfterCycleCollection();
32 void SendTelemetry(TimeDuration aCCNowDuration
, TimeStamp aPrevCCEnd
) const;
34 // Time the current slice began, including any GC finishing.
35 TimeStamp mBeginSliceTime
;
37 // Time the previous slice of the current CC ended.
38 TimeStamp mEndSliceTime
;
40 // Time the current cycle collection began.
43 // The longest GC finishing duration for any slice of the current CC.
44 TimeDuration mMaxGCDuration
;
46 // True if we ran sync forget skippable in any slice of the current CC.
47 bool mRanSyncForgetSkippable
= false;
49 // Number of suspected objects at the start of the current CC.
50 uint32_t mSuspected
= 0;
52 // The longest duration spent on sync forget skippable in any slice of the
54 TimeDuration mMaxSkippableDuration
;
56 // The longest pause of any slice in the current CC.
57 TimeDuration mMaxSliceTime
;
59 // The longest slice time since ClearMaxCCSliceTime() was called.
60 TimeDuration mMaxSliceTimeSinceClear
;
62 // The total amount of time spent actually running the current CC.
63 TimeDuration mTotalSliceTime
;
65 // True if we were locked out by the GC in any slice of the current CC.
66 bool mAnyLockedOut
= false;
68 // A file to dump CC activity to; set by MOZ_CCTIMER environment variable.
69 FILE* mFile
= nullptr;
71 // In case CC slice was triggered during idle time, set to the end of the idle
73 TimeStamp mIdleDeadline
;
75 TimeDuration mMinForgetSkippableTime
;
76 TimeDuration mMaxForgetSkippableTime
;
77 TimeDuration mTotalForgetSkippableTime
;
78 uint32_t mForgetSkippableBeforeCC
= 0;
80 uint32_t mRemovedPurples
= 0;
83 } // namespace mozilla
85 #endif // XPCOM_BASE_CYCLECOLLECTORSTATS_H_