[medusa] Re: tweaks to asyn{core,chat}.py

Skip Montanaro skip@m...
Sat, 20 Nov 1999 07:25:55 -0600 (CST)


Sam> But there are other areas that need tweaking, the poll() overhead
Sam> is no long on top of the list. I have modified a python here to do
Sam> a type of statistical profiling (every <checkinterval> VM insns a
Sam> dictionary of {<code-object>:<count>} is updated). Here's what
Sam> made me look at refill_buffer():

Sam> [...]
Sam> 4211 <code object handle_read at 810e260, file "../asynchat.py", line 77>
Sam> 4970 <code object refill_buffer at 81143a8, file "../asynchat.py", line 170>

Have you sent this to Guido? A statistical profiler would be a nice
complement to the regular (machine-eating) profiler. If you have a patch,
I'd like to take a look at it. (I'd probably change the simple counter to a
time accumulator the way gprof works.)

>> Another optimization would be to have a system of re-entering the
>> select call immediately after returning if nothing is ready--rather
>> than checking the results and rebuilding the arguments to the select
>> call.

Sam> This is a really good idea! it's getting into an interesting area,
Sam> of trying to be smarter about scheduling the r/w sets. I think
Sam> there are some things like that to be found here:

I've experienced cases where is sits for the timeout period (typically 30
seconds), then adds a fd that was in the read set to the write set as well
(or was it the other way 'round?), after which the next select returns
immediately.

Skip Montanaro | http://www.mojam.com/
skip@m... | http://www.musi-cal.com/
847-971-7098 | Python: Programming the way Guido indented...