Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Understanding XHProf: Pinpointing Why Your Site...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Ezra Gildesgame
April 19, 2014
Programming
0
200
Understanding XHProf: Pinpointing Why Your Site is Slow and How to Fix It
Ezra Gildesgame
April 19, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
310
Ruby and LLM Ecosystem 2nd
koic
1
1.4k
CS教育のDX AIによる育成の効率化
niftycorp
PRO
0
170
Claude Code Skill入門
mayahoney
0
450
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.6k
AI-DLC 入門 〜AIコーディングの本質は「コード」ではなく「構造」〜 / Introduction to AI-DLC: The Essence of AI Coding Is Not “Code” but “Structure”
seike460
PRO
0
110
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
320
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.4k
おれのAgentic Coding 2026/03
tsukasagr
1
120
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.2k
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
450
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
680
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
40
2.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Thoughts on Productivity
jonyablonski
75
5.1k
Utilizing Notion as your number one productivity tool
mfonobong
4
280
Designing Powerful Visuals for Engaging Learning
tmiket
1
310
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
120
Product Roadmaps are Hard
iamctodd
PRO
55
12k
AI: The stuff that nobody shows you
jnunemaker
PRO
4
500
Docker and Python
trallard
47
3.8k
Building AI with AI
inesmontani
PRO
1
830
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
500
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
390
Transcript
Understanding XHProf Pinpointing Why Your Site is Slow and How
to Fix It Ezra Gildesgame - Acquia @ezrabg Stanford Drupal Camp 2014
The Problem: Slow Websites/Web apps • Unhappy users leave •
Severs can’t sustain load
Every second counts • http://blog.kissmetrics.com/loading-time/
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”
Misconceptions
Misconceptions
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 calls • Wall
time (Inclusive/exclusive) • Memory usage • CPU time
Exclusive/Inclusive • Exclusive: This function only • Inclusive: This function
and all child functions
CPU Time vs Wall Time • CPU Time: Time spent
by the CPU • Wall time: Time including disk I/O • CPU time != Wall time? Likely waiting for disk
We may find: • Function called 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 calls
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 calls (eg, 3rd-party API requests)
• Queue these
We may find: • Excessive calls to watchdog() • Notices
can slow down your site. • Fix those notices!
We may find: • Views/Panels render time - Dig deeper!
We may find:
Getting started • Brew install xhprof • Install: http://drupal.org/project/xhprof •
Alternative: https://github.com/ msonnabaum/xhprof-single-file
Avoid dirty runs. • Eliminate menu rebuilds • Disable Devel
query log • Disable XDebug - Really. • Test as a non-admin (access control is expensive. We want to observe that.)
Know which caches are in place • Views caches (Disable
Views caches: https:// gist.github.com/msonnabaum/9671947) • Panels Caches • Other caches
Other caches
“ZOMG! The site is slow!” • ORLY • Develop a
plan to measure and set goals
“Slow” Define success with specific performance goals • Execution time
on specific page logged in as specific user under specific conditions • Quantify improvements on a per-page basis
Example template
Case examples
Example 1
Example: Static Caching in CTools https://drupal.org/node/2049087 • Eliminated ~128,000 calls
to t() • Reduced memory footprint • Reduced page execution time by 2 seconds • Simple fix
Example: Static caching of node access grants https://drupal.org/comment/8495029 • node_access_grants()
never changes within a request • Why compute it multiple times within a request?
Example: Avoid unnecessary entity loads https://drupal.org/node/2169099
Optimize node access query building https://drupal.org/comment/8516319
Questions?