Mentions légales du service

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • vatrophi/preemptive-iterator
1 result
Show changes
Commits on Source (2)
......@@ -2,55 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "anstream"
version = "0.6.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]]
name = "anstyle-parse"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
dependencies = [
"anstyle",
"windows-sys",
]
[[package]]
name = "byteorder"
version = "1.5.0"
......@@ -63,52 +14,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]]
name = "colorchoice"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]]
name = "critical-section"
version = "1.1.3"
......@@ -169,7 +74,6 @@ dependencies = [
"embassy-executor-macros",
"embassy-time-driver",
"embassy-time-queue-driver",
"log",
]
[[package]]
......@@ -199,7 +103,6 @@ dependencies = [
"embedded-io-async",
"futures-util",
"heapless",
"log",
]
[[package]]
......@@ -322,24 +225,12 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "litrs"
version = "0.4.1"
......@@ -383,7 +274,6 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
name = "preemptive-iterator"
version = "0.1.0"
dependencies = [
"clap",
"critical-section",
"embassy-executor",
"embassy-futures",
......@@ -438,87 +328,8 @@ version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
......@@ -10,9 +10,8 @@ embassy-time = { version = "0.3.2", features = ["log", "std"] }
embassy-futures = "0.1.1"
[dev-dependencies]
clap = { version = "4.5.19", features = ["derive"] }
embassy-sync = { version = "0.6.0", features = ["log"] }
embassy-executor = { version = "0.6.0", features = ["task-arena-size-32768", "arch-std", "executor-thread", "log", "integrated-timers"] }
embassy-sync = "0.6.0"
embassy-executor = { version = "0.6.0", features = ["task-arena-size-32768", "arch-std", "executor-thread", "integrated-timers"] }
critical-section = { version = "1.1", features = ["std"] }
......
use clap::Parser;
use embassy_time::Duration;
use preemptive_iterator::{AsyncIterator, PreemptiveIterator};
use std::hint::black_box;
......@@ -60,41 +59,51 @@ fn work(task_duration: u64) {
}
std::hint::black_box(res);
}
#[derive(Parser, Debug, Clone, Copy)]
#[derive(Default)]
struct Args {
#[arg(long)]
duration_task: u64,
#[arg(long)]
reactivity_us: u64,
#[arg(long)]
n_iter: u32,
#[arg(long, default_value_t = 1)]
repeat: u32,
#[arg(long, default_value_t = false)]
output_ns: bool,
}
impl Args {
fn parse() -> Self {
const N_ARGS: usize = 4;
const DUR: &'static str = "--duration-task=";
const REAC: &'static str = "--reactivity-us=";
const NITER: &'static str = "--n-iter=";
const REPEAT: &'static str = "--repeat=";
let args: Vec<String> = std::env::args().collect();
if args.len() != N_ARGS + 1 {
panic!("Usage: ./exec {DUR}1 {REAC}1 {NITER}1 {REPEAT}1")
}
let mut res = Args::default();
for arg in args.into_iter().skip(1) {
if arg.starts_with(DUR) {
res.duration_task = arg.split_at(DUR.len()).1.parse().unwrap();
} else if arg.starts_with(REAC) {
res.reactivity_us = arg.split_at(REAC.len()).1.parse().unwrap();
} else if arg.starts_with(NITER) {
res.n_iter = arg.split_at(NITER.len()).1.parse().unwrap();
} else if arg.starts_with(REPEAT) {
res.repeat = arg.split_at(REPEAT.len()).1.parse().unwrap();
} else {
panic!("Unknown argument: {arg}")
}
}
res
}
}
fn main() {
let args = Args::parse();
for _ in 0..args.repeat {
let time_ref = time_baseline(0..args.n_iter, |_| work(args.duration_task));
let [time_auto, time_manual, time_auto2] =
time_contender(args.n_iter, args.reactivity_us, args.duration_task);
if args.output_ns {
println!("Baseline: {}", time_ref.as_nanos());
println!("Preemptive: {}", time_auto.as_nanos());
println!("PreemptiveFixed: {}", time_manual.as_nanos());
println!("Preemptive2: {}", time_auto2.as_nanos());
} else {
let baseline = time_ref.as_secs_f64();
let overhead = 100.0 * (time_auto.as_secs_f64() - baseline) / baseline;
let overhead2 = 100.0 * (time_manual.as_secs_f64() - baseline) / baseline;
let overhead3 = 100.0 * (time_auto2.as_secs_f64() - baseline) / baseline;
println!("Baseline: {:?}", time_ref);
println!("Preemptive: {:?} => {:.4}%", time_auto, overhead);
println!("PreemptiveFixed: {:?} => {:.4}%", time_manual, overhead2);
println!("Preemptive2: {:?} => {:.4}%", time_auto2, overhead3);
println!("-------------------------------------------------------------");
}
println!("Baseline: {}", time_ref.as_nanos());
println!("Preemptive: {}", time_auto.as_nanos());
println!("PreemptiveFixed: {}", time_manual.as_nanos());
println!("Preemptive2: {}", time_auto2.as_nanos());
}
}
#! /usr/bin/env python3
import argparse
import argcomplete
import subprocess
import os
import re
ADDR_OR_LLVM_ANON = re.compile(r"(0x[a-f0-9]+|[+.a-f0-9x]+llvm[+.a-f0-9x]+)")
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("executable1", help="Executable reference.")
parser.add_argument("executable2", help="Executable to diff against.")
argcomplete.autocomplete(parser)
args = parser.parse_args()
disasm_out1 = "/tmp/compare_disasm1"
disasm_out2 = "/tmp/compare_disasm2"
disassemble(args.executable1, disasm_out1)
disassemble(args.executable2, disasm_out2)
diff_content = raw_diff(disasm_out1, disasm_out2)
diffs = diff_content.split("\n@@")
not_only_addr = []
for diff in diffs[2:]: # skip firsts since they are just objdump init header
if not only_addrs_change(diff):
not_only_addr.append(diff)
print(f"Found {len(not_only_addr)} real diffs")
for diff in not_only_addr:
only_addrs_change(diff, dbg=True)
user_input = input("Go next (y/n)?")
if user_input.startswith("y"):
print("@@", diff)
else:
break
def only_addrs_change(diff: str, dbg=False) -> bool:
lines = diff.splitlines()
lines1 = [line[1:] for line in lines if line.startswith("-")]
lines2 = [line[1:] for line in lines if line.startswith("+")]
if len(lines1) != len(lines2):
return False
for l1, l2 in zip(lines1, lines2):
dl1 = re.sub(ADDR_OR_LLVM_ANON, "", l1)
dl2 = re.sub(ADDR_OR_LLVM_ANON, "", l2)
if dbg:
print(dl1)
print(dl2)
if dl1 != dl2:
return False
return True
def disassemble(executable: str, output: str):
p = subprocess.run(
[
"objdump",
"-d",
"--demangle=auto",
"--no-addresses",
"--no-show-raw-insn",
executable,
],
check=True,
text=True,
stdout=subprocess.PIPE,
)
assert p.stdout
if os.path.exists(output):
os.remove(output)
with open(output, "w") as f:
f.write(p.stdout)
def raw_diff(file1: str, file2: str) -> str:
p = subprocess.run(["diff", "-u", file1, file2], text=True, stdout=subprocess.PIPE)
assert p.stdout
return p.stdout
if __name__ == "__main__":
main()
......@@ -9,10 +9,11 @@ from bisect import bisect_left
import os
import re
from dataclasses import dataclass
import pandas
import pandas
import matplotlib.pyplot as plt
import numpy as np
import argcomplete
DEFAULT_PARAMETERS = {
"Reactivity": [10],
......@@ -49,15 +50,10 @@ class CollectorCSV:
"-c",
"0",
f"target/{self.profile}/examples/overhead",
"--duration-task",
str(param["DurationTask"]),
"--reactivity-us",
str(param["Reactivity"]),
"--n-iter",
str(param["N_Iter"]),
"--repeat",
str(self.repeat),
"--output-ns",
f"--duration-task={param['DurationTask']}",
f"--reactivity-us={param['Reactivity']}",
f"--n-iter={param['N_Iter']}",
f"--repeat={self.repeat}",
],
check=True,
text=True,
......@@ -268,6 +264,7 @@ def main():
type=int,
default=DEFAULT_PARAMETERS["Reactivity"][0],
)
argcomplete.autocomplete(parser)
args = parser.parse_args()
match args.subparser_name:
......
argcomplete==3.5.1
contourpy==1.3.0
cycler==0.12.1
fonttools==4.54.1
......@@ -11,7 +12,6 @@ pyparsing==3.1.4
python-dateutil==2.9.0.post0
pytz==2024.2
scipy==1.14.1
seaborn==0.13.2
six==1.16.0
tabulate==0.9.0
tzdata==2024.2
......@@ -23,7 +23,6 @@ pub trait AsyncIterator: Iterator + Divisible {
self.async_fold((), move |(), item| f(item), reactivity)
.await
}
#[inline(never)]
async fn async_fold<B, F: FnMut(B, Self::Item) -> B>(
mut self,
init: B,
......
......@@ -33,7 +33,6 @@ pub trait PreemptiveIterator: Iterator + Sized {
}
impl<T, I: Iterator<Item = T>> PreemptiveIterator for I {
#[inline(never)]
async fn preemptive_fold<B, F: FnMut(B, Self::Item) -> B>(
mut self,
init: B,
......@@ -69,7 +68,6 @@ impl<T, I: Iterator<Item = T>> PreemptiveIterator for I {
}
}
#[inline(never)]
async fn preemptive_fold_fixed_block<B, F: FnMut(B, Self::Item) -> B>(
mut self,
init: B,
......