• Low latency, high throughput, power efficient, fast response… • Would you like to use slow software? • Have you ever see that people saying “many features are important than speed” loves slow software actually? • No!
the fundamental value of software • Marketing value • New comer sometimes beat down other products by performance • In 2008, Google Chrome beat down other browsers
normalize software performance by benchmark • Reproducibility is important • Keep our application faster from regression • We use benchmark to evaluate our application performance
is when start to play video • What is meaningful metric? • First Meaningful Paint/First Content Paint is nice • Time to Interactive? • Is it meaningful for this service actually? • Think about the bad case that page is responsible but video is not started
is useful to measure performance of general web page • e.g. Startup time • But general metrics cannot catch up application specific performance • Measure real scenario for your application • What is your application doing? • What is purpose?
• Application specific • We should think about what performance metrics is most suitable • Not only Lighthouse! • We should focus actual scenario that our application will do
my slow code! • But the running time/ops is pretty small… (e.g. ~0.1ms/ops) • I cannot find a difference! • I have nice idea. Run this code 10000 times • The result will be stretched! Easy to compare! • …Wait! Is this nice approach really?
optimize user code • e.g. JavaScriptCore has 4 tier (LLInt, Baseline, DFG, FTL) • JIT compiler change optimization level speculatively by how much you code run • Hot path (executed frequently) would be heavily optimized • Cold path (executed rarely) would be less optimized
• Typical micro-benchmark execute many iterations to stabilize results • But many iteration would make functions compiled with heavy optimizations by highest JIT tier • If your actual workload is run only several times, many iteration leads a different results from what you expected • Let’s see execution time changes of some cases from JetStream2
Workload may changes your benchmark score • Be careful to profile on actual workload as possible • Invalid assumption mislead your optimization strategy • By misleading, your application might go wrong…
‘defer’ attribute to <script/> to improve the overall page init speed • But it did not improve the first meaningful paint. Why? cite: https://docs.google.com/presentation/d/1MXlFGqFQFJByv8k6Ege0pt0GwJQqbjoh7GdIYia9UQg/
which starts working on DOMContentLoaded • script[defer] does not change this behavior • This “bootstrap” script is small size and fast execution • The profiler does not show up it as a “bottleneck” point easily cite: https://docs.google.com/presentation/d/1MXlFGqFQFJByv8k6Ege0pt0GwJQqbjoh7GdIYia9UQg/
for crosscutting analyzing bottleneck • But be careful, profiler sometimes shows unrelated values • It often requires domain specific knowledge • How your application works? • Is it a real bottleneck? • Performance Tracing for Tasks • Causal Profling [Curtsinger+, SOSP ‘15] (Virtual Speedup) cite: https://docs.google.com/presentation/d/1MXlFGqFQFJByv8k6Ege0pt0GwJQqbjoh7GdIYia9UQg/
one on same devices • https://bugzilla.mozilla.org/show_bug.cgi?id=1556022 • https://bugzilla.mozilla.org/show_bug.cgi?id=1570313 • This means simply that “Firefox network stack is slow"? • We tend to think so. Really?
• This site use XMLHttpRequest but its responseType is text for download test • Why not use “.responseType=arraybuffer”? • In worst case, this waste 59% of overall processing time in paint phase • Fancy animation caused performance issue that is not related to networking! What did this benchmark measure in Firefox?
• This site use XMLHttpRequest but its responseType is text for download test • Why not use “.responseType=arraybuffer”? • In worst case, this waste 59% of overall processing time in paint phase • Fancy animation caused performance issue that is not related to networking! What did this benchmark measure in Firefox?
hidden • Profiler might not shown them • There are may be problem which you cannot control • Improve your application actually, insight for your application specific behavior is most important • Breakdown bottlenecks with various tools & knowledge
to make a program faster is to never let get it slower” • https://webkit.org/performance/ • Let’s benchmark your application continuously, and plot results, per commit
term Trend • Each of score may bit change randomly by others • Other OS’ services, other guests on hypervisor, and more • Reproducible Infrastructure is important to test again
• Analyze perf issues deeply with tools & your app specific knowledge • CI is nice to keep performance through iteration cycles • First step: Benchmark your application based on your story