Skip to content

Commit 859460c

Browse files
authored
Merge pull request #447 from pythonspeed/sciagraph-multiprocessing
Sciagraph multiprocessing
2 parents 137591d + 35feae5 commit 859460c

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

memapi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ backtrace = "0.3"
1717
once_cell = "1.15"
1818
libloading = "0.7"
1919
libc = "0.2"
20+
serde = {version = "1", features = ["derive"] }
2021

2122
[dependencies.inferno]
2223
version = "0.11"

memapi/src/memorytracking.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use super::util::new_hashmap;
88
use ahash::RandomState as ARandomState;
99
use im::Vector as ImVector;
1010
use itertools::Itertools;
11+
use serde::Deserialize;
12+
use serde::Serialize;
1113
use std::borrow::Cow;
1214
use std::collections::BTreeMap;
1315
use std::collections::HashMap;
@@ -17,7 +19,7 @@ extern "C" {
1719
fn _exit(exit_code: std::os::raw::c_int);
1820
}
1921

20-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
22+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
2123
pub struct FunctionId(u64);
2224

2325
impl FunctionId {
@@ -83,7 +85,7 @@ impl FunctionLocations for VecFunctionLocations {
8385
pub type LineNumber = u16; // TODO u32, newtype
8486

8587
/// A specific location: file + function + line number.
86-
#[derive(Clone, Debug, PartialEq, Eq, Copy, Hash)]
88+
#[derive(Clone, Debug, PartialEq, Eq, Copy, Hash, Serialize, Deserialize)]
8789
pub struct CallSiteId {
8890
/// The function + filename. We use IDs for performance reasons (faster hashing).
8991
function: FunctionId,
@@ -101,7 +103,7 @@ impl CallSiteId {
101103
}
102104

103105
/// The current Python callstack.
104-
#[derive(Derivative)]
106+
#[derive(Derivative, Serialize, Deserialize)]
105107
#[derivative(Clone, PartialEq, Eq, Hash, Debug)]
106108
pub struct Callstack {
107109
calls: Vec<CallSiteId>,
@@ -290,11 +292,10 @@ impl CallstackInterner {
290292
const MIB: usize = 1024 * 1024;
291293
const HIGH_32BIT: u32 = 1 << 31;
292294

293-
/// A unique identifier for a process. The idea is that each subprocess will be
294-
/// given a unique identifier from a counter, and that >4 billion processes is
295-
/// unlikely. But the internal representation can change!
296-
#[derive(Clone, Copy, Debug, PartialEq, Ord, PartialOrd, Eq)]
297-
pub struct ProcessUid(u32);
295+
/// A unique identifier for a process.
296+
#[derive(Clone, Copy, Debug, PartialEq, Ord, PartialOrd, Eq, Serialize, Deserialize)]
297+
#[serde(transparent)]
298+
pub struct ProcessUid(pub u32);
298299

299300
pub const PARENT_PROCESS: ProcessUid = ProcessUid(0);
300301

0 commit comments

Comments
 (0)