Skip to content

Commit

Permalink
update bench numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
crusso committed Aug 6, 2024
1 parent bcc059c commit ba4c267
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 51 deletions.
37 changes: 31 additions & 6 deletions src/codegen/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6581,11 +6581,19 @@ module MakeSerialization (Strm : Stream) = struct
let set_instruction_limit env =
G.i (GlobalSet (nr (E.get_global env "@@instruction_limit")))

let get_allocation_limit env =
G.i (GlobalGet (nr (E.get_global env "@@allocation_limit")))
let set_allocation_limit env =
G.i (GlobalSet (nr (E.get_global env "@@allocation_limit")))

(* interval for checking instruction counter *)
let idl_limit_interval = 32l (* TUNE *)
let idl_limit_factor = 1000L (* TUNE *)
let idl_limit_bias = 10_000_000L (* TUNE *)
let idl_instruction_factor = 1000L (* TUNE *)
let idl_instruction_bias = 10_000_000L (* TUNE *)
let idl_pseudo_cost = 100L (* TUNE *)
let scale bytes = Int64.mul bytes (Int64.of_int32(Int32.div Heap.word_size 4l))
let idl_allocation_factor = scale(64L) (* TUNE *)
let idl_allocation_bias = scale(1_000_000L) (* TUNE *)

