Skip to content
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

feat: Add 'free_range' syscall #3467

Merged
merged 51 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1cd654b
feat: Add 'free_range' syscall
holykol Nov 1, 2023
72e0a39
fix tests
holykol Nov 1, 2023
56791f3
revert removing free
holykol Nov 2, 2023
717c97a
fuzzing support for free_range
holykol Nov 2, 2023
e174fa7
validate range
holykol Nov 2, 2023
cd5184e
address feedback
holykol Nov 6, 2023
69395c2
benchmark stuff
holykol Nov 6, 2023
53aec75
fix costs
holykol Nov 7, 2023
792c224
naming
holykol Nov 7, 2023
f770da2
update gsdk
holykol Nov 7, 2023
98a35d4
chore(runtime): update weights (#3477)
github-actions[bot] Nov 7, 2023
aecdcc5
address feedback
holykol Nov 7, 2023
a57bb06
revert changing alloc branch
holykol Nov 7, 2023
0751550
fix benchmarks
holykol Nov 8, 2023
c1562c6
chore(runtime): update weights (#3482)
github-actions[bot] Nov 8, 2023
8fe9e0c
address feedback
holykol Nov 8, 2023
0c6fdaf
move error handling inside syscall implementation
holykol Nov 9, 2023
24bbe91
fix benchmark
holykol Nov 9, 2023
ec644b3
chore(runtime): update weights (#3488)
github-actions[bot] Nov 10, 2023
2e90c3b
reduce free_range banchmark iterations
grishasobol Nov 10, 2023
fb08dd7
chore(runtime): update weights (#3489)
github-actions[bot] Nov 10, 2023
b0ba34c
revert weights
holykol Nov 10, 2023
dfdb792
revert weights 2
holykol Nov 10, 2023
601b58a
trap on any error
holykol Nov 13, 2023
75c38d4
return nothing
holykol Nov 13, 2023
3931497
fix tests
holykol Nov 13, 2023
fca257c
fix fuzzing
holykol Nov 14, 2023
b2e6e74
address feedback
holykol Nov 15, 2023
2123704
Merge branch 'master' into holykol/free-range-syscall
holykol Nov 17, 2023
60b4df9
address feedback
holykol Nov 20, 2023
ecb4317
address feedback 2
holykol Nov 21, 2023
6223615
revert test fix
holykol Nov 21, 2023
3c184b5
address feedback
holykol Nov 27, 2023
0e84818
Merge branch 'master' into holykol/free-range-syscall
holykol Nov 27, 2023
87a4a6c
exchange repetitions and BATCH_SIZE in benchmarks
holykol Nov 27, 2023
6fd6bc5
Merge branch 'master' into holykol/free-range-syscall
holykol Nov 28, 2023
841da55
always return 0 in free_range
holykol Nov 28, 2023
506f13d
fix
holykol Nov 28, 2023
b5355a9
fix 2
holykol Nov 28, 2023
d0f0d22
fix 3
holykol Nov 29, 2023
36664af
chore(runtime): update weights
holykol Nov 29, 2023
9c94842
Revert "chore(runtime): update weights"
holykol Dec 1, 2023
dbb44ab
Merge branch 'master' into holykol/free-range-syscall
holykol Dec 1, 2023
9ca5d86
Merge branch 'master' into holykol/free-range-syscall
holykol Dec 1, 2023
5e81011
return error instead of trapping
holykol Dec 1, 2023
e233c32
revert old benchmarks
holykol Dec 1, 2023
2313e22
fix 999
holykol Dec 2, 2023
449a6ba
fix 999.5
holykol Dec 2, 2023
39f3e4e
test that free_range behaves as free
holykol Dec 2, 2023
659f61f
address feedback
holykol Dec 2, 2023
37d447f
address feedback
holykol Dec 2, 2023
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
6 changes: 3 additions & 3 deletions pallets/gear/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ benchmarks! {
}

free_range {
let r in 0 .. API_BENCHMARK_BATCHES;
let r in 0..512;
let mut res = None;
let exec = Benches::<T>::free_range(r, 1)?;
}: {
Expand All @@ -838,9 +838,9 @@ benchmarks! {
}

free_range_per_page {
let r in 0 .. API_BENCHMARK_BATCHES;
let r in 0..512;
holykol marked this conversation as resolved.
Show resolved Hide resolved
let mut res = None;
let exec = Benches::<T>::free_range(1, 512)?;
let exec = Benches::<T>::free_range(1, r)?;
}: {
res.replace(run_process(exec));
}
Expand Down
20 changes: 10 additions & 10 deletions pallets/gear/src/benchmarking/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,21 @@ where
pub fn free_range(repetitions: u32, pages_per_call: u32) -> Result<Exec<T>, &'static str> {
use Instruction::*;
let mut instructions = vec![];
for _ in 0..(API_BENCHMARK_BATCH_SIZE * repetitions) {
for _ in 0..API_BENCHMARK_BATCH_SIZE {
let n_pages = 512;
instructions.extend([I32Const(n_pages), Call(0), I32Const(-1)]);
unreachable_condition(&mut instructions, I32Eq); // if alloc returns -1 then it's error

// if pages_per_call is
for chunk in (1..=512)
.collect::<Vec<i32>>()
.chunks(pages_per_call as usize)
{
let start = *chunk.first().unwrap();
let end = *chunk.last().unwrap();

instructions.extend([I32Const(start), I32Const(end), Call(1), I32Const(0)]);
let mut i = 0;
for _ in 0..repetitions {
instructions.extend([
I32Const(i),
I32Const(i + pages_per_call as i32),
Call(1),
I32Const(0),
]);
unreachable_condition(&mut instructions, I32Ne); // if free_range returns not 0 then it's error
i += pages_per_call as i32
}
}

Expand Down