<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

Profiling

From SqueezeboxWiki

Revision as of 05:52, 23 June 2010 by Soulkeeper (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Profiling SqueezeCenter

The recommended tool to use in profiling SqueezeCenter is Devel::NYTProf. NYTProf is a line-based profiler that tracks the execution time of every line of code, and allows you to follow method calls in the code through a nice web interface.

There are two basic ways of profiling a program: complete execution and selective execution.

Complete

Complete execution profiles everything, including startup and shutdown costs. This can be useful some of the time, but generally the one-time cost of, for example, loading plugins or waiting for MySQL to start is not very interesting and clutters up the report.

# Start the server with the profiler enabled
perl -d:NYTProf slimserver.pl
# Use the server for a bit

# Generate the report
perl -Ilib -ICPAN /usr/bin/nytprofhtml

nytprofhtml generates a lot of HTML files in an nytprof subdirectory. The reason we need to tell it about the lib and CPAN directories is because SqueezeCenter overrides some of the system modules with different versions.

You will probably see some warnings such as "Unable to open '../../lib/Storable.pm' for reading:", these can be safely ignored.

After the report is generated, open nytprof/index.html to view the report.

Selective

Selective execution allows you to start and stop the profiler while SqueezeCenter is running. You will need SqueezeCenter 7.2 or later for this method to work.

NYTPROF=start=no perl -d:NYTProf slimserver.pl
# Find the PID of the process and enable profiling via USR1
kill -USR1 12345
# Stop profiling with USR2
kill -USR2 12345
# Generate the report
perl -Ilib -ICPAN /usr/bin/nytprofhtml

More Reading

http://blog.timbunce.org/2008/07/15/nytprof-v2-a-major-advance-in-perl-profilers/

http://timbunce.blip.tv/file/1130150/

Candidates For Optimisation

See SqueezeCenterOpimisation for candidates for optimisation based on profiling.