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

Pass arguments as const Value* #552

Merged
merged 4 commits into from
Oct 2, 2020
Merged

Pass arguments as const Value* #552

merged 4 commits into from
Oct 2, 2020

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Sep 24, 2020

Part of #526 and #563.

Pass arguments to execute() as const Value*, without providing information about number of arguments. Previously arguments were passed as span<const Value>.

Also "host function" may be changed accordingly in following PR.

Some parts may be committed separately: 2 first commits, the {Value(0)} change in unit tests.

@chfast chfast force-pushed the check_inputs_and_outputs branch from 18a67f3 to 7208c06 Compare September 29, 2020 10:25
@axic axic force-pushed the check_inputs_and_outputs branch from 7208c06 to 12d71d3 Compare September 29, 2020 20:08
Base automatically changed from check_inputs_and_outputs to master September 29, 2020 20:24
@axic
Copy link
Member

axic commented Oct 1, 2020

This gives me a ~10% speed up on the call heavy benchmarks.

And (appropriately) combining this with #554 results in 30% total gain. Independently they produce 10-15% each.

@chfast chfast mentioned this pull request Oct 1, 2020
@@ -189,7 +189,7 @@ TEST(operand_stack, small)
TEST(operand_stack, small_with_locals)
{
const fizzy::Value args[] = {0xa1, 0xa2};
OperandStack stack(args, 3, 1);
OperandStack stack(args, std::size(args), 3, 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is example where std::size() is better than sizeof.

@@ -99,8 +99,8 @@ TEST(api, resolve_imported_functions)
module, external_functions, {}, {}, std::vector<ExternalGlobal>(external_globals));

EXPECT_THAT(execute(*instance, 0, {}), Result(0));
EXPECT_THAT(execute(*instance, 1, {0}), Result(1));
EXPECT_THAT(execute(*instance, 2, {0}), Result(2));
EXPECT_THAT(execute(*instance, 1, {Value{0}}), Result(1));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When passing single 0, clang thinks it should go as nullptr. This is a workaround.

@codecov
Copy link

codecov bot commented Oct 1, 2020

Codecov Report

Merging #552 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #552   +/-   ##
=======================================
  Coverage   98.24%   98.24%           
=======================================
  Files          62       62           
  Lines        9048     9052    +4     
=======================================
+ Hits         8889     8893    +4     
  Misses        159      159           

@chfast chfast requested review from gumb0 and axic October 2, 2020 06:25
@chfast chfast marked this pull request as ready for review October 2, 2020 06:25
@chfast
Copy link
Collaborator Author

chfast commented Oct 2, 2020

fizzy/execute/blake2b/512_bytes_rounds_1_mean                     -0.0724         -0.0724            83            77            83            77
fizzy/execute/blake2b/512_bytes_rounds_16_mean                    -0.0814         -0.0814          1274          1170          1274          1170
fizzy/execute/ecpairing/onepoint_mean                             -0.0506         -0.0506        399301        379093        399305        379097
fizzy/execute/keccak256/512_bytes_rounds_1_mean                   -0.0644         -0.0644            98            92            98            92
fizzy/execute/keccak256/512_bytes_rounds_16_mean                  -0.0660         -0.0660          1434          1340          1434          1340
fizzy/execute/memset/256_bytes_mean                               -0.1103         -0.1103             7             6             7             6
fizzy/execute/memset/60000_bytes_mean                             -0.1070         -0.1070          1559          1392          1559          1392
fizzy/execute/mul256_opt0/input1_mean                             -0.0278         -0.0278            26            25            26            25
fizzy/execute/ramanujan_pi/33_runs_mean                           -0.1471         -0.1471           134           115           134           115
fizzy/execute/sha1/512_bytes_rounds_1_mean                        -0.0781         -0.0781            91            84            91            84
fizzy/execute/sha1/512_bytes_rounds_16_mean                       -0.0785         -0.0785          1266          1167          1266          1167
fizzy/execute/sha256/512_bytes_rounds_1_mean                      -0.0743         -0.0743            91            84            91            84
fizzy/execute/sha256/512_bytes_rounds_16_mean                     -0.0701         -0.0701          1246          1159          1246          1159
fizzy/execute/taylor_pi/pi_1000000_runs_mean                      -0.0027         -0.0026         40144         40037         40144         40038
fizzy/execute/micro/eli_interpreter/exec105_mean                  -0.1112         -0.1112             5             4             5             4
fizzy/execute/micro/factorial/20_mean                             +0.0118         +0.0118             1             1             1             1
fizzy/execute/micro/fibonacci/24_mean                             +0.0033         +0.0033          4938          4954          4938          4954
fizzy/execute/micro/host_adler32/1_mean                           +0.0196         +0.0196             0             0             0             0
fizzy/execute/micro/host_adler32/1000_mean                        -0.0409         -0.0409            31            30            31            30
fizzy/execute/micro/spinner/1_mean                                -0.0560         -0.0559             0             0             0             0
fizzy/execute/micro/spinner/1000_mean                             -0.1647         -0.1647            11             9            11             9

@axic
Copy link
Member

axic commented Oct 2, 2020

Looks good to me, but do you want to squash in the review comments?

@chfast
Copy link
Collaborator Author

chfast commented Oct 2, 2020

Looks good to me, but do you want to squash in the review comments?

Of course.

@chfast chfast merged commit a74e152 into master Oct 2, 2020
@chfast chfast deleted the args_span_size branch October 2, 2020 19:53
@chfast chfast mentioned this pull request Oct 5, 2020
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