Skip to content

Commit 640aa66

Browse files
committed
WIP: Statistic data within all environment again
1 parent c9095c3 commit 640aa66

File tree

714 files changed

+790860
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

714 files changed

+790860
-184
lines changed

statistic/README

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
1: 13th Gen Intel(R) Core(TM) i7-13700
22
2: Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz
33
3: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
4-
4: arm (ThunderX2-99xx)
5-
5: mag
6-
6: M2 Pro Max
4+
4: 13th Gen Intel(R) Core(TM) i9-13900H
5+
5: arm (ThunderX2-99xx)
6+
6: mag
7+
7: M2 Pro Max

analyze.sh renamed to statistic/analyze_results.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#
2525
# We specifically remove any ANSI color codes and ensure each line is a single line, so the output doesn't break.
2626

27-
LOGDIR="logs" # Directory containing the log files
28-
OUTFILE="results_summary.txt"
27+
LOGDIR="logs-4" # Directory containing the log files
28+
OUTFILE="results_summary-4.txt"
2929

3030
# Print header (11 columns)
3131
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"

statistic/diff_boot_time.png

22.4 KB
Loading

statistic/diff_ns_per_call.png

-83.8 KB
Binary file not shown.
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
import matplotlib.pyplot as plt
3939

4040
ENV_FILES = [
41-
"results_summary_1.txt",
42-
"results_summary_2.txt",
43-
"results_summary_3.txt",
44-
"results_summary_4.txt",
45-
"results_summary_5.txt",
46-
"results_summary_6.txt"
41+
"results_summary-1.txt",
42+
"results_summary-2.txt",
43+
"results_summary-3.txt",
44+
"results_summary-4.txt",
45+
"results_summary-5.txt",
46+
"results_summary-6.txt",
47+
"results_summary-6.txt"
4748
]
4849

4950
ENV_NAMES = [
@@ -53,20 +54,21 @@
5354
"4: Env4",
5455
"5: Env5",
5556
"6: Env6",
57+
"7: Env7",
5658
]
5759

5860
# A dictionary for column labels (2..11):
5961
COL_LABELS = {
6062
2: "real_boot_time",
6163
3: "times_called",
62-
4: "predict_ns_per_call",
63-
5: "predict_boot_time",
64+
4: "predict ns_per_call",
65+
5: "predict boot time",
6466
6: "scale_factor",
65-
7: "test_total_clocksource_ns",
66-
8: "real_total_clocksource_ns",
67-
9: "percentage",
68-
10: "real_ns_per_call",
69-
11: "diff_ns_per_call",
67+
7: "test total clocksource ns",
68+
8: "real total clocksource ns",
69+
9: "percentage of clocksource",
70+
10: "real ns_per_call",
71+
11: "real - predict ns_per_call",
7072
}
7173

7274
def main():
@@ -75,7 +77,7 @@ def main():
7577
label = COL_LABELS[col]
7678

7779
plt.figure(figsize=(8, 6))
78-
plt.title(f"{label} vs. SMP")
80+
plt.title(f"{label}")
7981
plt.xlabel("SMP")
8082
plt.ylabel(label)
8183

