Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Memory Reporter State

Currently two focuses:

  • GetReportsState: roughly the interprocess state, keeps track of which subprocesses need to callled / are running. This is only in the parent process.
  • CollectReportsState: intraprocess state, used in runnable, keeps track of which CollectReports calls are pending. This is in all processes and created in GetReportsForThisProcessExtended
  struct GetReportsState                                                                                               
  {
    uint32_t                             mGeneration;                                                                  
    bool                                 mAnonymize;                                                                   
    bool                                 mMinimize;
    nsCOMPtr<nsITimer>                   mTimer;
    nsTArray<nsRefPtr<mozilla::dom::ContentParent>> mChildrenPending;                                                  
    uint32_t                             mNumProcessesRunning;
    uint32_t                             mNumProcessesCompleted;                                                       
    uint32_t                             mConcurrencyLimit;
    nsCOMPtr<nsIHandleReportCallback>    mHandleReport;                                                                
    nsCOMPtr<nsISupports>                mHandleReportData;                                                            
    nsCOMPtr<nsIFinishReportingCallback> mFinishReporting;                                                             
    nsCOMPtr<nsISupports>                mFinishReportingData;                                                         
    nsString                             mDMDDumpIdent;                                                                
  }
  struct CollectReportsState
  {
    uint32_t mReportsPending;
    nsCOMPtr<nsIHandleReportCallback> mHandleReport;
    nsCOMPtr<nsISupports> mHandleReportData;
    nsCOMPtr<nsIFinishReportingCallback> mFinishReporting;
    nsCOMPtr<nsISupports> mFinishReportingData;
    bool mAnonymize;
    FILE* mDMDFile;
  }

Unique to CollectReportsState

Param Details
mReportsPending Number of memory reporters that have not yet finished
mDMDFile GetReportsState has mDMDDumpIdent which is used to open the file. Needs to be stored so that report can be written when all Reporters complete.

Unique to GetReportsState

Param Details
mGeneration used to discard old reports from child processes that timed out
mMinimize stored param, indicates child process should minimize before reporting
mTimer used to decide if child process has timed out
mChildrenPending child processes that have not been asked to report yet
mNumProcessesRunning number of child processes currently reporting
mNumProcessesCompleted number of child processes that have finished reporting
mConcurrencyLimit max number of child processes that can report at the same time
mDMDDumpIdent prefix for DMD file opened for each process

Common

Param Details
mHandleReport callback invoked for every measurement
mHandleReportData user data passed to mHandleReport callback
mFinishReporting callback invoked when all reports have finished
mFinishReportingData user data passed to mFinishReporting
mAnonymize whether or not a reporter should anonymized data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.