# \--with-debug compile option

**URL:** <https://www.ruby-forum.com/t/with-debug-compile-option/220980>\
**Category:** NGINX\
**Created:** [June 27, 2012, 4:24am UTC](https://www.ruby-forum.com/t/with-debug-compile-option/220980 "2012-06-27T04:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 27, 2012, 4:24am UTC](https://www.ruby-forum.com/t/with-debug-compile-option/220980/1 "2012-06-27T04:24:58Z")

</div>

Hi,

I need to compile Nginx with --with-debug option.

Will there be any performance implications if I have this flag set but  
NOT set the error log to debug\_\* when I don’t want to debug or  
troubleshoot any issue?

Posted at Nginx Forum:

> **[\--with-debug compile option](https://forum.nginx.org/read.php?2,227963,227963#msg-227963)**
>
> Hi, I need to compile Nginx with --with-debug option. Will there be any performance implications if I have this flag set but NOT set the error log to debug\_\* when I don't want to debug or troubleshoot any issue?

---

<div class="post-metadata">

**Author:** ![paphillon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/67e7ee/32.png) [@paphillon](https://www.ruby-forum.com/u/paphillon)\
**Post date:** [June 27, 2012, 5:07am UTC](https://www.ruby-forum.com/t/with-debug-compile-option/220980/2 "2012-06-27T05:07:02Z")

</div>

On Tue, Jun 26, 2012 at 10:24:11PM -0400, paphillon wrote:

> I need to compile Nginx with --with-debug option.
> 
> Will there be any performance implications if I have this flag set but  
> NOT set the error log to debug\_\* when I don’t want to debug or  
> troubleshoot any issue?

No. Using [Core functionality](http://nginx.org/r/debug_connection) is also worth  
considering.

---

<div class="post-metadata">

**Author:** ![paphillon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/67e7ee/32.png) [@paphillon](https://www.ruby-forum.com/u/paphillon)\
**Post date:** [June 27, 2012, 9:44am UTC](https://www.ruby-forum.com/t/with-debug-compile-option/220980/3 "2012-06-27T09:44:38Z")

</div>

On Wed, Jun 27, 2012 at 02:20:15PM +0800, agentzh wrote:

> Even though the current error log level is set higher than “debug”,  
> there will still be C function call overhead for all those  
> ngx\_log\_debugN calls.

These aren’t functions but are macros that first check if log\_level is  
set for debugging, and they don’t pessimize performance in any  
measurable  
way.

> Also, both the nginx core and lots of 3rd-party modules have chunks of  
> debugging code protected by the “#if (NGX\_DEBUG)” and “#endif” C  
> macros, which won’t get even compiled when --with-debug is not  
> specified.

The same holds true for ngx\_log\_debugN() macros.

> Generally speaking, more code compiled (and run) means more  
> bugs. I can catch issues in the debugging code from time to time.

Most of these allocate some register/stack space, do some assignments,  
and empty loop at worst. Some of these can be optimized by first  
checking if log\_level was set for debugging (like is done in  
ngx\_select\_process\_events(), for example). Still, think they don’t  
pessimize performance measurable.

(There’s some debugging code in SSL that’s not conditional on the  
log\_level to be set for debugging.)

---

<div class="post-metadata">

**Author:** ![paphillon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/67e7ee/32.png) [@paphillon](https://www.ruby-forum.com/u/paphillon)\
**Post date:** [June 27, 2012, 8:21am UTC](https://www.ruby-forum.com/t/with-debug-compile-option/220980/4 "2012-06-27T08:21:01Z")

</div>

Hello!

On Wed, Jun 27, 2012 at 10:24 AM, paphillon [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I need to compile Nginx with --with-debug option.
> 
> Will there be any performance implications if I have this flag set but  
> NOT set the error log to debug\_\* when I don’t want to debug or  
> troubleshoot any issue?

Even though the current error log level is set higher than “debug”,  
there will still be C function call overhead for all those  
ngx\_log\_debugN calls.

Also, both the nginx core and lots of 3rd-party modules have chunks of  
debugging code protected by the “#if (NGX\_DEBUG)” and “#endif” C  
macros, which won’t get even compiled when --with-debug is not  
specified. Generally speaking, more code compiled (and run) means more  
bugs. I can catch issues in the debugging code from time to time.

We usually do not use nginx builds with --with-debug in production  
environments but we also prepare a separate debugging build at the  
same time.

Best regards,  
-agentzh
