Guides To Analyzing WebKit Performance


Published on

This talk will be about approaching WebKit. Goals: (1) Show ways to approach the codebase. (2) Establish ''do not guess but measure'' attitude.

Published in: Technology
  • HI. Does this mean that webkit on Android uses its own skia libraries for image and audio decoding instead of the native bitmap and skia libraries?
    Are you sure you want to  Yes  No
    Your message goes here
  • Godd
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Guides To Analyzing WebKit Performance

  1. 1. Guides To Analyzing WebKit Performance – Looking at the internals –Holger FreytherDeveloper, WebKit ProjectJim Huang ( 黃敬群 ) <>Developer & Co-founder, 0xlab April 28, 2011 / Android System Development Forum
  2. 2. Rights to copy © Copyright 2011 0xlab contact@0xlab.orgAttribution – ShareAlike 3.0 Corrections, suggestions, contributions andYou are free translations are welcome! to copy, distribute, display, and perform the work to make derivative works Latest update:April 28, 2011 to make commercial use of the workUnder the following conditions Attribution. You must give the original author credit. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder.Your fair use and other rights are in no way affected by the above.License text:
  3. 3. The Goal of This Talk(1)• Optimize WebKit for the Content?• Optimize the Content for WebKit?
  4. 4. The Goal of This Talk(2)• For optimizing content, see the remote inspector work • Another example: Opera Mobile Accelerator• This talk will be about approaching WebKit
  5. 5. The Goal of This Talk(3)• Take the fear from working on a big project.• Show ways to approach the codebase.• Establish do not guess but measure attitude.
  6. 6. Agenda (1) What is WebKit (project)? (2) Android & WebKit (3) How to prepare Android to measure?
  7. 7. What Groups are Responsible for Managing it?
  8. 8. WebKit ArchitectureWebKit GTK WebKit Mac QtWebKit WebCore JavascriptCoreNetworking Graphics 8
  9. 9. (Flexible) WebKit Implementations WebKit GTK WebCore JavascriptCorecurl / soup cairo & pango 9
  10. 10. WebKit drawn to Gtk+ eventWebCore Refresh the surface (expose event) Gtk+ window Gtk+ window Gtk+ WebKit Qt cairo cairo „expose event“ callback Gtk+ surface Gtk+ surface
  11. 11. WebKit drawn to Gtk+ applications „update-requested“WebCore event event Gtk+ program „update-requested“ callback Gtk+ WebKit Qt cairo Refreshing the surface cairo surface (every supported cairo surface)
  12. 12. What Is the WebKit Project?• ~80 Reviewers• ~110 Committers• 8 ports in the tree• Apple and Google (Chromium) are major contributors• Many commits per day
  13. 13. How Does WebKit Work?• Check • Goals vs. Non-Goals• Content Engine, Security, Performance and more• Every change needs review, no performance regression allowed• But performance tests are private due to copyright laws
  14. 14. Android & WebKit• Android is not involved with the WebKit project • Android style open source model• Android is using Chromium as upstream• Android does not include the data for Quality Assurance (tests)• Who is fixing known security issues in the Android code? WebKit Androids Chromium WebKit fork
  15. 15. WebKit in Android eventWebCore Refresh the surface (expose event) Android.webkit.WebViewCore android.webkit.WebView Skia bridge ... WebKit skia skia JNI v8 Gtk+ JNI Surface Surface
  16. 16. UI Element GLSurfaceView javax .microedition .khronos .openglesView and Canvas → Surface View and Canvas → Surface android. view. View android. view. Surface android graphics. Canvas . Java Graphics JAVA is implemented Framework via JNI Native Framework Surface JNI Graphic JNI OpenGL JNI SurfaceFlinger skia OpenGL|ES libui ++ libui SurfaceFlinger ++ SurfaceFlinger libpixelflinger libui libpixelflinger Overlay Camera Surface Key / Event format EglWindows libpixelflinger FrameBuffer Driver Event Input Driver
  17. 17. Moving To Performance Now• What is performance?• How to measure it on GNU/Linux?• How to do it on Android/ARM?
  18. 18. Computer Performance• Amount of useful work accomplished• Examples: • how fast does the page load? • How many frames per second are drawn? • How little/much bandwidth is used?• Optimization mostly trade off between Memory and CPU usage
  19. 19. Performance Experiments• Do not assume, meassure it!• Have a manual or automatic testcase• Observe the system while running the testcase• Analyze the situation, make changes• Repeat until considered good enough
  20. 20. Performance Experiments – Manual• Easy to setup• Open a site and wait, or scroll• Good for getting an idea• Bad for repeating and comparing results
  21. 21. Performance Experiments – Automatic • More difficult to create • Requires stable content • Should allow to compare results • Talos and others as a framework •
  22. 22. How to Observe on GNU/Linux• perf (new way)• oprofile (old way)• Both are sampling profilers • ARM Performance Counter; PMU (Performance Measurement Unit)
  23. 23. ProfilingTriggerProfiling Prof.out Profiling Analysis Engine Profiling data preparation
  24. 24. Evaluating and Tuning Tune Performance by CPU Configuration Simulate ProfilingQualified? No Yes END
  25. 25. Reference oprofile usage# prepare the setup$ rm -rf /var/lib/oprofile$ opcontrol --start-daemon -p library -c 10# run the app once to force loading it from nfs into the cache$ ./tst_something# start profiling$ opcontrol –start$ ./tst_something -iterations enough# stop profiling$ opcontrol -h# generate reports$ opreport -l$ opreport -c …
  26. 26. Profiler sampleProfile Result (A)Profile Result (B)
  27. 27. perf is powerful. perf is powerful.# perf record -s CMD # perf record -s CMD Error: perfcounter syscall returned with -1 (Function not implemented) Error: perfcounter syscall returned with -1 (Function not implemented) Fatal: No CONFIG_PERF_EVENTS=y kernel support configured? Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
  28. 28. How to Do On Android/ARM?• for Native libraries → • Use perf built without libperl, libpython • oprofiled and opcontrol are there, CPU data is missing • Binaries for ARM need frame pointers to have backtraces• Java part is the performance hell always. • traceview is a great tool for Java performance analysis. • JVMTI / JDWP (Java Debug Wire Protocol, normally spoken between a VM and a debugger)
  29. 29. How to Do On Android/ARM?• Upload some more files• Start oprofile with opcontrol on the device• Run the test on the device• Analyze with opreport on the PC
  30. 30. # Overhead Command Shared Object Symbol# ........ ............... ..................... ......# 89.23% system_server 2b0c6c [.] 0x000000002b0c6c 1.26% MLVdo_thread [kernel_helper] [k] 0x0000000017aa90 1.05% d.process.acore [.] S32A_Opaque_BlitRow32_arm 0.83% d.process.acore [.] android_memset32 0.63% system_server [.] memcpy 0.63% d.process.acore [.] memsetsystem_server is the process name of Android system_server is the process name of AndroidFramework runtime. ItItoccupies most of CPU Framework runtime. occupies most of CPUresources, but ititis hard to figure out details resources, but is hard to figure out detailsonly by native tools like perf. only by native tools like perf. We can always optimize known performance hotspot We can always optimize known performance hotspot routines such as S32A_Opaque_BlitRow32_arm but routines such as S32A_Opaque_BlitRow32_arm but should be measured in advance. should be measured in advance.
  31. 31. Picking or Creating a Testcase• What to measure? Loading, Painting, Scrolling?• No excellent benchmark suite available due to copyright issues• Some frameworks are available, but mostly manual work
  32. 32. Introducing The Methanol Framework • Small Framework from the University of Szeged • Can load pages and count the time • Provides a summary with error interval
  33. 33.
  34. 34. Issues With Methanol Framework• Webpages need to be converted• Everything loaded from the same URL•
  35. 35. Putting Everything Together• Using methanol with the example page• Executing it in the Browser• Observing it with oprofile/perf
  36. 36.