[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby real time web server multi threaded probs

Roger Pack

7/6/2007 6:44:00 PM

So...I seem to have run into a few problems in a ruby multi-threaded
socket based program that, after quite awhile, I am still scratching my
head at these. Has any body encountered/overcome...[sorry if these are
old, or not real bugs]

1) Exceptions that are 'jump their bounds' Sometimes a 'normal'
exception, typically caught, will just bypass its begin rescue blocks!
Brings the whole system to a crash.

2) Crossed streams. You open up a socket and start receiving data meant
for another socket.
Related to that sometimes when doing "server.accept" when under duress
it throws exception like 'not a socket' or 'bad file descriptor' or
'argument invalid' when it is a GOOD file descriptor, and is a socket.
Weirder than weird.
Also, I've had the following happen:
r,e,w = select([socket],nil,nil,5) # succeeds
then r is set to something other than [socket]! [very rare--once or
twice has that ever happened, but it has!]
or
r is set to [socket], then you when you run "socket.recv" it comes back
with "" -- in other words I think it read from some other socket that
was closed.

2) An app just freezes(at least on win32). Sometimes (too many open
sockets?) Ruby will just freeze. There it is. 0% cpu use. ~100 threads
exist. Ruby is frozen [1.8.6]
Or, related, a read from a socket 'freezes' all threads in the whole
program, waiting for a "recv" it come back [and if it doesn't....)
[pretty rare but happened once].


Thus far the 'answer' to these problems has been to...not run a multi
threaded app. Mongrel runs several different apps, for example. Any
ideas or experiences like this?
If nobody recognizes these then I will try to recreate them and submit
them as bugs. This is nuts.
Thanks!
-Roger

--
Posted via http://www.ruby-....

6 Answers

Roger Pack

7/6/2007 7:30:00 PM

0

Thanks for the replies!

One other 'ruby nasty' I thought of was the fact that sometimes
functions will end up 'defined' in a different thread than you would
anticipate them to be. Like if you do a 'require X' then it loads X --
into some other thread. Very odd. Anyone ever had any work arounds for
that? Any trouble with it? [The biggest trouble with the things I've
mentioned is that they are variable--they happen only every so often,
which makes them tough bugs to stomp out.]

Anyway that's about it! Thanks again!

-Roger

Jason Roelofs wrote:
> Arg, Francis is just too fast for me. I would also highly recommend
> EventMachine instead of doing your own socket code (it's Francis'
> library
> :P).
>
> Also, it seems like you are expecting Ruby threads to be system threads.
> This is simply not the case. Ruby threads are what's called Green
> threads,
> or handled by the Ruby interpreter only. The OS only ever sees one
> thread,
> the Ruby process. If you have ~100 Ruby threads going, you are probably
> running out of processing power to handle the constant switching.
>

So...if they were native threads would anticipate the load not being the
problem? I.e. is the only problem with threads inefficiency in context
switching of Ruby versus an OS? BTW when I say '100 threads' most of
them are sleeping or what not, don't worry I'm not insane [or maybe I
am] :)




> So scale yourself back, if really want to write your own socket code.
> Otherwise go get EventMachine and let it do all the nasty work for you.
>
> Jason


--
Posted via http://www.ruby-....

Steve

12/7/2010 9:18:00 PM

0

On Tue, 07 Dec 2010 11:57:31 -0600, David Hartung <david@hotmai*l.com>
wrote:

>On 12/07/2010 11:12 AM, Steve wrote:
>> On Tue, 7 Dec 2010 12:09:48 -0500, "Dano"<janeanddano@yahoo.com>
>> wrote:
>
>>> That's right. Money. That's all that matters. Fuck human beings. What do
>>> THEY matter in the grand scheme? We're all just here to provide wealth for
>>> the 5% that controls 90% of our nation's wealth.
>>
>> You can't even provide for yourself, loser.
>
>Steve, just out of curiosity, what would have happened hafd you not
>treated your employees with the respect they deserved?

They would've quit. Every last one of them. I only hired the very
best.
--

the only people who benefit from the communalistic economics that
leftists promote are the lazy, irresponible bottom feeders and
the power hungry community organizers.

Thanatos

12/7/2010 11:09:00 PM

