Skip to main content

cdp_driver/protocol/
heap_profiler.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `HeapProfiler` domain.
5//!
6//! Types, command parameters and event payloads for the `HeapProfiler`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9//!
10//! This domain is experimental and may change without notice.
11
12use serde::{Deserialize, Serialize};
13
14/// Heap snapshot object id.
15pub type HeapSnapshotObjectId = String;
16
17/// Sampling Heap Profile node. Holds callsite information, allocation
18/// statistics and child nodes.
19#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
20pub struct SamplingHeapProfileNode {
21    /// Function location.
22    #[serde(rename = "callFrame")]
23    pub call_frame: crate::protocol::runtime::CallFrame,
24    /// Allocations size in bytes for the node excluding children.
25    #[serde(rename = "selfSize")]
26    pub self_size: f64,
27    /// Node id. Ids are unique across all profiles collected between
28    /// startSampling and stopSampling.
29    pub id: i64,
30    /// Child nodes.
31    pub children: Vec<SamplingHeapProfileNode>,
32}
33
34/// A single sample from a sampling profile.
35#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
36pub struct SamplingHeapProfileSample {
37    /// Allocation size in bytes attributed to the sample.
38    pub size: f64,
39    /// Id of the corresponding profile tree node.
40    #[serde(rename = "nodeId")]
41    pub node_id: i64,
42    /// Time-ordered sample ordinal number. It is unique across all profiles
43    /// retrieved between startSampling and stopSampling.
44    pub ordinal: f64,
45}
46
47/// Sampling profile.
48#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
49pub struct SamplingHeapProfile {
50    pub head: SamplingHeapProfileNode,
51    pub samples: Vec<SamplingHeapProfileSample>,
52}
53
54/// Enables console to refer to the node with given id via $x (see Command
55/// Line API for more details $x functions).
56///
57/// Parameters of `HeapProfiler.addInspectedHeapObject`.
58#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
59pub struct AddInspectedHeapObjectParams {
60    /// Heap snapshot object id to be accessible by means of $x command line API.
61    #[serde(rename = "heapObjectId")]
62    pub heap_object_id: HeapSnapshotObjectId,
63}
64
65impl crate::typed::Command for AddInspectedHeapObjectParams {
66    const METHOD: &'static str = "HeapProfiler.addInspectedHeapObject";
67    type Returns = crate::typed::NoReturns;
68}
69
70/// Parameters of `HeapProfiler.collectGarbage`.
71#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
72pub struct CollectGarbageParams {}
73
74impl crate::typed::Command for CollectGarbageParams {
75    const METHOD: &'static str = "HeapProfiler.collectGarbage";
76    type Returns = crate::typed::NoReturns;
77}
78
79/// Parameters of `HeapProfiler.disable`.
80#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
81pub struct DisableParams {}
82
83impl crate::typed::Command for DisableParams {
84    const METHOD: &'static str = "HeapProfiler.disable";
85    type Returns = crate::typed::NoReturns;
86}
87
88/// Parameters of `HeapProfiler.enable`.
89#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
90pub struct EnableParams {}
91
92impl crate::typed::Command for EnableParams {
93    const METHOD: &'static str = "HeapProfiler.enable";
94    type Returns = crate::typed::NoReturns;
95}
96
97/// Parameters of `HeapProfiler.getHeapObjectId`.
98#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
99pub struct GetHeapObjectIdParams {
100    /// Identifier of the object to get heap object id for.
101    #[serde(rename = "objectId")]
102    pub object_id: crate::protocol::runtime::RemoteObjectId,
103}
104
105/// What `HeapProfiler.getHeapObjectId` answers with.
106#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
107pub struct GetHeapObjectIdReturns {
108    /// Id of the heap snapshot object corresponding to the passed remote object
109    /// id.
110    #[serde(rename = "heapSnapshotObjectId")]
111    pub heap_snapshot_object_id: HeapSnapshotObjectId,
112}
113
114impl crate::typed::Command for GetHeapObjectIdParams {
115    const METHOD: &'static str = "HeapProfiler.getHeapObjectId";
116    type Returns = GetHeapObjectIdReturns;
117}
118
119/// Parameters of `HeapProfiler.getObjectByHeapObjectId`.
120#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
121pub struct GetObjectByHeapObjectIdParams {
122    #[serde(rename = "objectId")]
123    pub object_id: HeapSnapshotObjectId,
124    /// Symbolic group name that can be used to release multiple objects.
125    #[serde(
126        rename = "objectGroup",
127        default,
128        skip_serializing_if = "Option::is_none"
129    )]
130    pub object_group: Option<String>,
131}
132
133/// What `HeapProfiler.getObjectByHeapObjectId` answers with.
134#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
135pub struct GetObjectByHeapObjectIdReturns {
136    /// Evaluation result.
137    pub result: crate::protocol::runtime::RemoteObject,
138}
139
140impl crate::typed::Command for GetObjectByHeapObjectIdParams {
141    const METHOD: &'static str = "HeapProfiler.getObjectByHeapObjectId";
142    type Returns = GetObjectByHeapObjectIdReturns;
143}
144
145/// Parameters of `HeapProfiler.getSamplingProfile`.
146#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
147pub struct GetSamplingProfileParams {}
148
149/// What `HeapProfiler.getSamplingProfile` answers with.
150#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
151pub struct GetSamplingProfileReturns {
152    /// Return the sampling profile being collected.
153    pub profile: SamplingHeapProfile,
154}
155
156impl crate::typed::Command for GetSamplingProfileParams {
157    const METHOD: &'static str = "HeapProfiler.getSamplingProfile";
158    type Returns = GetSamplingProfileReturns;
159}
160
161/// Parameters of `HeapProfiler.startSampling`.
162#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
163pub struct StartSamplingParams {
164    /// Average sample interval in bytes. Poisson distribution is used for the
165    /// intervals. The default value is 32768 bytes.
166    #[serde(
167        rename = "samplingInterval",
168        default,
169        skip_serializing_if = "Option::is_none"
170    )]
171    pub sampling_interval: Option<f64>,
172    /// Maximum stack depth. The default value is 128.
173    #[serde(
174        rename = "stackDepth",
175        default,
176        skip_serializing_if = "Option::is_none"
177    )]
178    pub stack_depth: Option<f64>,
179    /// By default, the sampling heap profiler reports only objects which are
180    /// still alive when the profile is returned via getSamplingProfile or
181    /// stopSampling, which is useful for determining what functions contribute
182    /// the most to steady-state memory usage. This flag instructs the sampling
183    /// heap profiler to also include information about objects discarded by major
184    /// GC, which will show which functions cause large temporary memory usage or
185    /// long GC pauses.
186    #[serde(
187        rename = "includeObjectsCollectedByMajorGC",
188        default,
189        skip_serializing_if = "Option::is_none"
190    )]
191    pub include_objects_collected_by_major_gc: Option<bool>,
192    /// By default, the sampling heap profiler reports only objects which are
193    /// still alive when the profile is returned via getSamplingProfile or
194    /// stopSampling, which is useful for determining what functions contribute
195    /// the most to steady-state memory usage. This flag instructs the sampling
196    /// heap profiler to also include information about objects discarded by minor
197    /// GC, which is useful when tuning a latency-sensitive application for
198    /// minimal GC activity.
199    #[serde(
200        rename = "includeObjectsCollectedByMinorGC",
201        default,
202        skip_serializing_if = "Option::is_none"
203    )]
204    pub include_objects_collected_by_minor_gc: Option<bool>,
205}
206
207impl crate::typed::Command for StartSamplingParams {
208    const METHOD: &'static str = "HeapProfiler.startSampling";
209    type Returns = crate::typed::NoReturns;
210}
211
212/// Parameters of `HeapProfiler.startTrackingHeapObjects`.
213#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
214pub struct StartTrackingHeapObjectsParams {
215    #[serde(
216        rename = "trackAllocations",
217        default,
218        skip_serializing_if = "Option::is_none"
219    )]
220    pub track_allocations: Option<bool>,
221}
222
223impl crate::typed::Command for StartTrackingHeapObjectsParams {
224    const METHOD: &'static str = "HeapProfiler.startTrackingHeapObjects";
225    type Returns = crate::typed::NoReturns;
226}
227
228/// Parameters of `HeapProfiler.stopSampling`.
229#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
230pub struct StopSamplingParams {}
231
232/// What `HeapProfiler.stopSampling` answers with.
233#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
234pub struct StopSamplingReturns {
235    /// Recorded sampling heap profile.
236    pub profile: SamplingHeapProfile,
237}
238
239impl crate::typed::Command for StopSamplingParams {
240    const METHOD: &'static str = "HeapProfiler.stopSampling";
241    type Returns = StopSamplingReturns;
242}
243
244/// Parameters of `HeapProfiler.stopTrackingHeapObjects`.
245#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
246pub struct StopTrackingHeapObjectsParams {
247    /// If true 'reportHeapSnapshotProgress' events will be generated while
248    /// snapshot is being taken when the tracking is stopped.
249    #[serde(
250        rename = "reportProgress",
251        default,
252        skip_serializing_if = "Option::is_none"
253    )]
254    pub report_progress: Option<bool>,
255    /// Deprecated in favor of `exposeInternals`.
256    ///
257    /// Deprecated in the protocol.
258    #[serde(
259        rename = "treatGlobalObjectsAsRoots",
260        default,
261        skip_serializing_if = "Option::is_none"
262    )]
263    pub treat_global_objects_as_roots: Option<bool>,
264    /// If true, numerical values are included in the snapshot
265    #[serde(
266        rename = "captureNumericValue",
267        default,
268        skip_serializing_if = "Option::is_none"
269    )]
270    pub capture_numeric_value: Option<bool>,
271    /// If true, exposes internals of the snapshot.
272    ///
273    /// Experimental: may change without notice.
274    #[serde(
275        rename = "exposeInternals",
276        default,
277        skip_serializing_if = "Option::is_none"
278    )]
279    pub expose_internals: Option<bool>,
280}
281
282impl crate::typed::Command for StopTrackingHeapObjectsParams {
283    const METHOD: &'static str = "HeapProfiler.stopTrackingHeapObjects";
284    type Returns = crate::typed::NoReturns;
285}
286
287/// Parameters of `HeapProfiler.takeHeapSnapshot`.
288#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
289pub struct TakeHeapSnapshotParams {
290    /// If true 'reportHeapSnapshotProgress' events will be generated while
291    /// snapshot is being taken.
292    #[serde(
293        rename = "reportProgress",
294        default,
295        skip_serializing_if = "Option::is_none"
296    )]
297    pub report_progress: Option<bool>,
298    /// If true, a raw snapshot without artificial roots will be generated.
299    /// Deprecated in favor of `exposeInternals`.
300    ///
301    /// Deprecated in the protocol.
302    #[serde(
303        rename = "treatGlobalObjectsAsRoots",
304        default,
305        skip_serializing_if = "Option::is_none"
306    )]
307    pub treat_global_objects_as_roots: Option<bool>,
308    /// If true, numerical values are included in the snapshot
309    #[serde(
310        rename = "captureNumericValue",
311        default,
312        skip_serializing_if = "Option::is_none"
313    )]
314    pub capture_numeric_value: Option<bool>,
315    /// If true, exposes internals of the snapshot.
316    ///
317    /// Experimental: may change without notice.
318    #[serde(
319        rename = "exposeInternals",
320        default,
321        skip_serializing_if = "Option::is_none"
322    )]
323    pub expose_internals: Option<bool>,
324}
325
326impl crate::typed::Command for TakeHeapSnapshotParams {
327    const METHOD: &'static str = "HeapProfiler.takeHeapSnapshot";
328    type Returns = crate::typed::NoReturns;
329}
330
331/// Payload of the `HeapProfiler.addHeapSnapshotChunk` event.
332#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
333pub struct AddHeapSnapshotChunkEvent {
334    pub chunk: String,
335}
336
337impl crate::typed::Event for AddHeapSnapshotChunkEvent {
338    const METHOD: &'static str = "HeapProfiler.addHeapSnapshotChunk";
339}
340
341/// If heap objects tracking has been started then backend may send update for
342/// one or more fragments
343///
344/// Payload of the `HeapProfiler.heapStatsUpdate` event.
345#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
346pub struct HeapStatsUpdateEvent {
347    /// An array of triplets. Each triplet describes a fragment. The first integer
348    /// is the fragment index, the second integer is a total count of objects for
349    /// the fragment, the third integer is a total size of the objects for the
350    /// fragment.
351    #[serde(rename = "statsUpdate")]
352    pub stats_update: Vec<i64>,
353}
354
355impl crate::typed::Event for HeapStatsUpdateEvent {
356    const METHOD: &'static str = "HeapProfiler.heapStatsUpdate";
357}
358
359/// If heap objects tracking has been started then backend regularly sends a
360/// current value for last seen object id and corresponding timestamp. If the
361/// were changes in the heap since last event then one or more heapStatsUpdate
362/// events will be sent before a new lastSeenObjectId event.
363///
364/// Payload of the `HeapProfiler.lastSeenObjectId` event.
365#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
366pub struct LastSeenObjectIdEvent {
367    #[serde(rename = "lastSeenObjectId")]
368    pub last_seen_object_id: i64,
369    pub timestamp: f64,
370}
371
372impl crate::typed::Event for LastSeenObjectIdEvent {
373    const METHOD: &'static str = "HeapProfiler.lastSeenObjectId";
374}
375
376/// Payload of the `HeapProfiler.reportHeapSnapshotProgress` event.
377#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
378pub struct ReportHeapSnapshotProgressEvent {
379    pub done: i64,
380    pub total: i64,
381    #[serde(default, skip_serializing_if = "Option::is_none")]
382    pub finished: Option<bool>,
383}
384
385impl crate::typed::Event for ReportHeapSnapshotProgressEvent {
386    const METHOD: &'static str = "HeapProfiler.reportHeapSnapshotProgress";
387}
388
389/// Payload of the `HeapProfiler.resetProfiles` event.
390#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
391pub struct ResetProfilesEvent {}
392
393impl crate::typed::Event for ResetProfilesEvent {
394    const METHOD: &'static str = "HeapProfiler.resetProfiles";
395}