Domanda

In my server written in Stackless Python, I occasionally am getting large spikes in CPU usage for 5-10 seconds durations. This happens sporadically so I'm having trouble tracking it down.

I've used cProfile to try and determine where these spikes are coming from but cProfile gives an overall picture of where time is being spent per function. What I would really like to know is whether the CPU spikes are due to some processing occurring in a single tasklet (and stalling other tasklets) or if there are multiple tasklets doing a lot of processing (ie. as each becomes active, each is doing a lot of work).

Is there a convenient way to hook into the scheduler in Stackless Python so that I can add some timing code? In other words, is there a function that is invoked when a tasklet becomes active and when it becomes inactive that I can hook into?

È stato utile?

Soluzione

I haven't found an explicit function to hook into when a tasklet blocks/resumes, but since Channel.receive() is typically when the block/resume occurs, I hooked into every occurrence of that happening.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top