0

In article <idlpot$jf$1@news.eternal-september.org>,
"Dano" <janeanddano@yahoo.com> wrote:

> "David Hartung" <david@hotmai*l.com> wrote in message
> news:otSdnW1k88cB_mPRnZ2dnUVZ_r2dnZ2d@giganews.com...
> > On 12/07/2010 10:26 AM, Phlip wrote:
> >> On Dec 7, 6:11 am, David Hartung<david@hotmai*l.com> wrote:
> >>
> >>>> I'm reasonably sure anything he or sure does isn't worth 80 or 100
> >>>> million to anybody. You?
> >>>
> >>> If it isn't, then he would not be making that level of income.
> >>
> >> Really? Please describe the mechanism that keeps his salary that high.
> >> If sales go down, for example, does something force his salary down?
> >
> > The salary of the CEO of any corporation is determined by that company's
> > board of directors, and is generally done on a contractual basis. The
> > terms of that contract determine when, if at all, the corporation can
> > lower the compensation of a CEO.
> >
> > I am guessing that you know this, and are simply unwilling to admit that
> > the wages of any employee, even that of the CEO are none of your business.
> >
> >> Recall that a CEO is chartered by a board of directors, typically his
> >> friends, and that he typically sits on boards for their companies,
> >> too.
> >
> > A CEO is an employee, and chances are that the any given board of
> > directors is made up of people who have a significant ownership in the
> > corporation. They will want the company to do as well as possible, after
> > all, that is how they make money.
>
> That's right. Money. That's all that matters.

To a business, yeah. That's why they exist. To buy and sell stuff.

That's why people start businesses: to make money. I know you yearn for
some utopian Star Trek fantasy society where everyone just wanders
around doing whatever makes them happy and they never get paid, no one
uses money, and no one wants for anything, but that ain't how the world
works.

Thanatos

12/7/2010 11:11:00 PM

0

In article <pa8tf6picbir6davap42pnqqj0pt5iuf3n@4ax.com>,
Steve <stevencanyon@yahooooo.com> wrote:

> On Tue, 07 Dec 2010 11:57:31 -0600, David Hartung <david@hotmai*l.com>
> wrote:
>
> >On 12/07/2010 11:12 AM, Steve wrote:
> >> On Tue, 7 Dec 2010 12:09:48 -0500, "Dano"<janeanddano@yahoo.com>
> >> wrote:
> >
> >>> That's right. Money. That's all that matters. Fuck human beings. What
> >>> do
> >>> THEY matter in the grand scheme? We're all just here to provide wealth
> >>> for
> >>> the 5% that controls 90% of our nation's wealth.
> >>
> >> You can't even provide for yourself, loser.
> >
> >Steve, just out of curiosity, what would have happened hafd you not
> >treated your employees with the respect they deserved?
>
> They would've quit. Every last one of them. I only hired the very
> best.

Shame on you. The government doesn't want you only hiring the best
people for the job. They'd much rather you have a multi-culti "diverse"
workforce, even if that means you have to hire less than exceptional
people to achieve it.

trotsky

12/8/2010 12:45:00 AM

0

On 12/7/10 11:55 AM, David Hartung wrote:
> On 12/07/2010 11:09 AM, Dano wrote:
>
>> THEY matter in the grand scheme? We're all just here to provide wealth
>> for the 5% that controls 90% of our nation's wealth. And of
>> course...wealth = power.
>
> In point of fact, when I worked in the business world,


Somebody has to make the coffee.

trotsky

12/9/2010 12:27:00 PM

0

On 12/7/10 10:26 AM, Phlip wrote:
> On Dec 7, 6:11 am, David Hartung<david@hotmai*l.com> wrote:
>
>>> I'm reasonably sure anything he or sure does isn't worth 80 or 100
>>> million to anybody. You?
>>
>> If it isn't, then he would not be making that level of income.
>
> Really? Please describe the mechanism that keeps his salary that high.
> If sales go down, for example, does something force his salary down?
>
> Recall that a CEO is chartered by a board of directors, typically his
> friends, and that he typically sits on boards for their companies,
> too.


He already answered the question: because the CEO is in a contract, his
salary can't go down. Nor does his golden parachute go away.