Compare commits

..
2 Commits
4 changed files with 52 additions and 31 deletions
@@ -4,7 +4,17 @@ library(readr)
library(stringr)
library(tidyr)
# Usage: Rscript marker_composition.r exp_abspath1 ... resultsdata_file
# Usage: Rscript combined_fault_probability.r exp_abspath1 ... resultsdata_file
#
# Divides by the faultspace area instead of by a marker total, which makes the
# running modes comparable: raw counts scale with how long WAMR runs, so they
# say more about execution length than about susceptibility.
#
# Each segment is P[outcome] for a uniformly random single-bit flip in the
# traced fault space, so a bar's height is P[anything goes wrong].
#
# Replaces combined_fault_composition.r, which divided by the marker total and
# was therefore this chart with every bar rescaled to 100%.
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 2) {
@@ -32,12 +42,15 @@ extract_info <- function(path) {
warning(paste("Could not parse:", dir_name))
return(NULL)
}
list(base_name = match[1, 2], variant = match[1, 3], path = path)
# "tacle-kernel-bsort" -> "bsort", otherwise it doesn't fit
base_name <- sub("^tacle-[^-]+-", "", match[1, 2])
list(base_name = base_name, variant = match[1, 3], path = path)
}
# Load data
all_data <- data.frame()
weight_data <- data.frame()
for (arg in exp_args) {
info <- extract_info(arg)
@@ -56,37 +69,48 @@ for (arg in exp_args) {
all_data <- bind_rows(all_data, df)
}
# TODO: Finally put all the bullshit before this in some shared space
if (nrow(all_data) == 0) {
stop("No data loaded")
}
# Skip OK_MARKERs, sum GROUP1 + TRAP.
all_data <- all_data |>
filter(resulttype != "OK_MARKER") |>
mutate(
resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype)
) |>
group_by(base_name, variant, benchmark, resulttype) |>
summarise(faults = sum(faults), .groups = "drop")
marker_order <- c(
"OK_MARKER",
"DETECTED_MARKER",
"GROUP1_MARKER",
"TRAP",
"TIMEOUT",
"WRITE_TEXTSEGMENT",
"ACCESS_OUTERSPACE",
"FAIL_MARKER"
)
out_suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
# Calculate percentages
composition <- all_data |>
# Don't merge GROUP1_MARKER into TRAP for this chart
# Also keep the OK_MARKERs, so the "sum to 100%" is accurate
probability <- all_data |>
group_by(base_name, variant, benchmark) |>
mutate(frac = faults / sum(faults)) |>
mutate(frac = faults / sum(faults, na.rm = TRUE)) |>
ungroup()
# Don't print alphabetically
probability$resulttype <- factor(probability$resulttype, levels = marker_order)
probability$variant <- factor(
probability$variant,
levels = c("c", "aot", "interp")
)
plot <- ggplot(
composition |> filter(variant %in% c("aot", "interp")),
probability,
aes(x = variant, y = frac, fill = resulttype)
) +
geom_col() +
facet_grid(benchmark ~ base_name) +
scale_y_continuous(labels = scales::percent) +
labs(
title = "Marker Composition (AOT vs Interp)",
title = "Fault Probability per Fault Space",
x = NULL,
y = "Percentage of Faults",
y = "Probability of Failure",
fill = "Fault Type"
) +
theme_minimal() +
@@ -95,9 +119,6 @@ plot <- ggplot(
axis.text.x = element_text(angle = 45, hjust = 1)
)
filename <- paste0(
"injections/fault_composition",
out_suffix,
".svg"
)
out_suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
filename <- paste0("injections/fault_probability", out_suffix, ".svg")
ggsave(filename, plot = plot, width = 13, height = 8)
+4 -4
View File
@@ -653,15 +653,15 @@ my %handlers = (
# Sucks to put those here but I can't write them inside the R scripts
my %chart_descriptions = (
combined_fault_composition =>
'stacked fault type percentages/composition (resultsdata.csv).',
combined_fault_count_comparison =>
'faults per benchmark, c/aot/interp side by side (resultsdata.csv).',
combined_fault_count_correlation =>
'correlation of raw aot vs. interp fault counts (resultsdata.csv).',
combined_fault_probability =>
'marker probability per fault space (resultsdata.csv [+ traceweight.csv]).',
combined_fault_rates_per_instruction =>
'faults normalised by instruction count (faults.csv + mnemonics.csv).',
@@ -698,7 +698,7 @@ my %handlers = (
} @selected_charts;
my @resultsdata_charts =
grep {
/_result|_fault_count_comparison|_ratio_comparison|_fault_count_correlation|_fault_composition/
/_result|_fault_count_comparison|_ratio_comparison|_fault_count_correlation|_fault_probability/
} @selected_charts;
# Select if faults.csv or a filtered variant should be used