XHProf provides information about execution time • Time spent by the server to generate page sent to the web browser (or API endpoint) • Also measures memory & CPU usage
XHProf does not measure: • Time to First Byte (TTFB) • Page render time (happens in the browser) • Other aspects of front-end performance • For page render time, see Chrome Dev tools, YSlow
Our goal: Reduce page execution time • Improve user experience • Improve concurrency and efficient use of server resources.
Avoid speculation: • “Maybe it’s x” • Wasted time on fruitless investigation • Wasted time on inappropriate remediations • Vague problem descriptions, “Eg, Views is slow”
Be smart, m’kay? • Tools like Views & Panels empower you to do inefficient things but aren’t necessarily bad for performance • Views render & query, Panels pane caches are great tools to improve performance
Example problem statement • “Entity loads are slow because when we load entities, we load field X which also loads Y data, which spends Z time in the database. Page A loads 1,000 entities of type X.”
Use XHProf to • Pinpoint the root cause of performance problems • Develop a surgical remediation plan
Key UI Elements • # of function cal s • Wal time (Inclusive/exclusive) • Memory usage • CPU time
Exclusive/Inclusive • Exclusive: This function only • Inclusive: This function and al child functions
CPU Time vs Wal Time • CPU Time: Time spent by the CPU • Wal time: Time including disk I/O • CPU time != Wal time? Likely waiting for disk
We may find: • Function cal ed many times unnecessarily • Consider a static cache
We may find: • Slow queries • Execute page again with Devel query log, use built-in explain feature
We may find: • Many fast queries that stack up
We may find
We may find • Queries that are quick to execute but slow to assemble
We may find: • Excessive entity loads • Excessive cal s to memcache set/get
What is “excessive” • It depends! Know your app. • Maybe you need that data on that request: Make it less expensive to compute • Maybe you don’t need that data: Don’t compute it
We may find: • Page-blocking cal s (eg, 3rd-party API requests) • Queue these
We may find: • Excessive cal s to watchdog() • Notices can slow down your site. • Fix those notices!
We may find: • Views/Panels render time - Dig deeper!