mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
Estimated hours taken: 30 Branches: main Make tabling statistics much more useful, and avoid core dumps while printing them (thereby fixing bug #23 in Mantis). runtime/mercury_tabling.h: Expand the set of statistics we can gather about tabling (starting to gather information about memory consumption). Put the statistics into logical groups: enum functors, non-enum du functors, hash tables, and the expandable table used for I/O tabling. For du types and polymorphic types, we can gather different statistics for different parts of a term. We used to use one field to gather more than one related kind of count, but these are now separated. Group the MR_ProcTableInfo struct fields relating to statistics into substructures. The substructures describing a call or answer table have their own substructures giving the statistics about the individual steps; put these in parallel with the descriptions of the steps themselves. Put those substructures into two-element arrays to allow them to be handled uniformly. runtime/mercury_types.h: Add the typedefs needed by mercury_tabling.h. runtime/mercury_tabling_macros.h: Conform to the modified classification of tabling categories. runtime/mercury_tabling.c: runtime/mercury_hash_lookup_or_add_body.h: runtime/mercury_table_int_fix_index_body.h: runtime/mercury_table_int_start_index_body.h: runtime/mercury_table_type_body.h: runtime/mercury_tabling_stats_defs.h: runtime/mercury_tabling_stats_nodefs.h: runtime/mercury_tabling_stats_undefs.h: Gather the modified and expanded set of statistics. Use more meaningful names (with MR_ prefixes) for macros. library/table_builtin.m: library/table_statistics.m: Move the material relating to statistics that used to be in table_builtin.m to the new module table_statistics.m. This is necessary because table_builtin.m is deliberately not included in the library documentation, yet users needs to know how to print out and interpret tabling statistics. Expand the code for handling statistics, adding predicates for printing them together with (hopefully explanatory) labels. Make it all work with the new runtime data structures. library/library.m: Include the new library module. mdbcomp/prim_data.m: Provide a way to refer to the tabling statistics module. compiler/hlds_pred.m: Add utility function to compute the kind of statistics we gather for a given kind of tabling step. compiler/rtti.m: Change the compiler's representation of tabling's runtime data structures to conform to the change to runtime/mercury_tabling.h. Replace a bool with a purpose-designed type (is_array), and add other similar types (call_or_answer_table, curr_or_prev_table). compiler/rtti_out.m: compiler/llds_out.m: Output the updated data structures. compiler/ml_code_gen.m: Generate the updated data structures. compiler/table_gen.m: Update the C code we generate to gather statistics. Gather the extra information needed by the updated data structures in the compiler (to fill in the updated data structures in the runtime). compiler/mlds.m: Add a new kind of constant, one that has just a name. This allows ml_code_gen.m to avoid lying about the type of constants of enum tyes (such as the kind of tabling stats we gather for a step). compiler/modules.m: Import the new table_statistics module automatically if any tabling pragma asks for statistics. compiler/add_pragma.m: compiler/hlds_out.m: compiler/llds.m: compiler/mlds_to_c.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/mlds_to_java.m: compiler/mlds_to_managed.m: trace/mercury_trace_cmd_developer.c: Conform to the changes above. tests/tabling/fib_stats.{m,exp}: tests/tabling/specified_stats.{m,exp}: New test cases to the test tabling statistics. tests/tabling/Mmakefile: Enable the new test cases. tests/tabling/fib.m: tests/tabling/specified.m: Clean up the code of these test cases, which were used as the basis of the new test cases.
116 lines
4.7 KiB
Plaintext
116 lines
4.7 KiB
Plaintext
fib(1): 1
|
|
fib(2): 2
|
|
fib(3): 3
|
|
fib(4): 5
|
|
fib(5): 8
|
|
fib(6): 13
|
|
fib(7): 21
|
|
fib(8): 34
|
|
fib(9): 55
|
|
fib(10): 89
|
|
|
|
Previous call table for mfib, test 1 to 10:
|
|
number of lookups: 0
|
|
|
|
Current call table for mfib, test 1 to 10:
|
|
number of lookups: 28
|
|
number of successful lookups (old calls): 17 (60.71%)
|
|
number of unsuccessful lookups (new calls): 11 (39.29%)
|
|
statistics for the individual steps:
|
|
|
|
step 1, variable N: hash table
|
|
number of lookups: 28
|
|
number of successful lookups: 17 (60.71%)
|
|
number of unsuccessful lookups: 11 (39.29%)
|
|
number of hash table allocations: 1
|
|
number of bytes allocated for hash tables: 536
|
|
number of bulk hash link allocations: 1
|
|
number of bytes allocated for hash links: 3,080
|
|
number of key compares when unsuccessful: 0
|
|
number of key compares when successful: 17
|
|
number of hash table resizes: 0
|
|
|
|
Call table difference (curr - prev) for mfib, test 1 to 10:
|
|
number of lookups: 28
|
|
number of successful lookups (old calls): 17 (60.71%)
|
|
number of unsuccessful lookups (new calls): 11 (39.29%)
|
|
statistics for the individual steps:
|
|
|
|
step 1, variable N: hash table
|
|
number of lookups: 28
|
|
number of successful lookups: 17 (60.71%)
|
|
number of unsuccessful lookups: 11 (39.29%)
|
|
number of hash table allocations: 1
|
|
number of bytes allocated for hash tables: 536
|
|
number of bulk hash link allocations: 1
|
|
number of bytes allocated for hash links: 3,080
|
|
number of key compares when unsuccessful: 0
|
|
number of key compares when successful: 17
|
|
number of hash table resizes: 0
|
|
|
|
fib(11): 144
|
|
fib(12): 233
|
|
fib(13): 377
|
|
fib(14): 610
|
|
fib(15): 987
|
|
fib(16): 1597
|
|
fib(17): 2584
|
|
fib(18): 4181
|
|
fib(19): 6765
|
|
fib(20): 10946
|
|
|
|
Previous call table for mfib, test 11 to 20:
|
|
number of lookups: 28
|
|
number of successful lookups (old calls): 17 (60.71%)
|
|
number of unsuccessful lookups (new calls): 11 (39.29%)
|
|
statistics for the individual steps:
|
|
|
|
step 1, variable N: hash table
|
|
number of lookups: 28
|
|
number of successful lookups: 17 (60.71%)
|
|
number of unsuccessful lookups: 11 (39.29%)
|
|
number of hash table allocations: 1
|
|
number of bytes allocated for hash tables: 536
|
|
number of bulk hash link allocations: 1
|
|
number of bytes allocated for hash links: 3,080
|
|
number of key compares when unsuccessful: 0
|
|
number of key compares when successful: 17
|
|
number of hash table resizes: 0
|
|
|
|
Current call table for mfib, test 11 to 20:
|
|
number of lookups: 58
|
|
number of successful lookups (old calls): 37 (63.79%)
|
|
number of unsuccessful lookups (new calls): 21 (36.21%)
|
|
statistics for the individual steps:
|
|
|
|
step 1, variable N: hash table
|
|
number of lookups: 58
|
|
number of successful lookups: 37 (63.79%)
|
|
number of unsuccessful lookups: 21 (36.21%)
|
|
number of hash table allocations: 1
|
|
number of bytes allocated for hash tables: 536
|
|
number of bulk hash link allocations: 1
|
|
number of bytes allocated for hash links: 3,080
|
|
number of key compares when unsuccessful: 0
|
|
number of key compares when successful: 37
|
|
number of hash table resizes: 0
|
|
|
|
Call table difference (curr - prev) for mfib, test 11 to 20:
|
|
number of lookups: 30
|
|
number of successful lookups (old calls): 20 (66.67%)
|
|
number of unsuccessful lookups (new calls): 10 (33.33%)
|
|
statistics for the individual steps:
|
|
|
|
step 1, variable N: hash table
|
|
number of lookups: 30
|
|
number of successful lookups: 20 (66.67%)
|
|
number of unsuccessful lookups: 10 (33.33%)
|
|
number of hash table allocations: 0
|
|
number of bytes allocated for hash tables: 0
|
|
number of bulk hash link allocations: 0
|
|
number of bytes allocated for hash links: 0
|
|
number of key compares when unsuccessful: 0
|
|
number of key compares when successful: 20
|
|
number of hash table resizes: 0
|
|
|