let idl_instruction_counter env =
match E.mode env with
Expand All @@ -6608,16 +6616,28 @@ module MakeSerialization (Strm : Stream) = struct
let reset_instruction_limit env get_blob get_rel_buf_opt =
get_rel_buf_opt ^^
G.if0 begin (* Candid deserialization *)
(* set instruction limit *)
idl_instruction_counter env ^^
get_blob ^^
Blob.len env ^^
G.i (Convert (Wasm.Values.I64 I64Op.ExtendUI32)) ^^
compile_const_64 idl_limit_factor^^
compile_const_64 idl_instruction_factor ^^
G.i (Binary (Wasm.Values.I64 I64Op.Mul)) ^^
compile_const_64 idl_limit_bias ^^
G.i (Binary (Wasm.Values.I64 I64Op.Add)) ^^
compile_const_64 idl_instruction_bias ^^
G.i (Binary (Wasm.Values.I64 I64Op.Add)) ^^
G.i (Binary (Wasm.Values.I64 I64Op.Add)) ^^
set_instruction_limit env
set_instruction_limit env ^^
(* set allocation limit *)
Heap.get_total_allocation env ^^
get_blob ^^
Blob.len env ^^
G.i (Convert (Wasm.Values.I64 I64Op.ExtendUI32)) ^^
compile_const_64 idl_allocation_factor ^^
G.i (Binary (Wasm.Values.I64 I64Op.Mul)) ^^
compile_const_64 idl_allocation_bias ^^
G.i (Binary (Wasm.Values.I64 I64Op.Add)) ^^
G.i (Binary (Wasm.Values.I64 I64Op.Add)) ^^
set_allocation_limit env
end
begin (* Extended candid/ Destabilization *)
G.nop
Expand All @@ -6640,6 +6660,7 @@ module MakeSerialization (Strm : Stream) = struct
| Flags.WASIMode | Flags.WasmMode ->
E.add_global64 env "@@pseudo_instruction_counter" Mutable 0L);
E.add_global64 env "@@instruction_limit" Mutable 0L;
E.add_global64 env "@@allocation_limit" Mutable 0L;
Func.define_built_in env "idl_limit_check" [] [] (fun env ->
get_rel_buf_opt env ^^
G.if0 begin (* Candid deserialization *)
Expand All @@ -6655,6 +6676,10 @@ module MakeSerialization (Strm : Stream) = struct
get_instruction_limit env ^^
G.i (Compare (Wasm.Values.I64 I64Op.LeU)) ^^
E.else_trap_with env "IDL error: exceeded instruction limit" ^^
Heap.get_total_allocation env ^^
get_allocation_limit env ^^
G.i (Compare (Wasm.Values.I64 I64Op.LeU)) ^^
E.else_trap_with env "IDL error: exceeded allocation limit" ^^
(* Reset counter *)
compile_unboxed_const idl_limit_interval ^^
set_limit_counter env
Expand Down
2 changes: 1 addition & 1 deletion test/bench/ok/bignum.drun-run-opt.ok
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a000000000000000001
ingress Completed: Reply: 0x4449444c0000
debug.print: {cycles = 2_512_723; size = +59_652}
ingress Completed: Reply: 0x4449444c0000
debug.print: {cycles = 107_695_543; size = +1_817_872}
debug.print: {cycles = 107_695_562; size = +1_817_872}
ingress Completed: Reply: 0x4449444c0000
2 changes: 1 addition & 1 deletion test/bench/ok/bignum.drun-run.ok
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a000000000000000001
ingress Completed: Reply: 0x4449444c0000
debug.print: {cycles = 2_619_856; size = +59_652}
ingress Completed: Reply: 0x4449444c0000
debug.print: {cycles = 107_890_497; size = +1_817_872}
debug.print: {cycles = 107_890_550; size = +1_817_872}
ingress Completed: Reply: 0x4449444c0000
2 changes: 1 addition & 1 deletion test/bench/ok/heap-32.drun-run-opt.ok
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: (50_227, +29_863_068, 708_174_952)
debug.print: (50_070, +32_992_212, 766_613_640)
debug.print: (50_070, +32_992_212, 766_613_760)
ingress Completed: Reply: 0x4449444c0000
2 changes: 1 addition & 1 deletion test/bench/ok/heap-32.drun-run.ok
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: (50_227, +29_863_068, 769_000_085)
debug.print: (50_070, +32_992_212, 830_427_314)
debug.print: (50_070, +32_992_212, 830_427_500)
ingress Completed: Reply: 0x4449444c0000
40 changes: 20 additions & 20 deletions test/run-drun/ok/idl-limits-fine.drun-run.ok
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
debug.print: {bytes = 12}
debug.print: {MB = 0; bytes = 12; instr_per_byte = 194; instrs = 2_331}
debug.print: {MB = 0; bytes = 12; instr_per_byte = 198; instrs = 2_384}
debug.print: {bytes = 524_348}
debug.print: {MB = 1; bytes = 524_348; instr_per_byte = 86; instrs = 45_447_595}
debug.print: {MB = 1; bytes = 524_348; instr_per_byte = 87; instrs = 45_813_072}
debug.print: {bytes = 1_048_684}
debug.print: {MB = 2; bytes = 1_048_684; instr_per_byte = 86; instrs = 90_892_859}
debug.print: {MB = 2; bytes = 1_048_684; instr_per_byte = 87; instrs = 91_623_760}
debug.print: {bytes = 1_573_020}
debug.print: {MB = 3; bytes = 1_573_020; instr_per_byte = 86; instrs = 136_338_331}
debug.print: {MB = 3; bytes = 1_573_020; instr_per_byte = 87; instrs = 137_434_702}
debug.print: {bytes = 2_097_356}
debug.print: {MB = 4; bytes = 2_097_356; instr_per_byte = 86; instrs = 181_783_595}
debug.print: {MB = 4; bytes = 2_097_356; instr_per_byte = 87; instrs = 183_245_390}
debug.print: {bytes = 2_621_692}
debug.print: {MB = 5; bytes = 2_621_692; instr_per_byte = 86; instrs = 227_228_859}
debug.print: {MB = 5; bytes = 2_621_692; instr_per_byte = 87; instrs = 229_056_078}
debug.print: {bytes = 3_146_028}
debug.print: {MB = 6; bytes = 3_146_028; instr_per_byte = 86; instrs = 272_674_331}
debug.print: {MB = 6; bytes = 3_146_028; instr_per_byte = 87; instrs = 274_867_020}
debug.print: {bytes = 3_670_364}
debug.print: {MB = 7; bytes = 3_670_364; instr_per_byte = 86; instrs = 318_119_595}
debug.print: {MB = 7; bytes = 3_670_364; instr_per_byte = 87; instrs = 320_677_708}
debug.print: {bytes = 4_194_701}
debug.print: {MB = 8; bytes = 4_194_701; instr_per_byte = 86; instrs = 363_564_898}
debug.print: {MB = 8; bytes = 4_194_701; instr_per_byte = 87; instrs = 366_488_435}
debug.print: {bytes = 4_719_037}
debug.print: {MB = 9; bytes = 4_719_037; instr_per_byte = 86; instrs = 409_010_162}
debug.print: {MB = 9; bytes = 4_719_037; instr_per_byte = 87; instrs = 412_299_123}
debug.print: {bytes = 5_243_373}
debug.print: {MB = 10; bytes = 5_243_373; instr_per_byte = 86; instrs = 454_455_426}
debug.print: {MB = 10; bytes = 5_243_373; instr_per_byte = 87; instrs = 458_109_811}
debug.print: {bytes = 5_767_709}
debug.print: {MB = 11; bytes = 5_767_709; instr_per_byte = 86; instrs = 499_900_898}
debug.print: {MB = 11; bytes = 5_767_709; instr_per_byte = 87; instrs = 503_920_753}
debug.print: {bytes = 6_292_045}
debug.print: {MB = 12; bytes = 6_292_045; instr_per_byte = 86; instrs = 545_346_162}
debug.print: {MB = 12; bytes = 6_292_045; instr_per_byte = 87; instrs = 549_731_441}
debug.print: {bytes = 6_816_381}
debug.print: {MB = 13; bytes = 6_816_381; instr_per_byte = 86; instrs = 590_791_426}
debug.print: {MB = 13; bytes = 6_816_381; instr_per_byte = 87; instrs = 595_542_129}
debug.print: {bytes = 7_340_717}
debug.print: {MB = 14; bytes = 7_340_717; instr_per_byte = 86; instrs = 636_236_690}
debug.print: {MB = 14; bytes = 7_340_717; instr_per_byte = 87; instrs = 641_352_817}
debug.print: {bytes = 7_865_053}
debug.print: {MB = 15; bytes = 7_865_053; instr_per_byte = 86; instrs = 681_682_162}
debug.print: {MB = 15; bytes = 7_865_053; instr_per_byte = 87; instrs = 687_163_759}
debug.print: {bytes = 8_389_389}
debug.print: {MB = 16; bytes = 8_389_389; instr_per_byte = 86; instrs = 727_127_426}
debug.print: {MB = 16; bytes = 8_389_389; instr_per_byte = 87; instrs = 732_974_447}
debug.print: {bytes = 8_913_725}
debug.print: {MB = 17; bytes = 8_913_725; instr_per_byte = 86; instrs = 772_572_690}
debug.print: {MB = 17; bytes = 8_913_725; instr_per_byte = 87; instrs = 778_785_135}
debug.print: {bytes = 9_438_061}
debug.print: {MB = 18; bytes = 9_438_061; instr_per_byte = 86; instrs = 818_018_162}
debug.print: {MB = 18; bytes = 9_438_061; instr_per_byte = 87; instrs = 824_596_077}
debug.print: {bytes = 9_962_397}
debug.print: {MB = 19; bytes = 9_962_397; instr_per_byte = 86; instrs = 863_463_218}
debug.print: {MB = 19; bytes = 9_962_397; instr_per_byte = 87; instrs = 870_406_511}
ingress Completed: Reply: 0x4449444c0000
20 changes: 10 additions & 10 deletions test/run-drun/ok/idl-limits.drun-run.ok
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
debug.print: {bytes = 12}
debug.print: {MB = 0; bytes = 12; instr_per_byte = 194; instrs = 2_331}
debug.print: {MB = 0; bytes = 12; instr_per_byte = 198; instrs = 2_384}
debug.print: {bytes = 1_048_620}
debug.print: {MB = 1; bytes = 1_048_620; instr_per_byte = 4; instrs = 4_999_931}
debug.print: {MB = 1; bytes = 1_048_620; instr_per_byte = 4; instrs = 4_999_984}
debug.print: {bytes = 2_097_228}
debug.print: {MB = 2; bytes = 2_097_228; instr_per_byte = 4; instrs = 9_997_739}
debug.print: {MB = 2; bytes = 2_097_228; instr_per_byte = 4; instrs = 9_997_838}
debug.print: {bytes = 3_145_836}
debug.print: {MB = 3; bytes = 3_145_836; instr_per_byte = 4; instrs = 14_995_547}
debug.print: {MB = 3; bytes = 3_145_836; instr_per_byte = 4; instrs = 14_995_692}
debug.print: {bytes = 4_194_444}
debug.print: {MB = 4; bytes = 4_194_444; instr_per_byte = 4; instrs = 19_993_147}
debug.print: {MB = 4; bytes = 4_194_444; instr_per_byte = 4; instrs = 19_993_292}
debug.print: {bytes = 5_243_052}
debug.print: {MB = 5; bytes = 5_243_052; instr_per_byte = 4; instrs = 24_990_747}
debug.print: {MB = 5; bytes = 5_243_052; instr_per_byte = 4; instrs = 24_990_892}
debug.print: {bytes = 6_291_660}
debug.print: {MB = 6; bytes = 6_291_660; instr_per_byte = 4; instrs = 29_988_555}
debug.print: {MB = 6; bytes = 6_291_660; instr_per_byte = 4; instrs = 29_988_746}
debug.print: {bytes = 7_340_268}
debug.print: {MB = 7; bytes = 7_340_268; instr_per_byte = 4; instrs = 34_986_155}
debug.print: {MB = 7; bytes = 7_340_268; instr_per_byte = 4; instrs = 34_986_346}
debug.print: {bytes = 8_388_877}
debug.print: {MB = 8; bytes = 8_388_877; instr_per_byte = 3; instrs = 27_397_890}
debug.print: {MB = 8; bytes = 8_388_877; instr_per_byte = 3; instrs = 27_398_127}
debug.print: {bytes = 9_437_485}
debug.print: {MB = 9; bytes = 9_437_485; instr_per_byte = 3; instrs = 30_822_434}
debug.print: {MB = 9; bytes = 9_437_485; instr_per_byte = 3; instrs = 30_822_717}
ingress Completed: Reply: 0x4449444c0000
22 changes: 11 additions & 11 deletions test/run-drun/ok/idl-spacebomb.drun-run.ok
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: ID
debug.print: {function = "vec_null_not_ignored"; hex = "4449444C016D7F01008094EBDC03"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: RTS error: Array allocation too large
debug.print: {function = "vec_null_not_ignored"; hex = "4449444C016D7F010080ADE204"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_null_not_ignored"; hex = "4449444C016D7F0100FFFF3F"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_null_not_ignored"; hex = "4449444C016D7F010080BF18"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_reserved_not_ignored"; hex = "4449444C016D7001008094EBDC03"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: RTS error: Array allocation too large
debug.print: {function = "vec_reserved_not_ignored"; hex = "4449444C016D70010080ADE204"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_reserved_not_ignored"; hex = "4449444C016D700100FFFF3F"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_reserved_not_ignored"; hex = "4449444C016D70010080BF18"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "zero_sized_record_not_ignored"; hex = "4449444C046C03007F010102026C0100706C006D0001038094EBDC03"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: RTS error: Array allocation too large
debug.print: {function = "zero_sized_record_not_ignored"; hex = "4449444C046C03007F010102026C0100706C006D00010380ADE204"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "zero_sized_record_not_ignored"; hex = "4449444C046C03007F010102026C0100706C006D000103FFFF3F"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "zero_sized_record_not_ignored"; hex = "4449444C046C03007F010102026C0100706C006D00010380B518"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_vec_null_not_ignored"; hex = "4449444C026D016D7F010005FFFF3FFFFF3FFFFF3FFFFF3FFFFF3F"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_record_emp_not_ignored"; hex = "4449444C026D016C00010080ADE204"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded allocation limit
debug.print: {function = "vec_null_subtyping"; hex = "4449444C016D7F01008094EBDC03"}
debug.print: IC0503: Canister rwlgt-iiaaa-aaaaa-aaaaa-cai trapped explicitly: IDL error: exceeded instruction limit
debug.print: {function = "vec_null_subtyping"; hex = "4449444C016D7F010080ADE204"}
Expand Down

0 comments on commit ba4c267

Please sign in to comment.