pphaneuf: (Default)
[personal profile] pphaneuf
Well, it's been a while I haven't done a technical post, and well, I'm feeling a bit under the weather, so it might be a bit shoddy and make even less sense than usual, but you'll just have to deal with that, won't you?

Recently, jdub (who has one of my favouritest domain name, I hope he'll give it to me in his will) was talking about things that suck. Those too lazy to click the preceding link are probably wondering what thing and/or how so. Well, it's Python, that for what sounds like a totally lame excuse, has a maximum timeout of a hundred milliseconds in its select()-based main loop, in order to poll whether the interpreter received a signal. Polling. Jebus, it's 2006 already, somebody tell these people!

Now, someone like apenwarr, who both wrote such code and sat beside me, consequently almost going deaf from my horrified screams, many times over. Note to others who think of writing such code: it might be hazardous to your health! Save yourself! Write a byte to a pipe in your signal handler!

Now, of course, the primary reasons to do so would often be things like "not sucking" and "not going deaf", but power usage is getting to be an important problem in enterprise computing, not to mention longer autonomy for laptops, as well as quieter and cooler workstations, which can then be made smaller and less obtrusive. Sun keeps telling us, and Google is having issues with it. Like apenwarr once said, semi-famously, inspired by Spiderman's uncle, "with great power comes a great power bill", in the order of 1 to 2 millions $US per month!

As [livejournal.com profile] kernelslacker is pointing out in his experiments that you can actually look into these things at home, provided you have the appropriate gadget. I'd be very interested in playing around with this, but I'd need to find myself a similar tool adapted to European power standards... Anyone has a lead for me?

Now, you might wonder what's the point of that post. Me too. I forgot. Stupid cold...

Date: 2006-09-15 08:25 pm (UTC)
From: [identity profile] azrhey.livejournal.com
hmm...yeah... I mean... *resumes reading her F-list*

Date: 2006-09-15 11:06 pm (UTC)
From: [identity profile] joenotcharles.livejournal.com
Did you read the comments on that article? It's the readline library that's doing it - it only happens when you're sitting at the interactive prompt. The Python interpreter in general doesn't do any such thing.

Date: 2006-09-16 08:49 am (UTC)
From: [identity profile] pphaneuf.livejournal.com
It's actually a sort of trend they have in there, somewhere (from this bug):

static gboolean
pyg_signal_watch_prepare(GSource *source,
                         int     *timeout)
{
    /* Python only invokes signal handlers from the main thread,
     * so if a thread other than the main thread receives the signal
     * from the kernel, PyErr_CheckSignals() from that thread will
     * do nothing. So, we need to time out and check for signals
     * regularily too.
     * Also, on Windows g_poll() won't be interrupted by a signal
     * (AFAIK), so we need the timeout there too.
     */
#ifndef PLATFORM_WIN32
    if (pyg_threads_enabled)
#endif
        *timeout = 100;
    return FALSE;
}


And on Windows, it'll suck all the time. It's kind of ironic, considering signals don't exist on Windows. In any case, see also [livejournal.com profile] kernelslacker's paper/slides from OLS2006, and strace random processes on your system, it's all rather depressing. I didn't mean to point a finger at Python in particular, as much as to anyone who might be doing such awful things, be them libreadline, Python or whoever.

Appropriate gadget

Date: 2006-09-18 11:14 am (UTC)
From: [identity profile] colinleroy.livejournal.com
For an appropriate gadget suitable to french plugs, see http://www.castorama.fr/boutique/sku/sku.jhtml?elementId=Casto508075&productId=CastoEL1208&_requestid=76080

Re: Appropriate gadget

Date: 2006-09-18 11:34 am (UTC)
From: [identity profile] pphaneuf.livejournal.com
Cool, and it's not too expensive either, I might just get one! Eurgh, I might have to get a ride, though... ;-)

February 2016

S M T W T F S
 123456
7891011 1213
14151617181920
21222324252627
2829     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 6th, 2025 02:24 am
Powered by Dreamwidth Studios