Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/data/hotline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,9 @@ impl ProcessData for Hotline {
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
table {{ border-collapse: collapse; width: 100%; table-layout: fixed; font-family: monospace; font-size: 12px; }}
table {{ background-color: #f5f5f5; border-collapse: collapse; width: 100%; table-layout: fixed; font-family: monospace; font-size: 12px; }}
th, td {{ border: 1px solid #ccc; padding: 2px 4px; text-align: left; word-break: break-word; }}
th {{ background-color: #f2f2f2; position: sticky; top: 0; }}
tr:hover {{ background-color: #f5f5f5; }}
</style>
</head>
<body>
Expand Down
44 changes: 37 additions & 7 deletions src/profiling/jfr/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ pub fn jfr_to_profiler(path: &Path) -> Result<Profiler> {
.unwrap_or_default();

let mut profiler = Profiler::new(start_time_ms);
// Computed lazily after settings are populated from ActiveSetting events
let mut wall_interval_ms: Option<i64> = None;

// Cache: (method_id, frame_type) -> formatted frame string
let mut frame_cache: HashMap<(i64, u8), String> = HashMap::new();
Expand Down Expand Up @@ -382,13 +384,41 @@ pub fn jfr_to_profiler(path: &Path) -> Result<Profiler> {
}

if !frames.is_empty() {
profiler.insert_stack(
profile_type,
sample_time_ms,
thread_state,
&frames,
samples,
);
// Wall clock events with samples > 1 represent consecutive sampling
// intervals. Spread them across time blocks to match async-profiler
// heatmap behavior.
// Source https://github.com/async-profiler/async-profiler/blob/20e0b5cfc344bf5e32e5554750c2b08462c353b8/src/converter/one/convert/JfrToHeatmap.java#L34
if profile_type == "wall" && samples > 1 {
let interval = *wall_interval_ms.get_or_insert_with(|| {
reader
.settings
.get("wall")
.or_else(|| reader.settings.get("interval"))
.and_then(|s| s.parse::<i64>().ok())
.filter(|&v| v > 0)
.unwrap_or(50_000_000)
/ 1_000_000
});
let mut time_ms = sample_time_ms;
for _ in 0..samples {
profiler.insert_stack(
profile_type,
time_ms,
thread_state,
&frames,
1,
);
time_ms += interval;
}
} else {
profiler.insert_stack(
profile_type,
sample_time_ms,
thread_state,
&frames,
samples,
);
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/profiling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod jfr;
pub mod perf;
pub mod symbols;

pub const BUCKET_WIDTH_MS: u64 = 100;
pub const BUCKET_WIDTH_MS: u64 = 20;

use crate::data::common::data_formats::Profiler;
use anyhow::Result;
Expand Down Expand Up @@ -360,7 +360,9 @@ impl Profile {
) {
// Calculate block index and extend blocks vec if necessary
let thread_state_id = thread_state.id();
let offset_ms = (sample_time_ms - start_time_ms).max(0) as u64;
// Align blocks by width
let start_block_ms = start_time_ms - (start_time_ms % (bucket_width_ms as i64));
let offset_ms = (sample_time_ms - start_block_ms).max(0) as u64;
let block_idx = (offset_ms / bucket_width_ms) as usize;

while self.blocks.len() <= block_idx {
Expand Down
4 changes: 3 additions & 1 deletion src/report_frontend/src/components/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default function () {
{!preprocessing && dataFormat == "key_value" && (
<KeyValueDataPage dataType={dataComponent} key={dataComponent} />
)}
{!preprocessing && dataFormat == "profile" && <ProfilingDataPage dataType={dataComponent} key={dataComponent} />}
{!preprocessing && dataFormat == "profile" && (
<ProfilingDataPage dataType={dataComponent} key={dataComponent} />
)}
{!preprocessing && dataFormat == "text" && <TextDataPage dataType={dataComponent} key={dataComponent} />}
{!preprocessing && (dataFormat == "unknown" || (dataFormat as string) === "" || dataFormat === undefined) && (
<Box textAlign="center" color="inherit">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from "react";
import { AnalyticalFinding, DataType, FindingType, TimeSeriesMetricProps } from "../../definitions/types";
import {
AnalyticalFinding,
DataType,
FindingType,
TimeSeriesMetricProps,
ProfilingDataMetricProps,
} from "../../definitions/types";
import {
Icon,
SpaceBetween,
Expand Down Expand Up @@ -154,6 +160,30 @@ export function MetricAnalyticalFindings(props: TimeSeriesMetricProps) {
);
}

/**
* This component renders all analytical findings of a specific profiler instance.
*/
export function ProfileAnalyticalFindings(props: ProfilingDataMetricProps) {
const dataFindings = PER_DATA_ANALYTICAL_FINDINGS[props.dataType];
if (dataFindings == undefined) return null;
const curRunFindings = dataFindings.per_run_findings[props.runName];
if (curRunFindings == undefined) return null;

const profileFindings = curRunFindings.findings[props.profileInstance];
if (profileFindings == undefined) return null;

const sortedProfileFindings = [...profileFindings];
sortedProfileFindings.sort((a, b) => a.score - b.score);

return (
<SpaceBetween size={"xxxs"}>
{sortedProfileFindings.map((finding) => (
<Finding finding={finding} dataType={props.dataType} dataKey={props.profileInstance} />
))}
</SpaceBetween>
);
}

/**
* Defines how filtering texts (in the search bar) can be used to filter analytical findings
*/
Expand Down
Loading
Loading