Skip to content

Commit 3022ff5

Browse files
Store self-profile data in an Arc
We do not interpolate it, so when duplicates of non-interpolated data are made, it should not be duplicated. This shaves around 2 GB off of our maximum heap usage.
1 parent 6c3af99 commit 3022ff5

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

collector/src/self_profile.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use serde::{Deserialize, Serialize};
22
use std::convert::TryFrom;
3+
use std::sync::Arc;
34
use std::time::Duration;
45

56
#[derive(Serialize, Deserialize, Debug, Clone)]
67
#[serde(into = "InternalSelfProfile")]
78
#[serde(from = "InternalSelfProfile")]
89
pub struct SelfProfile {
9-
pub query_data: Vec<QueryData>,
10+
pub query_data: Arc<Vec<QueryData>>,
1011
}
1112

1213
impl Into<InternalSelfProfile> for SelfProfile {
@@ -42,7 +43,12 @@ impl Into<InternalSelfProfile> for SelfProfile {
4243
impl From<InternalSelfProfile> for SelfProfile {
4344
fn from(profile: InternalSelfProfile) -> SelfProfile {
4445
match profile {
45-
InternalSelfProfile::Rustc { query_data } => SelfProfile { query_data },
46+
InternalSelfProfile::Rustc { mut query_data } => {
47+
query_data.shrink_to_fit();
48+
SelfProfile {
49+
query_data: Arc::new(query_data),
50+
}
51+
}
4652
InternalSelfProfile::Perf {
4753
label,
4854
self_time,
@@ -73,7 +79,10 @@ impl From<InternalSelfProfile> for SelfProfile {
7379
incremental_load_time: incremental_load_time.next().unwrap(),
7480
});
7581
}
76-
SelfProfile { query_data }
82+
query_data.shrink_to_fit();
83+
SelfProfile {
84+
query_data: Arc::new(query_data),
85+
}
7786
}
7887
}
7988
}

site/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ fn get_self_profile_data(
688688
let mut profile = self_profile::SelfProfile {
689689
query_data: profile
690690
.query_data
691-
.into_iter()
691+
.iter()
692692
.map(|qd| self_profile::QueryData {
693693
label: qd.label,
694694
self_time: qd.self_time,

0 commit comments

Comments
 (0)