statistic/draw_time.py

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import os
2+
import matplotlib.pyplot as plt
3+
4+
def parse_results_summary(summary_path):
5+
"""
6+
Reads a results_summary_N.txt file and returns a dict:
7+
{smp_value: (percentage, predicted_ns_per_call, real_ns_per_call)}
8+
"""
9+
smp_info = {}
10+
with open(summary_path, "r") as f:
11+
for line in f:
12+
line = line.strip()
13+
if not line or line.startswith("#"):
14+
continue
15+
16+
parts = line.split()
17+
# Skip the header line if it's present
18+
if parts[0] == "SMP":
19+
continue
20+
21+
# Columns in summary file (1-based):
22+
# 1: SMP
23+
# 2: real_boot_time
24+
# 3: times_called
25+
# 4: ns_per_call (predicted ns)
26+
# 5: predict_sec
27+
# 6: scale_factor
28+
# 7: test_total_clocksource_ns
29+
# 8: real_total_clocksource_ns
30+
# 9: percentage
31+
# 10: real_ns_per_call
32+
# 11: diff_ns_per_call
33+
#
34+
# Zero-based index references:
35+
# parts[0] -> SMP
36+
# parts[3] -> ns_per_call (predicted)
37+
# parts[8] -> percentage
38+
# parts[9] -> real_ns_per_call
39+
if len(parts) >= 10:
40+
try:
41+
smp_val = int(parts[0])
42+
predicted_ns_per_call = float(parts[3])
43+
percentage = float(parts[8])
44+
smp_info[smp_val] = (percentage, predicted_ns_per_call)
45+
except ValueError:
46+
continue
47+
48+
return smp_info
49+
50+
def parse_and_scale_time_log(time_log_path, scale_factor):
51+
scaled_values = []
52+
with open(time_log_path, "r") as f:
53+
for line in f:
54+
line = line.strip()
55+
if line.startswith("diff:"):
56+
# e.g. "diff: 50176382"
57+
parts = line.split(":")
58+
if len(parts) == 2:
59+
try:
60+
val_ns = float(parts[1].strip()) # raw ns
61+
val_ms = val_ns / 1_000_000
62+
scaled_val = val_ms * scale_factor # scale by 'percentage'
63+
scaled_values.append(scaled_val)
64+
except ValueError:
65+
pass
66+
return scaled_values
67+
68+
def main():
69+
base_statistic_dir = "." # Your base folder for logs & summaries
70+
num_summaries = 7 # We have results_summary_1.txt ... results_summary_6.txt
71+
num_smp = 32 # Each summary covers SMP=1..32
72+
73+
for i in range(1, num_summaries + 1):
74+
summary_file = os.path.join(base_statistic_dir, f"results_summary-{i}.txt")
75+
time_log_dir = os.path.join(base_statistic_dir, f"time_log-{i}") # e.g. statistic/time_log-1
76+
output_dir = os.path.join(base_statistic_dir, f"plots-{i}")
77+
78+
# Create output directory for plots
79+
os.makedirs(output_dir, exist_ok=True)
80+
81+
# 1) Parse the summary file => { SMP: (percentage, predicted_ns, real_ns) }
82+
smp_data = parse_results_summary(summary_file)
83+
print(f"[INFO] Parsed {len(smp_data)} SMP entries from {summary_file}")
84+
85+
# We'll store an average (of scaled diff) per SMP for a "trend" plot
86+
averages = []
87+
88+
for smp_val in range(1, num_smp + 1):
89+
# Retrieve info for this SMP
90+
if smp_val not in smp_data:
91+
print(f"[WARNING] SMP={smp_val} not found in {summary_file}. Skipping.")
92+
averages.append(0.0)
93+
continue
94+
95+
percentage, pred_ns_per_call = smp_data[smp_val]
96+
97+
# 2) Parse & scale the time_log_{SMP}.txt
98+
time_log_path = os.path.join(time_log_dir, f"time_log_{smp_val}.txt")
99+
if not os.path.exists(time_log_path):
100+
print(f"[WARNING] File not found: {time_log_path}")
101+
averages.append(0.0)
102+
continue
103+
104+
scaled_values = parse_and_scale_time_log(time_log_path, percentage)
105+
if not scaled_values:
106+
print(f"[WARNING] No valid data in {time_log_path}")
107+
averages.append(0.0)
108+
continue
109+
110+
# 3) Plot scaled diff values (blue line)
111+
plt.figure(figsize=(8, 4))
112+
plt.plot(scaled_values, color='blue', marker=None, linewidth=1, linestyle='-',
113+
label='real ns_per_call (average per 1e6 times)')
114+
115+
# 4) Add horizontal lines for predicted (red) + real (green) ns_per_call
116+
plt.axhline(y=pred_ns_per_call, color='red', linestyle='--',
117+
label='Predicted ns_per_call')
118+
119+
plt.title(f"SMP={smp_val} --- real vs. predict ns_per_call\n"
120+
f"(percentage={percentage}, pred={pred_ns_per_call:.3f}ns)")
121+
plt.xlabel("per 1e6 times called")
122+
plt.ylabel("Nanoseconds (ns)")
123+
plt.legend()
124+
125+
# Save the figure for this SMP
126+
plot_path = os.path.join(output_dir, f"time_log_{smp_val}_scaled.png")
127+
plt.savefig(plot_path, dpi=150)
128+
plt.close()
129+
130+
# Compute average of scaled diff
131+
avg_val = sum(scaled_values) / len(scaled_values)
132+
averages.append(avg_val)
133+
134+
# 5) Plot the average trend (per SMP)
135+
smp_indices = list(range(1, num_smp + 1))
136+
plt.figure(figsize=(8, 4))
137+
plt.plot(smp_indices, averages, marker=None, linewidth=1)
138+
plt.title(f"Average scaled diff (ns) across SMP=1..{num_smp} (Set {i})")
139+
plt.xlabel("SMP #")
140+
plt.ylabel("Average scaled diff (ns)")
141+
142+
avg_trend_path = os.path.join(output_dir, "scaled_averages_trend.png")
143+
plt.savefig(avg_trend_path, dpi=150)
144+
plt.close()
145+
146+
print(f"[INFO] Finished set {i}, results in {output_dir}")
147+
148+
if __name__ == "__main__":
149+
main()
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
DTC minimal.dtb
2+
Ready to launch Linux kernel. Please be patient.
3+
failed to allocate TAP device: Operation not permitted
4+
[ 0.000000] Linux version 6.1.99 (jserv@node1) (riscv32-buildroot-linux-gnu-gcc.br_real (Buildroot 2024.02.4) 12.3.0, GNU ld (GNU Binutils) 2.41) #1 SMP Thu Jul 18 13:04:10 CST 2024
5+
[ 0.000000] Machine model: semu
6+
[ 0.000000] earlycon: ns16550 at MMIO 0xf4000000 (options '')
7+
[ 0.000000] printk: bootconsole [ns16550] enabled
8+
[ 0.000000] Zone ranges:
9+
[ 0.000000] Normal [mem 0x0000000000000000-0x000000001fffffff]
10+
[ 0.000000] Movable zone start for each node
11+
[ 0.000000] Early memory node ranges
12+
[ 0.000000] node 0: [mem 0x0000000000000000-0x000000001fffffff]
13+
[ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000001fffffff]
14+
[ 0.000000] SBI specification v2.0 detected
15+
[ 0.000000] SBI implementation ID=0x999 Version=0x1
16+
[ 0.000000] SBI TIME extension detected
17+
[ 0.000000] SBI IPI extension detected
18+
[ 0.000000] SBI RFENCE extension detected
19+
[ 0.000000] SBI SRST extension detected
20+
[ 0.000000] SBI HSM extension detected
21+
[ 0.000000] riscv: base ISA extensions aim
22+
[ 0.000000] riscv: ELF capabilities aim
23+
[ 0.000000] percpu: Embedded 10 pages/cpu s11604 r8192 d21164 u40960
24+
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 130048
25+
[ 0.000000] Kernel command line: earlycon console=ttyS0
26+
[ 0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
27+
[ 0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
28+
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
29+
[ 0.000000] Memory: 506428K/524288K available (3578K kernel code, 345K rwdata, 873K rodata, 185K init, 140K bss, 17860K reserved, 0K cma-reserved)
30+
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
31+
[ 0.000000] rcu: Hierarchical RCU implementation.
32+
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=32 to nr_cpu_ids=1.
33+
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
34+
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
35+
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
36+
[ 0.000000] riscv-intc: 32 local interrupts mapped
37+
[ 0.000000] plic: interrupt-controller@0: mapped 31 interrupts with 1 handlers for 1 contexts.
38+
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
39+
[ 0.000000] riscv-timer: riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
40+
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0xefdb196da, max_idle_ns: 440795204367 ns
41+
[ 0.000000] sched_clock: 64 bits at 65MHz, resolution 15ns, wraps every 2199023255550ns
42+
[ 0.000010] Console: colour dummy device 80x25
43+
[ 0.000010] Calibrating delay loop (skipped), value calculated using timer frequency.. 130.00 BogoMIPS (lpj=260000)
44+
[ 0.000010] pid_max: default: 32768 minimum: 301
45+
[ 0.000020] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
46+
[ 0.000020] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
47+
[ 0.000050] ASID allocator disabled (0 bits)
48+
[ 0.000050] rcu: Hierarchical SRCU implementation.
49+
[ 0.000060] rcu: Max phase no-delay instances is 1000.
50+
[ 0.000060] smp: Bringing up secondary CPUs ...
51+
[ 0.000060] smp: Brought up 1 node, 1 CPU
52+
[ 0.000070] devtmpfs: initialized
53+
[ 0.000100] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
54+
[ 0.000100] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
55+
[ 0.000130] NET: Registered PF_NETLINK/PF_ROUTE protocol family
56+
[ 0.000160] platform soc@F0000000: Fixed dependency cycle(s) with /soc@F0000000/interrupt-controller@0
57+
[ 0.000351] clocksource: Switched to clocksource riscv_clocksource
58+
[ 0.000591] NET: Registered PF_INET protocol family
59+
[ 0.000601] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
60+
[ 0.000672] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
61+
[ 0.000672] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
62+
[ 0.000672] TCP established hash table entries: 4096 (order: 2, 16384 bytes, linear)
63+
[ 0.000682] TCP bind hash table entries: 4096 (order: 4, 65536 bytes, linear)
64+
[ 0.000682] TCP: Hash tables configured (established 4096 bind 4096)
65+
[ 0.000682] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
66+
[ 0.000692] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
67+
[ 0.000692] NET: Registered PF_UNIX/PF_LOCAL protocol family
68+
[ 0.000712] Unpacking initramfs...
69+
[ 0.008775] Freeing initrd memory: 8188K
70+
[ 0.008775] workingset: timestamp_bits=30 max_order=17 bucket_order=0
71+
[ 0.010371] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
72+
[ 0.010411] printk: console [ttyS0] disabled
73+
[ 0.010411] f4000000.serial: ttyS0 at MMIO 0xf4000000 (irq = 1, base_baud = 312500) is a 16550
74+
[ 0.010421] printk: console [ttyS0] enabled
75+
[ 0.010421] printk: console [ttyS0] enabled
76+
[ 0.010421] printk: bootconsole [ns16550] disabled
77+
[ 0.010421] printk: bootconsole [ns16550] disabled
78+
[ 0.010431] virtio_blk virtio1: 1/0/0 default/read/poll queues
79+
[ 0.010441] virtio_blk virtio1: [vda] 4800 512-byte logical blocks (2.46 MB/2.34 MiB)
80+
[ 0.010471] virtio_net virtio0: Assigned random MAC address 9a:a5:1b:7f:96:3b
81+
[ 0.010510] clk: Disabling unused clocks
82+
[ 0.010540] Freeing unused kernel image (initmem) memory: 180K
83+
[ 0.010540] Kernel memory protection not selected by kernel config.
84+
[ 0.010540] Run /init as init process
85+
[SEMU LOG]: Use clock_gettime
86+
[SEMU LOG]: Real boot time: 12.05580 seconds, called 220579106 times semu_timer_clocksource
87+
[SEMU LOG]: ns_per_call = 2.77813, predict_sec = 5.55625, scale_factor = 1.79977
88+
[SEMU LOG]: test_total_clocksource_ns = 2523327095, real_total_clocksource_ns = 1297733725, percentage = 0.10764
89+
[SEMU LOG]: real_ns_per_call = 5.88330, diff_ns_per_call = 3.10518

0 commit comments

Comments
 (0)