在v8go中添加V8 CPU分析器

V8 is Google’s open source high-performance JavaScript and WebAssembly engine written in C++. v8go is a library written in Go and C++ allowing users to execute JavaScript from Go using V8 isolates. Using Cgo bindings allows us to run JavaScript in Go at native performance.

V8是Google用C++编写的开源高性能JavaScript和WebAssembly引擎。v8go是一个用Go和C++编写的库,允许用户使用V8隔离物从Go执行JavaScript。使用Cgo绑定允许我们在Go中以原始性能运行JavaScript。

The v8go library, developed by Roger Chapman, aims to provide an idiomatic way for Go developers to interface with V8. As it turns out, this can be tricky. For the past few months, I’ve been contributing to v8go to expose functionality in V8. In particular, I’ve been adding support to expose the V8 CPU Profiler

v8go库由Roger Chapman开发,旨在为Go开发者提供一种与V8对接的习惯性方法。事实证明,这可能是很棘手的。在过去的几个月里,我一直在为v8go做贡献,以暴露V8的功能。特别是,我一直在增加对V8 CPU分析器的支持。

From the start, I wanted this new API to be:

从一开始,我就希望这个新的API是。

  • easy for the library's Go users to reason about
  • 对图书馆的围棋用户来说,易于推理
  • easy to extend for other profiler functionality eventually
  • 最终易于扩展其他分析器的功能
  • aligned closely with the V8 API
  • 与V8 API紧密结合
  • as performant as possible.
  • 尽可能地提高性能。

The point about performance is especially interesting. I theorized that my first iteration of the implementation was less performant than a proposed alternative. Without benchmarking them, I proceeded to rewrite. That second implementation was merged, and I moved on with my life. So when I was like "Hey! I should write a post about the PR and benchmark the results" only to actually see the benchmarks and reconsider everything.

关于性能的观点特别有趣。我推测,我的第一个迭代实现的性能不如一个拟议的替代方案。在没有对它们进行基准测试的情况下,我继续重写。第二个实现被合并了,然后我继续我的生活。所以,当我想 "嘿!我应该写一篇关于PR的文章,并对结果进行基准测试 "的时候,才真正看到了基准测试,并重新考虑了一切。

If you’re interested in API development, Go/Cgo/C++ performance or the importance of good benchmarks, this is a story for you.

如果你对API开发、Go/Cgo/C++性能或良好的基准测试的重要性感兴趣,这就是一个适合你的故事。

Backing Up to the Starting Line: What Was My Goal?

倒退到起跑线上。我的目标是什么?

The goal of adding the V8 CPU Profiler to v8go was so users of the library could measure the performance of any Java...

开通本站会员,查看完整译文。

Home - Wiki
Copyright © 2011-2024 iteam. Current version is 2.139.0. UTC+08:00, 2024-12-23 03:41
浙ICP备14020137号-1 $Map of visitor$