flutter / flutter/devtools

Performance improvements to CPU profile code

Đang mở
#7,917 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
dart2wasm devtools app performance P2 product-quality screen: cpu profiler
Ngôn ngữ chính
Dart
Star
1.7k
Fork
404
Merge trung bình
6 ngày 17 giờ
Pull request đã merge (30 ngày)
18

Mô tả

After having taken a look at the cpu profiling code in DevTools, we found:

* It unnecessarily encodes json maps and decodes them again: [devtools/pull/7916](https://github.com/flutter/devtools/pull/7916)
* It gets `Stream */>` from the websocket and then json decodes strings
=> It would be more efficient to avoid going from utf-8 to string and then to json and instead directly from utf8->json
=> This would probably require some refactoring in various packages, so maybe not easily doable?
* Way too many conversions
* Bytes->String in websocket layer
* String->JSON in `package:vm_service layer`
* JSON -> service objects in `package:vm_service` layer (e.g. `vm_service.CpuSamples`, `vm_service.CpuSample`)
* service objects -> `_CpuProfileTimelineTree` tree structure
=> Uses expandos (!!) to map service objects back to tree nodes
* `_CpuProfileTimelineTree` -> JSON "traceObject" (very expensive operation!)
* Going from JSON "traceObject" back to normal objects in `CpuProfileData.fromJson` which builds json maps with strings and `CpuStackFrame` as values

It seems there's too many conversions from one data structure to another and the representations used for encoding this profiling information doesn't seem very efficient either.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.