Measure changed-key work on large collections

This commit is contained in:
sneeker committed 2017-06-22 12:11:00 +00:00
1 parent abe98c29fb
commit 39dd21eee2
6 files changed
+252 -7

No files matched your search

+5 -1
View File
@@ -659,7 +659,11 @@ let generated_differential_case seed_count batch_count =
let updates_path = Filename.concat dir (Printf.sprintf "updates_%d.sexp" seed) in
write_entries input_path entries;
write_batches updates_path batches;
(match run [ executable; "--input"; input_path; "--updates"; updates_path; "--trace"; "--print-result" ] with
(match run
[
executable; "--input"; input_path; "--updates"; updates_path; "--trace";
"--verify"; "--print-result";
] with
| Unix.WEXITED 0, output ->
let lines = List.filter (fun line -> line <> "") (String.split_on_char '\n' output) in
if List.length lines <> List.length expected then
+39
View File
@@ -856,3 +856,42 @@ let differential_cases =
( "the incremental plan matches full evaluation on a short run",
fun () -> differential_case 5 20 );
]
let regression_cases =
[
( "a single key update on a large collection touches only that key",
fun () ->
let entries =
Util.list_init 500 (fun index -> (index + 1, order_row (Printf.sprintf "customer%d" index) ((index * 37) mod 4001)))
in
let fixture = build_fixture (read_fixture "expensive_order.delta") entries in
Delta_runtime.reset_counters fixture.fx_counters;
(match step fixture [ Change.OpReplace (250, order_row "customer250" 3000) ] with
| Error message -> fail "update" message
| Ok (applied, cached, _) ->
let counters = fixture.fx_counters in
check_equal_int "predicate evaluations" 1 counters.Delta_runtime.predicate_evaluations;
check_equal_int "mapping evaluations" 0 counters.Delta_runtime.mapping_evaluations;
check_equal_int "scalar deltas" 1 counters.Delta_runtime.scalar_deltas;
check_equal_int "changed key visits" 3 counters.Delta_runtime.changed_key_visits;
check_equal_int "full traversals" 0 counters.Delta_runtime.full_traversals;
check_equal_string "result matches the reference"
(Value.to_string (reference_result fixture fixture.fx_state))
(Value.to_string applied);
check_equal_string "cache matches the reference"
(Value.to_string (reference_result fixture fixture.fx_state))
(Value.to_string cached)) );
( "an inserted key only evaluates the predicate and mapping for itself",
fun () ->
let entries = Util.list_init 500 (fun index -> (index + 1, order_row "row" 10)) in
let fixture = build_fixture (read_fixture "expensive_order.delta") entries in
Delta_runtime.reset_counters fixture.fx_counters;
(match step fixture [ Change.OpInsert (501, order_row "newcomer" 5000) ] with
| Error message -> fail "insert" message
| Ok _ ->
let counters = fixture.fx_counters in
check_equal_int "predicate evaluations" 1 counters.Delta_runtime.predicate_evaluations;
check_equal_int "mapping evaluations" 1 counters.Delta_runtime.mapping_evaluations;
check_equal_int "changed key visits" 3 counters.Delta_runtime.changed_key_visits;
check_equal_int "full traversals" 0 counters.Delta_runtime.full_traversals) );
]
+1
View File
@@ -388,6 +388,7 @@ let () =
Test_harness.run_suite "generated updates" Test_codegen.update_cases;
Test_harness.run_suite "wire" Test_codegen.wire_cases;
Test_harness.run_suite "cli" Test_codegen.cli_cases;
Test_harness.run_suite "regression" Test_incremental.regression_cases;
Test_harness.run_suite "differential" Test_incremental.differential_cases;
Test_harness.run_suite "generated differential" Test_codegen.generated_differential_cases;
Printf.printf "%d cases, %d failures\n" (Test_harness.case_count ()) (Test_harness.failure_count ());