Skip to content

Instantly share code, notes, and snippets.

@TwilightTechie
Last active January 17, 2024 11:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TwilightTechie/94f6fc54413e7d88b751615ff280af17 to your computer and use it in GitHub Desktop.
Save TwilightTechie/94f6fc54413e7d88b751615ff280af17 to your computer and use it in GitHub Desktop.
GSoC Final Project

Google Summer of Code 2023 Final Report

Project: Perf Data Converter - Adding Support for Gecko Converter in Perf Tool

Overview

This document presents the final report for the project "Perf Data Converter" undertaken as a part of the Google Summer of Code 2023 program with the Linux Perf Tool under the umbrella of The Linux Foundation. The project aimed to enhance the capabilities of the perf tool by adding support for the Gecko converter. The Gecko converter leverages a perf script interface, enabling effortless and streamlined analysis using the Firefox profiler.

Project Details

Achievements

The primary objective of the project was to introduce support for the Gecko converter within the perf tool. The Gecko script employs the perf script interface. The key achievements of the project include:

  1. Gecko Converter Integration: The project successfully integrated the Gecko converter into the perf tool. This integration enables users to execute the Gecko command effortlessly, simplifying the analysis process using the Firefox profiler.

  2. Profiler UI Launch Support: Another significant achievement of the project is the addition of support to launch the profiler UI on the default browser with the appropriate URL. This enhancement streamlines the workflow by providing users with direct access to the profiler's user interface for in-depth analysis.

  3. Test Coverage: As a part of the project, comprehensive testing was integrated to ensure the functionality and reliability of the added features. This includes:

    • perf test Integration: The project successfully introduced tests to validate the Gecko script's functionality. This ensures that the script behaves as expected and produces accurate results.
    • JSON Generation Validation: Additionally, the project included tests to validate the JSON generated by the perf data convert --to-json command. This further enhances the reliability of the data conversion process.
  4. Usage Instructions: The project provided clear and concise usage instructions for the newly added functionality. Users can employ the perf script gecko command, along with relevant options, to utilize the Gecko script for analysis.

  5. Command Line Flexibility: Users can customize Gecko script behavior using command line arguments. This flexibility allows users to tailor the analysis process according to their specific requirements.

  6. Process Visualization Options: The project also highlighted various options for visualizing the behavior of specific processes. Users can utilize commands like perf record -p <pid> and perf script report gecko to focus on particular processes and streamline analysis.

Patches/Contribution

The discussion I had with community can be found here. Below is the list of accepted patches:

  1. Add initial script file with usage information

  2. Extact necessary information from process event

  3. Add classes and conversion functions

  4. Add trace end processing and PRODUCT and CATEGORIES information

  5. Implemented Internal get or create frame, stack and string function

  6. Implement add sample function and thread processing

  7. Add command execution for gecko script

  8. Add support for input args in gecko script

  9. Launch the profiler UI on the default browser with the appropriate URL

  10. Add support for testing gecko script

  11. Add test validating JSON generated by 'perf data convert --to-json'

Usage Examples

The following are usage examples of the newly added functionality:

  1. Execute the Gecko script for analysis:

    perf script gecko -a sleep 60
    

    or

    perf record -a -g -F 99 sleep 60
    perf script report gecko
    
  2. Utilize command line arguments for the Gecko script:

    perf script report gecko [<options>]
    
  3. Visualize process behavior:

    • Capture data for a specific process:
      perf record -p <pid>
      perf script report gecko
      
    • Visualize behavior through perf report:
      1. Run perf report
      2. Select the target process
      3. Choose to run a script for the chosen process or all processes

Output Demo

In the screenshot, you can observe the various performance metrics, visualizations, and insights offered by the Firefox profiler. firefox_profiler_output

Further Work

  • Currently, the Gecko script only support user and kernel space stacks. Adding more categories for page fault and caches missed in stackTable of gecko script
  • Currently, the Gecko script lacks an opening browser when run in root mode.
  • We can make gecko command more simpler like perf gecko intread of perf script gecko

Acknowledgments

I'm extremely thankful to...

...my mentors - Arnaldo Carvalho de Melo, Ian Rogers and Namhyung Kim - for the constant support, guidance, fun weekly office hours.

...my friend Siddharth Bhardwaj for casually parting knowledge, from programming tips to late night debugging. Also Vedant Paranjape for constant support

...the kernel hackers who are a part of the perf mailing list and also, the maintainer of the perf subsystem of the Linux kernel, who all assisted me a great deal to get my patches accepted.

... Firefox Profiler team for collaboration which was invaluable. Their insights and guidance significantly contributed to my understanding of various aspect on Firefox Profiler side. We engaged in discussion through the matrix channel

...The Linux Foundation for organizing this learning-heavy performance-packed project.

...and finally, Google Open Source for orchestrating the GSoC program and ensuring a fruitful, fun-packed summer.

Conclusion

The successful integration of the Gecko converter into the perf tool enhances its capabilities, allowing users to analyze and profile applications using the Firefox profiler. The addition of the profiler UI launch support and comprehensive testing further enhance the user experience and reliability of the tool. The project's outcomes significantly contribute to the usability and efficiency of the perf tool, making it a more versatile choice for performance analysis tasks.

References

[1]: Perf WiKi: Perf Wiki - Firefox Profiler [2]: Firefox Profiler: official website [3]: Firefox Profiler Documentation: details on gecko format [4]: SimplePerf: gecko profile generator [5]: Samply: Samply Github

Contact Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment