LISTSERV mailing list manager LISTSERV 16.5

Help for QSERV-L Archives


QSERV-L Archives

QSERV-L Archives


QSERV-L@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

QSERV-L Home

QSERV-L Home

QSERV-L  May 2014

QSERV-L May 2014

Subject:

LSST Logging (aka ProtoLog): APIs and Performance

From:

Bill Chickering <[log in to unmask]>

Reply-To:

General discussion for qserv (LSST prototype baseline catalog)

Date:

Thu, 22 May 2014 17:46:03 -0700

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (75 lines)

Greetings -

I'd like to solicit feedback regarding logging interface options and my latest timing measurements.

If you have not already visited the online documentation for the prototype logging solution, and are so inclined, please visit:
https://dev.lsstcorp.org/trac/wiki/db/Qserv/ProtoLog

The above documentation is mostly complete but pertains only to the boost::format style interface. In this email, I describe two other interface options: a varargs/printf style interface and a streaming style interface.

For each of the interface styles, one would write logging statements like the following:

== boost::format style interface ==
int data = 99;
LOG("myLogger", LOG_WARN_LVL, "This is a warning about data = %d. So you have been warned!") % data;
LOG_WARN("This is a warning about data = %d. So you have been warned!") % data;

== varargs/printf style interface ==
int data = 99;
LOG("myLogger", LOG_WARN_LVL, "This is a warning about data = %d. So you have been warned!", data);
LOG_WARN("This is a warning about data = %d. So you have been warned!", data);

== streaming style interface ==
int data = 99;
LOG("myLogger", LOG_WARN_LVL, "This is a warning about data = " << data << ". So you have been warned!");
LOG_WARN("This is a warning about data = " <<  data << ". So you have been warned!");

An important measurement is the time required to execute a logging statement that does not meet the presently set threshold. That is, one might have a large number of fine-level logging statements throughout their code but would normally like these turned off. Ideally, the presence of these inactive logging statements would not add appreciably to the program's running time. These timing measurements should therefore be taken into consideration when choosing between the above interfaces.

Here are the average times required to run the logging statements similar to those above with the threshold set to LOG_ERROR_LVL such that they are all suppressed. (These measurements were made on lsst-dev03 in the absence of significant competing activity.)

== boost::format style interface ==
LOG(.....): 1.3us
LOG_WARN(.....): 120ns

== varargs/printf style interface ==
LOG(....): 1.0us
LOG_WARN(.....): 27ns

== streaming style interface ==
LOG(.....): 970ns
LOG_WARN(......): 26ns

First, you'll notice that the LOG(.....) statements are generally much slower than the LOG_WARN(....) statements. This is because the LOG(....) statements must look up the logger by name, which is the bottleneck of these logging operations. The LOG_WARN(....) statements, meanwhile, use the defaultLogger. Next, you'll notice that the LOG_WARN(....) statement for the boost::format style interface is ~4X slower than that for the varargs/printf or streaming style interfaces. This is due to the creation of the boost::format object. The creation of this object is also the reason for the longer timing associated with the boost::format style LOG(....) statement.

While the boost::format style is typically slower, it offers several advantages over the other logging interfaces. For starters, it provides type safety not present with the varargs/printf style interface. For example, one can do something like:
LOG_INFO("This is %1% example of a %2% safe statement with data = %3%") % 1 % "type" % 3.14;

In fact, even if classic formatting (e.g. %d) is provided, it is only treated as a suggestion by boost::format. boost::format also offers a number of formatting options not available via the varargs/printf style interface.

Note that while the streaming interface has limited formatting abilities, it also offers a level of type safety. For example, one could do something like:
LOG_INFO("This is " << 1 << " example of a " << "type" << " safe statement with data = " << 3.14);

The boost::format style interface offers other advantages as well. While it is *relatively* expensive to create the formatting object, once created it can be reused. For example, one can do something like:
LOG_FMT logFmt = LOG("myLogger", LOG_INFO_LVL, "This is iteration %d");
for (int i=0; i < 10; i++) {
    logFmt % i;
    logFmt.dump();
}

In the above example, if the logging threshold were set to LOG_WARN_LVL such that the statements from logFmt were suppressed, the average execution time for the body of the loop (on lsst-dev03) is about 21ns--faster than the other interfaces.

Finally, it is worth mentioning that the streaming interface is native to log4cxx. As such, this is the simplest implementation.

Each of the above interfaces involves its own set of macros and functions. Combining any or all of them would result (IMHO) in an overly-complex implementation. Ideally, we can choose to adopt one of the three.

I look forward to feedback.

-- Bill

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the QSERV-L list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=QSERV-L&A=1

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

March 2018
February 2018
January 2018
December 2017
August 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use