# Remove compilation optimization flag

**URL:** <https://www.ruby-forum.com/t/remove-compilation-optimization-flag/130307>\
**Category:** Redcloth\
**Created:** [February 27, 2008, 7:39am UTC](https://www.ruby-forum.com/t/remove-compilation-optimization-flag/130307 "2008-02-27T07:39:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gazoduc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@gazoduc](https://www.ruby-forum.com/u/gazoduc)\
**Post date:** [February 27, 2008, 7:39am UTC](https://www.ruby-forum.com/t/remove-compilation-optimization-flag/130307/1 "2008-02-27T07:39:25Z")

</div>

top output (compilation took about 10 minutes)

# cc1 8.6% 5:13.31 1 13 365 730M+ 2.45M 519M-

1.13G

time to run all tests (3rd launch):  
real 0m2.713s  
user 0m1.321s  
sys 0m0.306s

Without optimization flag (compilation takes 30 seconds):

# cc1 84.0% 0:17.15 1 13 203 243M+ 4.42M 245M+

435M+

time to run all tests (3rd launch)  
real 0m2.560s  
user 0m1.323s  
sys 0m0.319s

I think it would be a good change, especially when people compile this  
on a server with limited memory and shared CPU resources…

# PATCH: Index: ext/superredcloth\_scan/extconf.rb

— ext/superredcloth\_scan/extconf.rb (revision 245)  
+++ ext/superredcloth\_scan/extconf.rb (working copy)  
@@ -1,9 +1,6 @@  
require ‘mkmf’

-if /darwin9/ =~ RUBY\_PLATFORM

- 
# OSX 10.5 doesn’t like the default “-Os”
- $CFLAGS \<\< " -O1 "  
-end  
+$CFLAGS \<\< " -O0 " # do not optimize (takes too much memory and  
performance gain is negligeable)

dir\_config(“superredcloth\_scan”)  
have\_library(“c”, “main”)

---

<div class="post-metadata">

**Author:** ![gazoduc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@gazoduc](https://www.ruby-forum.com/u/gazoduc)\
**Post date:** [February 27, 2008, 6:27pm UTC](https://www.ruby-forum.com/t/remove-compilation-optimization-flag/130307/2 "2008-02-27T18:27:57Z")

</div>

Gaspard:  
Hey, wow! You’re my new favorite person. I’d been commenting out  
nonessentials when I was working on something specific and just  
waiting the 10 minutes when I wanted to see the whole thing work.

I’m committing this change. Johan, since you’re the one who  
requested the -O1 flag, would you verify it still works for you in  
Leopard?

If anyone knows a reason it’s bad to compile with -O0, now’s the time  
to speak up.

Great work, Gaspard! Thanks!

Jason

---

<div class="post-metadata">

**Author:** ![gazoduc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@gazoduc](https://www.ruby-forum.com/u/gazoduc)\
**Post date:** [February 28, 2008, 4:55pm UTC](https://www.ruby-forum.com/t/remove-compilation-optimization-flag/130307/3 "2008-02-28T16:55:15Z")

</div>

On Wed, Feb 27, 2008 at 12:22:54PM -0500, Jason G. wrote:

> I’m committing this change. Johan, since you’re the one who  
> requested the -O1 flag, would you verify it still works for you in  
> Leopard?

I agree, nice tweak! I’m playing with the Ragel flags and noticing  
wildly different behaviors as well. (Using -G0, -T0, -T1, etc.  
instead of -G2.) I’d really like to assemble a rake tasks that  
would go through and try permutations of Ragel flags with GCC flags  
and determine the most optimal settings.

For sure, though, compilation time was getting ridiculous.

\_why

---

<div class="post-metadata">

**Author:** ![gazoduc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c5a1d2/32.png) [@gazoduc](https://www.ruby-forum.com/u/gazoduc)\
**Post date:** [February 28, 2008, 5:25pm UTC](https://www.ruby-forum.com/t/remove-compilation-optimization-flag/130307/4 "2008-02-28T17:25:19Z")

</div>

While trying ragel optimization settings, it would be good to record  
the size of the output files, since I think it would be nice to  
include these files in the gem in order to avoid ragel dependency for  
those not modifying the gem.

Gaspard

2008/2/28, why the lucky stiff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
