The Artima Developer Community
Sponsored Link •

Ruby Buzz Forum
Preventing massive CPU suckage

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
Preventing massive CPU suckage Posted: Jul 18, 2009 7:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: Preventing massive CPU suckage
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
While trying to find a way to simulate getrlimit and setrlimit on MS Windows I realized you could do this on most Unix platforms as a way to prevent your process from sucking massive CPU cycles:
trap('XCPU'){
   puts "CPU time exceeded!"
   # Insert diagnostic code here
   exit!
}

Process.setrlimit(Process::RLIMIT_CPU, 1) # Or whatever max value you want

while true
   puts "This should exit in a few seconds..."
end

What I'm not sure of is what a good value is for the maximum CPU time. Then again, maybe limiting RLIMIT_VMEM would be better. Or perhaps both?

I've never done this in practice, btw, but it might be a good way to deal with spiking processes. Just a thought.

Read: Preventing massive CPU suckage

Topic: Nick Plante: How do I learn and master Sinatra? Previous Topic   Next Topic Topic: My Apprenticeship - Thursday, July 15, 2004

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use