Flexible I/O Tester development
 help / color / mirror / Atom feed
* Tiny fio performance bug with debug enabled
@ 2010-03-19  3:10 David Andersen
  2010-03-19  7:07 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: David Andersen @ 2010-03-19  3:10 UTC (permalink / raw)
  To: fio

Hi, fio hackers:  

Version 285d451f5c3e034463ea49a5ba99e8e0eb1b83a2
(snapshot from yesterday)

Tiny performance tweak with -DFIO_INC_DEBUG enabled but no debug flags specified (the default if building from source):  the dprint macro calls getpid() before checking to see whether or not it's going to actually do anything.  This causes a bit of a slowdown if you've built with debugging but aren't using it.  The fix is to simply swap them:

debug.h:

#define dprint(type, str, args...)                              \
        do {                                                    \
                assert(type < FD_DEBUG_MAX);                    \
                if ((((1 << type)) & fio_debug) == 0)           \
                        break;                                  \
                pid_t pid = getpid();                           \

I wasn't sure what the style guidelines were for non-initial declaration & assignment, though...

Reproducing:  run fio under 'perf';  observe 1.x% of time taken by getpid(). :)

  -Dave


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Tiny fio performance bug with debug enabled
  2010-03-19  3:10 Tiny fio performance bug with debug enabled David Andersen
@ 2010-03-19  7:07 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2010-03-19  7:07 UTC (permalink / raw)
  To: David Andersen; +Cc: fio

On Thu, Mar 18 2010, David Andersen wrote:
> Hi, fio hackers:  
> 
> Version 285d451f5c3e034463ea49a5ba99e8e0eb1b83a2
> (snapshot from yesterday)
> 
> Tiny performance tweak with -DFIO_INC_DEBUG enabled but no debug flags specified (the default if building from source):  the dprint macro calls getpid() before checking to see whether or not it's going to actually do anything.  This causes a bit of a slowdown if you've built with debugging but aren't using it.  The fix is to simply swap them:
> 
> debug.h:
> 
> #define dprint(type, str, args...)                              \
>         do {                                                    \
>                 assert(type < FD_DEBUG_MAX);                    \
>                 if ((((1 << type)) & fio_debug) == 0)           \
>                         break;                                  \
>                 pid_t pid = getpid();                           \
> 
> I wasn't sure what the style guidelines were for non-initial declaration & assignment, though...
> 
> Reproducing:  run fio under 'perf';  observe 1.x% of time taken by getpid(). :)

Thanks, I'll commit a fix for that.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-19  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-19  3:10 Tiny fio performance bug with debug enabled David Andersen
2010-03-19  7:07 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox