Hi Sebastian,

On Tue, 5 Jan 2010, Sebastian Moors wrote:

> I've just read all the other mails concerning the logger class and a few
> questions popped out of mind..
> If i understand it correct, the new proposal uses something like
> INFOLOG( const char* , .. ) instead of INFOLOG( const QString ).  Why is
> this faster? Is it just the fact the we don't have to pass the QString
> by value, which results in an expensive call to the copy constructor ?

Correct on the change to INFOLOG.

The objective isn't to be /faster/, but to be real-time 
safe.  QString::QString(...) and QString::operator=(const 
QString&) are not real-time safe because they allocate 
memory dynamically (i.e. they use 'new').  You must not do 
this in a real-time thread.

We currently work around this by wrapping the code inside an 
integer check.  Something like:

    if( Logger::log_level() & Logger::Info ) {
        Logger::log(Logger::Info, message, ... );
    }

This avoids invoking QString's methods unless the logging 
level is set sufficiently high.

But if you /do/ set the log level high, you risk becoming a 
JACK zombie while you wait on `new QChar`.

The proposal would use strings that are allocated on the 
stack or pre-allocated in a buffer.

As a side benefit, these strings will also run faster 
becaus.  However, you give up the benefits of having unicode 
strings.

> If my assumption is correct, we have to do now some casts ( QString ->
> char ) in the gui / audio threads *before* we call the logger, but we
> save the copy constructor calls. Is this faster for the non-logger threads?
> I'm very unexpierenced when it comes to all this low-level speed
> considerations, but i'm trying to learn :)

Yeah, if you need to get data from an existing QString into 
a log message, you'll need to do something like:

     INFOLOG( "Filename was '%s'", str.toLocal8Bit() );

But even this should be avoided from the audio threads.

> And a last, related Question:
> You mentioned speed-tests.. How do you measure the speed of those
> operations? Are you using dedicated profiling tools or C internals like
> those out of time.h?

For my implementation (which is different from Jeremy's), I 
used a stopwatch class from the Template Numerical Toolkit 
and wrote some test cases.  You can view the code here:

     
http://gitorious.org/composite/composite-labs/blobs/master/200912-rtstring/benchmark.cpp

-gabriel

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel

Reply via email to