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

Consider replacing/refactoring log() streams.

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.7, 2.2.0
    • Component/s: Logging
    • Labels:
    • Environment:
      All

      Currently, all log messages are implemented using streams and manipulators. This is problematic when a function is passed to a log() stream (because the function will be called regardless of the log level or use of NullStreams).

      Take, for example, this seemingly innocuous line:

                  log( pc ) << "finishing on shard " << shard << ", current connection state is " << mdata << endl;
      

      Because mdata is of type ParallelConnectionMetadata, and defines a toString() method which calls toBSON(), we waste CPU time (and malloc/free much more than necessary) even if verbose logging is disabled.

      To gauge impact, the supplied patch was applied. A simple stress test which floods mongos with simple find() operations performed 6500 queries per second unpatched, and 7600 queries per second with the patch.

            Assignee:
            Unassigned Unassigned
            Reporter:
            benjamin.becker Ben Becker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: