Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4786

Random sampling for profiling and logging

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.3
    • Component/s: Performance
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Query 2017-02-13

      Description

      Add a new sampleRate parameter to the profile command. This parameter can take values on the interval [0, 1], and is set to 1 by default on startup. The behavior of sampleRate is as follows for logging:

      • If the logLevel is 0, then we log a slow command that exceeds the slowms with probability given by sampleRate. Commands whose latency is less than slowms, as before, are not logged.
      • If the logLevel is 1 or higher, then all commands are logged. The sampleRate has no affect in this case.

      For creating system.profile entries, the behavior of sampleRate is as follows:

      • If the profiling level is 0, then no profile entries are created and sampleRate takes no affect.
      • If the profiling level is 1, then an operation exceeding slowms is profiled with probability given by sampleRate.
      • If the profiling level is 2, then all operations are profiled with probability given by sampleRate, regardless of latency.

      There are three ways to set the profiler sampleRate. The first is by running the profile command. For example, the following command indicates that the server should profile 10% of operations slower than 30ms:

      db.runCommand({profile: 2, slowms: 30, sampleRate: 0.1});
      

      This command will return the previous settings of profile, slowms, and sampleRate on success. Like slowms, the sampleRate setting is unchanged when it is omitted from the command. The sampleRate can also be set from the shell using the db.setProfilingLevel() helper:

      db.setProfilingLevel(2, {slowms: 30, sampleRate: 0.1});
      

      The second argument to this helper is now either the slowms value, or an options object.

      The second way to set sampleRate is the new slowOpSampleRate command line option:

      ./mongod --profile 2 --slowms 30 --slowOpSampleRate 0.1
      

      Third, it can be set in a configuration file using operationProfiling.slowOpSampleRate.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              david.storch David Storch
              Reporter:
              scotthernandez Scott Hernandez
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: