-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scale frequency to suppress RCU CPU stall warning #67
Draft
Mes0903
wants to merge
9
commits into
sysprog21:master
Choose a base branch
from
Mes0903:scale-frequency
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1f9c6a8
Scale frequency to suppress RCU CPU stall warning
Mes0903 fb3bf51
WIP: profiling for ns_per_call
Mes0903 2172626
WIP: remove gprof
Mes0903 471877d
WIP: parse data
Mes0903 c9095c3
WIP: update new profiling data
Mes0903 640aa66
WIP: Statistic data within all environment again
Mes0903 f548bda
WIP: optimize profile method
Mes0903 544156c
WIP: correct percentage calculation
Mes0903 147bf47
WIP: Test increase base method
Mes0903 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Create a directory to store logs (optional) | ||
mkdir -p logs | ||
|
||
for N in $(seq 1 32); do | ||
echo "=============================================" | ||
echo "Starting experiment with SMP=$N" | ||
echo "=============================================" | ||
|
||
echo "Building and running 'make check SMP=$N'..." | ||
make check SMP=$N 2>&1 | tee "logs/emulator_SMP_${N}.log" | ||
|
||
echo "Done with SMP=$N. Logs saved:" | ||
echo " - logs/emulator_SMP_${N}.log" | ||
echo | ||
done | ||
|
||
echo "All experiments complete!" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# parse_results_macos.sh | ||
# | ||
# Parses log files of the form: emulator_SMP_{N}.log | ||
# Each log ends with lines like: | ||
# [SEMU LOG]: Real boot time: 43.63820 seconds, called 220128512 times semu_timer_clocksource | ||
# [SEMU LOG]: ns_per_call = 4.46425, predict_sec = 8.92851, scale_factor = 1.12001 | ||
# | ||
# We output a table with columns: | ||
# 1) SMP | ||
# 2) real_boot_time | ||
# 3) times_called | ||
# 4) ns_per_call | ||
# 5) predict_sec | ||
# 6) scale_factor | ||
# | ||
# We do not parse total_clocksource_ns or percentage, as they do not appear in this log snippet. | ||
|
||
LOGDIR="mac_log" # Directory containing emulator_SMP_{N}.log | ||
OUTFILE="results_summary.txt" | ||
|
||
# Print a header: | ||
echo -e "SMP\treal_boot_time\ttimes\t\tns_per_call\tpredict_sec\tscale_factor" > "$OUTFILE" | ||
|
||
# Iterate from SMP=1..32 (adjust if needed) | ||
for N in $(seq 1 32); do | ||
FILE="$LOGDIR/emulator_SMP_${N}.log" | ||
|
||
if [[ ! -f "$FILE" ]]; then | ||
echo "Skipping N=$N, file not found: $FILE" | ||
continue | ||
fi | ||
|
||
# Initialize variables | ||
real_boot_time="" | ||
times_called="" | ||
ns_per_call="" | ||
predict_sec="" | ||
scale_factor="" | ||
|
||
# 1) Parse the "Real boot time" line: | ||
# Example: | ||
# [SEMU LOG]: Real boot time: 43.63820 seconds, called 220128512 times semu_timer_clocksource | ||
line_boot="$(grep 'Real boot time:' "$FILE")" | ||
if [[ -n "$line_boot" ]]; then | ||
# Remove ANSI color codes, if any | ||
line_no_ansi="$(echo "$line_boot" | sed 's/\x1b\[[0-9;]*m//g')" | ||
# e.g. "[SEMU LOG]: Real boot time: 43.63820 seconds, called 220128512 times semu_timer_clocksource" | ||
# We'll extract: | ||
# real_boot_time = 43.63820 | ||
# times = 220128512 | ||
real_boot_time="$(echo "$line_no_ansi" | sed -E 's/.*Real boot time: ([0-9.]+) seconds, called ([0-9]+) .*/\1/')" | ||
times_called="$(echo "$line_no_ansi" | sed -E 's/.*Real boot time: ([0-9.]+) seconds, called ([0-9]+) .*/\2/')" | ||
fi | ||
|
||
# 2) Parse the "ns_per_call" line: | ||
# Example: | ||
# [SEMU LOG]: ns_per_call = 4.46425, predict_sec = 8.92851, scale_factor = 1.12001 | ||
line_ns="$(grep 'ns_per_call =' "$FILE")" | ||
if [[ -n "$line_ns" ]]; then | ||
# Also remove ANSI codes | ||
ns_no_ansi="$(echo "$line_ns" | sed 's/\x1b\[[0-9;]*m//g')" | ||
# e.g. "ns_per_call = 4.46425, predict_sec = 8.92851, scale_factor = 1.12001" | ||
# We'll extract them | ||
ns_per_call="$(echo "$ns_no_ansi" | sed -E 's/.*ns_per_call = ([0-9.]+).*/\1/')" | ||
predict_sec="$(echo "$ns_no_ansi" | sed -E 's/.*predict_sec = ([0-9.]+).*/\1/')" | ||
scale_factor="$(echo "$ns_no_ansi" | sed -E 's/.*scale_factor = ([0-9.]+).*/\1/')" | ||
fi | ||
|
||
# 3) Print a line with the data | ||
echo -e "${N}\t${real_boot_time}\t${times_called}\t${ns_per_call}\t${predict_sec}\t${scale_factor}" >> "$OUTFILE" | ||
done | ||
|
||
echo "Done. Results saved to ${OUTFILE}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
1: 13th Gen Intel(R) Core(TM) i7-13700 | ||
2: Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz | ||
3: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz | ||
4: 13th Gen Intel(R) Core(TM) i9-13900H | ||
5: arm (ThunderX2-99xx) | ||
6: mag | ||
7: M2 Pro Max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# parse_results_new.sh | ||
# | ||
# Parses new logs named "emulator_SMP_{N}.log" (N=1..32). Each log's final lines look like: | ||
# | ||
# [SEMU LOG]: Real boot time: 233.04606 seconds, called 3628365913 times semu_timer_clocksource | ||
# [SEMU LOG]: ns_per_call = 6.26153, predict_sec = 225.41525, scale_factor = 0.04436 | ||
# [SEMU LOG]: test_total_clocksource_ns = 92301869299, real_total_clocksource_ns = 46863590994, percentage = 0.20109 | ||
# [SEMU LOG]: real_ns_per_call = 12.91589, diff_ns_per_call = 6.65436 | ||
# | ||
# We output results_summary.txt with 11 columns in tab-delimited format: | ||
# 1) SMP | ||
# 2) real_boot_time | ||
# 3) times_called | ||
# 4) ns_per_call | ||
# 5) predict_sec | ||
# 6) scale_factor | ||
# 7) test_total_clocksource_ns | ||
# 8) real_total_clocksource_ns | ||
# 9) percentage | ||
# 10) real_ns_per_call | ||
# 11) diff_ns_per_call | ||
# | ||
# We specifically remove any ANSI color codes and ensure each line is a single line, so the output doesn't break. | ||
|
||
LOGDIR="logs-4" # Directory containing the log files | ||
OUTFILE="results_summary-4.txt" | ||
|
||
# Print header (11 columns) | ||
echo -e "SMP\treal_boot_time\ttimes_called\tns_per_call\tpredict_sec\tscale_factor\ttest_total_clocksource_ns\treal_total_clocksource_ns\tpercentage\treal_ns_per_call\tdiff_ns_per_call" > "$OUTFILE" | ||
|
||
for N in $(seq 1 32); do | ||
FILE="$LOGDIR/emulator_SMP_${N}.log" | ||
|
||
if [[ ! -f "$FILE" ]]; then | ||
echo "Skipping N=$N; file not found: $FILE" | ||
continue | ||
fi | ||
|
||
# Initialize variables | ||
real_boot_time="" | ||
times_called="" | ||
ns_per_call="" | ||
predict_sec="" | ||
scale_factor="" | ||
test_total_clocksource_ns="" | ||
real_total_clocksource_ns="" | ||
percentage="" | ||
real_ns_per_call="" | ||
diff_ns_per_call="" | ||
|
||
# A helper function to grep for a specific pattern once, strip ANSI codes, unify line | ||
grep_single_line() { | ||
# Usage: grep_single_line "<pattern>" | ||
# We'll grep for this pattern, take only the first match, remove color codes, unify line | ||
grep -m1 "$1" "$FILE" \ | ||
| sed 's/\x1b\[[0-9;]*m//g' \ | ||
| tr '\n' ' ' | ||
} | ||
|
||
# 1) Real boot time line | ||
# e.g. "[SEMU LOG]: Real boot time: 233.04606 seconds, called 3628365913 times semu_timer_clocksource" | ||
line_boot="$(grep_single_line 'Real boot time:')" | ||
if [[ -n "$line_boot" ]]; then | ||
# extract real_boot_time, times_called | ||
real_boot_time="$(echo "$line_boot" | sed -E 's/.*Real boot time: ([0-9.]+) seconds, called ([0-9]+) .*/\1/')" | ||
times_called="$(echo "$line_boot" | sed -E 's/.*Real boot time: ([0-9.]+) seconds, called ([0-9]+) .*/\2/')" | ||
fi | ||
|
||
# 2) ns_per_call line | ||
# e.g.: "[SEMU LOG]: ns_per_call = 6.26153, predict_sec = 225.41525, scale_factor = 0.04436" | ||
line_nscall="$(grep_single_line 'ns_per_call =')" | ||
if [[ -n "$line_nscall" ]]; then | ||
ns_per_call="$(echo "$line_nscall" | sed -E 's/.*ns_per_call = ([0-9.]+).*/\1/')" | ||
predict_sec="$(echo "$line_nscall" | sed -E 's/.*predict_sec = ([0-9.]+).*/\1/')" | ||
scale_factor="$(echo "$line_nscall" | sed -E 's/.*scale_factor = ([0-9.]+).*/\1/')" | ||
fi | ||
|
||
# 3) total_clocksource_ns line | ||
# e.g. "[SEMU LOG]: test_total_clocksource_ns = 92301869299, real_total_clocksource_ns = 46863590994, percentage = 0.20109" | ||
line_totals="$(grep_single_line 'test_total_clocksource_ns =')" | ||
if [[ -n "$line_totals" ]]; then | ||
test_total_clocksource_ns="$(echo "$line_totals" | sed -E 's/.*test_total_clocksource_ns = ([0-9]+).*/\1/')" | ||
real_total_clocksource_ns="$(echo "$line_totals" | sed -E 's/.*real_total_clocksource_ns = ([0-9]+).*/\1/')" | ||
percentage="$(echo "$line_totals" | sed -E 's/.*percentage = ([0-9.]+).*/\1/')" | ||
fi | ||
|
||
# 4) real_ns_per_call line | ||
# e.g. "[SEMU LOG]: real_ns_per_call = 12.91589, diff_ns_per_call = 6.65436" | ||
line_realns="$(grep_single_line 'real_ns_per_call =')" | ||
if [[ -n "$line_realns" ]]; then | ||
real_ns_per_call="$(echo "$line_realns" | sed -E 's/.*real_ns_per_call = ([0-9.]+).*/\1/')" | ||
diff_ns_per_call="$(echo "$line_realns" | sed -E 's/.*diff_ns_per_call = ([0-9.]+).*/\1/')" | ||
fi | ||
|
||
# Print a single line with 11 columns in tab-delimited format | ||
echo -e "${N}\t${real_boot_time}\t${times_called}\t${ns_per_call}\t${predict_sec}\t${scale_factor}\t${test_total_clocksource_ns}\t${real_total_clocksource_ns}\t${percentage}\t${real_ns_per_call}\t${diff_ns_per_call}" >> "$OUTFILE" | ||
done | ||
|
||
echo "Data parsed and saved to $OUTFILE." |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# plot_results.sh | ||
# | ||
# Generates 7 separate .png plots using gnuplot. Each plot corresponds | ||
# to a particular data column (2..8) from the results_summary_{1..5}.txt files. | ||
# The x-axis is SMP (column 1), and the y-axis is the chosen data column. | ||
# | ||
# The files are assumed to be: | ||
# results_summary_1.txt | ||
# results_summary_2.txt | ||
# results_summary_3.txt | ||
# results_summary_4.txt | ||
# results_summary_5.txt | ||
# | ||
# Each file has at least these columns: | ||
# 1) SMP | ||
# 2) real_boot_time | ||
# 3) times | ||
# 4) ns_per_call | ||
# 5) predict_sec | ||
# 6) scale_factor | ||
# 7) percentage | ||
# 8) real_ns_per_call | ||
# | ||
# Usage: | ||
# ./plot_results.sh | ||
# It will produce 7 PNG images, e.g. real_boot_time.png, times.png, etc. | ||
|
||
# A small map from column index to a more descriptive name (for file titles). | ||
declare -A COLTITLE=( | ||
[2]="real_boot_time" | ||
[3]="times" | ||
[4]="ns_per_call" | ||
[5]="predict_sec" | ||
[6]="scale_factor" | ||
[7]="percentage" | ||
[8]="real_ns_per_call" | ||
) | ||
|
||
# Check if gnuplot is installed | ||
command -v gnuplot >/dev/null 2>&1 || { | ||
echo "Error: gnuplot is not installed or not in PATH." | ||
exit 1 | ||
} | ||
|
||
# Loop over the data columns we want to plot | ||
for col in 2 3 4 5 6 7 8; do | ||
title="${COLTITLE[$col]}" | ||
|
||
echo "Generating plot for column $col -> $title" | ||
|
||
gnuplot -persist <<EOF | ||
set title "$title vs SMP" | ||
set xlabel "SMP" | ||
set ylabel "$title" | ||
set key left top | ||
set grid | ||
|
||
# Output a PNG figure sized 800x600 | ||
set term pngcairo size 800,600 | ||
set output "${title}.png" | ||
|
||
# Skip the header row with 'skip=1' | ||
# We assume each file has a header line, so 'using 1:$col' means: | ||
# x = column 1 (SMP) | ||
# y = column $col (the data we want) | ||
# | ||
# Each line is for a different environment's file. | ||
plot \ | ||
"results_summary_1.txt" using 1:$col skip 1 with linespoints title "Env1", \ | ||
"results_summary_2.txt" using 1:$col skip 1 with linespoints title "Env2", \ | ||
"results_summary_3.txt" using 1:$col skip 1 with linespoints title "Env3", \ | ||
"results_summary_4.txt" using 1:$col skip 1 with linespoints title "Env4", \ | ||
"results_summary_5.txt" using 1:$col skip 1 with linespoints title "Env5" | ||
|
||
EOF | ||
|
||
done | ||
|
||
echo "All plots generated! Look for *.png in the current directory." |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the
make check
command. If the command fails, it might be helpful to capture the exit status and handle failures appropriately. Could consider addingset -e
at the beginning of the script to fail fast on any error.Code suggestion
Code Review Run #6023d9
Is this a valid issue, or was it incorrectly flagged by the Agent?