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

Base function call computations #4529

Merged
merged 7 commits into from
Jul 26, 2021
Merged

Base function call computations #4529

merged 7 commits into from
Jul 26, 2021

Conversation

olonho
Copy link
Contributor

@olonho olonho commented Jul 16, 2021

No description provided.

@olonho olonho requested a review from matklad as a code owner July 16, 2021 08:41
fn test_function_call(metric: GasMetric, vm_kind: VMKind) {
let mut xs = vec![];
let mut ys = vec![];
const REPEATS: i32 = 50;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const REPEATS: i32 = 50;
const REPEATS: u64 = 50;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 74 to 81
"
(export \"hello{}\" (func {}))
(func (;{};)
i32.const {}
drop
return
)
", i, i, i, i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"
(export \"hello{}\" (func {}))
(func (;{};)
i32.const {}
drop
return
)
", i, i, i, i)
r#"
(export "hello{i}" (func {i}))
(func (;{i};)
i32.const {i}
drop
return
)
"#, i=i)

although I guess it's better to use some wat sugar here to not repeat the i in the first place:

        write!(
            &mut methods,
            r#"
            (func (export "hello{i}")
                i32.const {i}
                drop
                return
            )
            "#,
            i = i
        )

)",
methods
);
ContractCode::new(wabt::wat2wasm(code.as_bytes()).unwrap(), None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a rebase, we now use wat instead of wabt.

#[test]
fn test_function_call_time() {
// Run with
// cargo test --release --lib function_call::test_function_call_time -- --exact --nocapture
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, shouldn't this include --features required as well?

I think as written, this'll hit the in-memory cache, masking the deserializaion costs, and desiralization should be the primary contributor to func call cost

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, although from results it doesn't seem so.

test_function_call(GasMetric::ICount, VMKind::Wasmtime);
}

fn make_many_methods_contact(method_count: i32) -> ContractCode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn make_many_methods_contact(method_count: i32) -> ContractCode {
fn make_many_methods_contract(method_count: i32) -> ContractCode {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

let mut ys = vec![];
const REPEATS: i32 = 50;
for method_count in vec![5, 20, 30, 50, 100, 200, 1000] {
let contract = make_many_methods_contact(method_count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
let contract = make_many_methods_contact(method_count);
let contract = make_many_methods_contract(method_count);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants