Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Call will_log_event() to determine if we are going to log the event.  If we aren't return.
  2. Call pbs_asprintf_len() to determine the length of the formatted string.
  3. If the length is less than 4096, we call snprintf() into our local buffer.  This avoids us having to allocate memory for smaller log messages.
  4. If the length is greater than 4096, we vsnprintf() into a local log buffer the same size as the global log_buffer.
  5. If we truncated the string, call pbs_asprintf_format() to allocate and format the string.
  6. We call log_record() to to log the buffer.
  7. If we allocated the buffer with pbs_asprintf_format(), we free the buffer.


The reason we directly vsnprintf() into a buffer instead of calling pbs_asprintf_len() is that the vast majority of the log messages we log in PBS will fit.  Why should we call vsnprintf() twice for all messages, when we can get away with calling it only once for the majority of them.  It is true that really long log messages will take longer since we create the string twice, but those are few and far between.


...

OSS Site Map

Project Documentation Main Page

...