BlogsShopifyV8 CPU Profiler Integration for v8go

V8 CPU Profiler Integration for v8go

V8 CPU Profiler Integration for v8go

1
posts
2022

This feature thread tracks the development and enhancement of Shopify's v8go library, focusing on integrating the V8 CPU Profiler. Initial efforts involved exposing core V8 functionality through Cgo bindings. This post details the addition of the V8 CPU Profiler, exploring the trade-offs between lazy and eager loading strategies for profile data to optimize performance and developer experience. The focus is on providing Go users with an idiomatic and performant way to measure JavaScript execution performance within V8 isolates.

2022

Adding the V8 CPU Profiler to v8go - Shopify

3/4/2022

This post details the integration of the V8 CPU Profiler into the v8go library. It explores two primary implementation strategies: lazy loading, where Cgo calls are made for each profile property, and eager loading, where the entire profile graph is built in C++ and passed as a single pointer to Go. Benchmarks comparing these approaches for small and large JavaScript execution trees are presented, highlighting the performance implications of Cgo overhead and the benefits of eager loading for larger profiles. The post also discusses the design considerations for an API that is easy to reason about, extendable, aligned with the V8 API, and performant.