John A Meinel wrote:
[...]
> How do you profile the twisted server, though?
It's just Python, which you know how to profile, so I guess you're
specifically asking how to profile something run via twistd(1)? Add
--profile=profile.stats (and maybe --profiler=cprofiler) to the twistd
invocation.
(If you're invoking reactor.run() directly for some reason, then
obviously you can just use the usual profiling APIs.)
Also, you could rig the process to enable/disable profiling when poked
by a signal or similar, regardless of how it was started. I think
something like this would work, but I haven't tested:
import cProfile, signal
profile = cProfile.Profile()
profiling = False
def toggle_profiler(*ignored):
global profiling
if not profiling: profile.enable()
else: profile.disable() profile.dump_stats('/tmp/profile.stats')
signal.signal(signal.SIGUSR1, toggle_profiler)
Also, along the lines of Martin's suggestion, I'd expect “perf record
twistd ...” followed by “perf report” would probably show if a
significant proportion of the time is spent in crypto libraries, generic
Python, or something else entirely. (Conch uses PyCrypto, which should
be doing the hard work in C functions, unless somehow the packaging is
broken, which seems unlikely.)
John A Meinel wrote:
[...]
> How do you profile the twisted server, though?
It's just Python, which you know how to profile, so I guess you're profile. stats (and maybe --profiler= cprofiler) to the twistd
specifically asking how to profile something run via twistd(1)? Add
--profile=
invocation.
(If you're invoking reactor.run() directly for some reason, then
obviously you can just use the usual profiling APIs.)
Also, you could rig the process to enable/disable profiling when poked
by a signal or similar, regardless of how it was started. I think
something like this would work, but I haven't tested:
import cProfile, signal profiler( *ignored) :
profile. enable( )
profile. disable( )
profile. dump_stats( '/tmp/profile. stats') signal( signal. SIGUSR1, toggle_profiler)
profile = cProfile.Profile()
profiling = False
def toggle_
global profiling
if not profiling:
else:
signal.
Also, along the lines of Martin's suggestion, I'd expect “perf record
twistd ...” followed by “perf report” would probably show if a
significant proportion of the time is spent in crypto libraries, generic
Python, or something else entirely. (Conch uses PyCrypto, which should
be doing the hard work in C functions, unless somehow the packaging is
broken, which seems unlikely.)