# How to debug and profile rails library code ( in windows )

**URL:** <https://www.ruby-forum.com/t/how-to-debug-and-profile-rails-library-code-in-windows/185547>\
**Category:** Rails\
**Created:** [March 22, 2010, 3:59pm UTC](https://www.ruby-forum.com/t/how-to-debug-and-profile-rails-library-code-in-windows/185547 "2010-03-22T15:59:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wonko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8dc957/32.png) [@wonko](https://www.ruby-forum.com/u/wonko)\
**Post date:** [March 22, 2010, 3:59pm UTC](https://www.ruby-forum.com/t/how-to-debug-and-profile-rails-library-code-in-windows/185547/1 "2010-03-22T15:59:27Z")

</div>

Hi,  
I have a project on windows using rails 2.3.5, ruby 1.8.6, mysql 5.0.28,  
and mysql gem 2.8.1.

I am trying to debug a problem where it seems like each rails thread  
hangs before it has the chance to release the db connection to the pool.  
When the number of active connections reaches the total number available  
in the pool, the next request times out for five seconds before getting  
processed.

I have tried many things to identify what is causing this problem and  
now I think I need to run profiling and/or debugging inside the rails  
code to find out where it is hanging. (For example - I’ve gotten rid of  
database session stores to see if that was the cause, as older posts  
have indicated.)

How do I configure my project which currently has gems installed for  
rails to use source code so I can edit and debug it?

Thanks,

Ryan

---

<div class="post-metadata">

**Author:** ![wonko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8dc957/32.png) [@wonko](https://www.ruby-forum.com/u/wonko)\
**Post date:** [March 22, 2010, 6:30pm UTC](https://www.ruby-forum.com/t/how-to-debug-and-profile-rails-library-code-in-windows/185547/2 "2010-03-22T18:30:47Z")

</div>

Thanks Luke - freezing the gems is what I need because I am embedding  
ruby profile calls in there.

However, now I’m trying to add the profiling inside mongrel, because the  
profiling I added in ActionController::Base.process did not show me  
where the delay is occurring.

I did an unpack of mongrel and copied it to vendor along with adding the  
profiling code, but I’m unable to get the vendor version of  
mongrel\_rails to execute when I run the script\server.

How do I get the mongrel\_rails executable in vendor override the one in  
path?

thanks!

> > How do I configure my project which currently has gems installed for  
> > rails to use source code so I can edit and debug it?
> 
> I assume you’re debugging anyways:
> 
> [Debugging Rails Applications — Ruby on Rails Guides](http://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-ruby-debug)
> 
> If you do that you can step out into the rails code to see what’s  
> happening. If you want to actually put debug lines into rails source  
> code then how about freezing the rails gems into your project? Then you  
> could edit them and step out at any point you like.
> 
> Cheers  
> Luke

---

<div class="post-metadata">

**Author:** ![wonko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8dc957/32.png) [@wonko](https://www.ruby-forum.com/u/wonko)\
**Post date:** [March 23, 2010, 1:22am UTC](https://www.ruby-forum.com/t/how-to-debug-and-profile-rails-library-code-in-windows/185547/3 "2010-03-23T01:22:05Z")

</div>

Keeping it simple - you could just rename the one in your ruby bin  
directory or uninstall the mongrel gem! 🙂

---

<div class="post-metadata">

**Author:** ![wonko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8dc957/32.png) [@wonko](https://www.ruby-forum.com/u/wonko)\
**Post date:** [March 22, 2010, 4:57pm UTC](https://www.ruby-forum.com/t/how-to-debug-and-profile-rails-library-code-in-windows/185547/4 "2010-03-22T16:57:53Z")

</div>

> How do I configure my project which currently has gems installed for  
> rails to use source code so I can edit and debug it?

I assume you’re debugging anyways:

> **[Debugging Rails Applications — Ruby on Rails Guides](https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-ruby-debug)**
>
> Debugging Rails ApplicationsThis guide introduces techniques for debugging Ruby on Rails applications.After reading this guide, you will know: The purpose of debugging. How to track down problems and issues in your application that your tests aren't...

If you do that you can step out into the rails code to see what’s  
happening. If you want to actually put debug lines into rails source  
code then how about freezing the rails gems into your project? Then you  
could edit them and step out at any point you like.

Cheers  
Luke
