Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4800

Return early in mongoc_log_trace functions if no logger is configured

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Logging

    Description

      PHPC-2337 fixed an issue where I inadvertently forgot to explicitly disable tracing at runtime (PHPC compiles with tracing enabled, so that was the default), despite clearing libmongoc's log handler. This introduced a performance regression whereby trace log messages were still generated, but never written.

      A possible improvement in libmongoc would have mongoc_log_trace_iovec() and mongoc_log_trace_bytes() return early if a log handler isn't registered (beyond just checking whether tracing is enabled). mongoc_log() already does this itself for its stop_logging calculation.

      One approach may be to turn the following snippet from mongoc_log() into a macro to call from all three functions:

      stop_logging = !gLogFunc;
      stop_logging = stop_logging || (log_level == MONGOC_LOG_LEVEL_TRACE &&
                                      !_mongoc_log_trace_is_enabled ());
      if (stop_logging) {
         return;
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: