diff --git a/docs/BasicInformKit/S-mst.html b/docs/BasicInformKit/S-mst.html index f9665b1b1..36b0f28f0 100644 --- a/docs/BasicInformKit/S-mst.html +++ b/docs/BasicInformKit/S-mst.html @@ -242,28 +242,17 @@ where it is to be written, of course: that would corrupt the sentinel.

§8. Rulebook Variables. Each rulebook has a slate of variables, usually empty, with ID number the same as the rulebook's own ID number. (Rulebook IDs number upwards from 0 -in order of creation in the source text.) The associated creator functions, -usually null, are stored in an array if there is no problem about memory -usage, but with a switch statement if MEMORY_ECONOMY is in force; this -costs a very small amount of time, but saves 1K of readable memory. +in order of creation in the source text.)

 [ MStack_CreateRBVars rb cr;
-    #ifdef MEMORY_ECONOMY;
     cr = MStack_GetRBVarCreator(rb);
-    #ifnot;
-    cr = rulebook_var_creators-->rb;
-    #endif;
     if (cr) Mstack_Create_Frame(cr, rb);
 ];
 
 [ MStack_DestroyRBVars rb cr;
-    #ifdef MEMORY_ECONOMY;
     cr = MStack_GetRBVarCreator(rb);
-    #ifnot;
-    cr = rulebook_var_creators-->rb;
-    #endif;
     if (cr) Mstack_Destroy_Frame(cr, rb);
 ];
 
diff --git a/docs/BasicInformKit/S-rlb.html b/docs/BasicInformKit/S-rlb.html index f0d57bf3e..911204c45 100644 --- a/docs/BasicInformKit/S-rlb.html +++ b/docs/BasicInformKit/S-rlb.html @@ -168,12 +168,10 @@ or failed if — spv = parameter_value; parameter_value = parameter; we won't need parameter again, so can reuse it parameter = debugging_rules; - #ifndef MEMORY_ECONOMY; if (debugging_rules) { DebugRulebooks(rulebook, parameter); process_rulebook_count = process_rulebook_count + debugging_rules; } - #endif; if ((rulebook >= 0) && (rulebook < NUMBER_RULEBOOKS_CREATED)) { rv = rulebooks_array-->rulebook; if (rv ~= EMPTY_RULEBOOK) { @@ -191,7 +189,6 @@ or failed if — else if (rv) rv = rulebook; } if (rv) { - #ifndef MEMORY_ECONOMY; if (debugging_rules) { process_rulebook_count = process_rulebook_count - debugging_rules; if (process_rulebook_count < 0) process_rulebook_count = 0; @@ -199,7 +196,6 @@ or failed if — if (latest_rule_result-->0 == RS_SUCCEEDS) print "[stopped: success]^"; if (latest_rule_result-->0 == RS_FAILS) print "[stopped: fail]^"; } - #endif; } else { if (debugging_rules) process_rulebook_count = process_rulebook_count - debugging_rules; diff --git a/docs/WorldModelKit/S-act.html b/docs/WorldModelKit/S-act.html index b3f534303..4554f829e 100644 --- a/docs/WorldModelKit/S-act.html +++ b/docs/WorldModelKit/S-act.html @@ -471,11 +471,9 @@ more discussion of this. switch (rv) { RS_SUCCEEDS: print "succeeded"; RS_FAILS: print "failed"; - #IFNDEF MEMORY_ECONOMY; if (reason_the_action_failed) print " the ", (RulePrintingRule) reason_the_action_failed; - #ENDIF; default: print "ended without result"; } print "]^"; say__p = 1; diff --git a/docs/pipeline-module/5-rls.html b/docs/pipeline-module/5-rls.html index 1bf76a3b3..b1ea44860 100644 --- a/docs/pipeline-module/5-rls.html +++ b/docs/pipeline-module/5-rls.html @@ -80,10 +80,14 @@ compiler. if (me_s) economy = InterSymbol::evaluate_to_int(me_s); Define NUMBER_RULEBOOKS_CREATED1.2; Define RulebookNames array1.3; - if (economy) Define SlowLookup function1.6 - else Define rulebook_var_creators array1.4; + if (economy) { + Define SlowLookup function1.7; + } else { + Define faster SlowLookup function1.6; + Define rulebook_var_creators array1.4; + } Define rulebooks_array array1.5; - Define RULEPRINTINGRULE function1.7; + Define RULEPRINTINGRULE function1.8; }

§1.1. Each rulebook package contains a numeric constant with the symbol name rulebook_id. @@ -163,7 +167,25 @@ so we change the values of these constants accordingly. Synoptic::end_array(I);

-

§1.6. Define SlowLookup function1.6 = +

§1.6. Define faster SlowLookup function1.6 = +

+ +
+    inter_name *iname = HierarchyLocations::iname(I, SLOW_LOOKUP_HL);
+    Synoptic::begin_function(I, iname);
+    inter_symbol *rb_s = Synoptic::local(I, I"rb", NULL);
+    Produce::inv_primitive(I, RETURN_BIP);
+    Produce::down(I);
+        Produce::inv_primitive(I, LOOKUP_BIP);
+        Produce::down(I);
+            Produce::val_iname(I, K_value, HierarchyLocations::iname(I, RULEBOOK_VAR_CREATORS_HL));
+            Produce::val_symbol(I, K_value, rb_s);
+        Produce::up(I);
+    Produce::up(I);
+    Synoptic::end_function(I, step, iname);
+
+ +

§1.7. Define SlowLookup function1.7 =

@@ -202,7 +224,7 @@ so we change the values of these constants accordingly.
     Synoptic::end_function(I, step, iname);
 
-

§1.7. Define RULEPRINTINGRULE function1.7 = +

§1.8. Define RULEPRINTINGRULE function1.8 =

@@ -228,17 +250,17 @@ so we change the values of these constants accordingly.
         Produce::up(I);
         Produce::code(I);
         Produce::down(I);
-            Print a rulebook name1.7.1;
+            Print a rulebook name1.8.1;
         Produce::up(I);
         Produce::code(I);
         Produce::down(I);
-            Print a rule name1.7.2;
+            Print a rule name1.8.2;
         Produce::up(I);
     Produce::up(I);
     Synoptic::end_function(I, step, iname);
 
-

§1.7.1. Print a rulebook name1.7.1 = +

§1.8.1. Print a rulebook name1.8.1 =

@@ -266,8 +288,8 @@ so we change the values of these constants accordingly.
         Produce::up(I);
     }
 
- -

§1.7.2. Print a rule name1.7.2 = +

+

§1.8.2. Print a rule name1.8.2 =

@@ -321,7 +343,7 @@ so we change the values of these constants accordingly.
         Produce::up(I);
     }
 
- + diff --git a/docs/pipeline-module/5-su.html b/docs/pipeline-module/5-su.html index b0c884e95..a6c3da214 100644 --- a/docs/pipeline-module/5-su.html +++ b/docs/pipeline-module/5-su.html @@ -122,10 +122,10 @@ does exist, it must have a definition, and we return that.
 inter_package *synoptic_fn_package = NULL;
 packaging_state synoptic_fn_ps;
-void Synoptic::begin_function(inter_tree *I, inter_name *iname) {
+void Synoptic::begin_function(inter_tree *I, inter_name *iname) {
     synoptic_fn_package = Produce::function_body(I, &synoptic_fn_ps, iname);
 }
-void Synoptic::end_function(inter_tree *I, pipeline_step *step, inter_name *iname) {
+void Synoptic::end_function(inter_tree *I, pipeline_step *step, inter_name *iname) {
     Produce::end_function_body(I);
     Packaging::exit(I, synoptic_fn_ps);
 }
@@ -134,7 +134,7 @@ does exist, it must have a definition, and we return that.
 

-inter_symbol *Synoptic::local(inter_tree *I, text_stream *name, text_stream *comment) {
+inter_symbol *Synoptic::local(inter_tree *I, text_stream *name, text_stream *comment) {
     return Produce::local(I, K_value, name, comment);
 }
 
diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index 3b6473b61..f0381f3cd 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,10 +1,10 @@ Total memory consumption was 120953K = 118 MB - ---- was used for 2048032 objects, in 364569 frames in 0 x 800K = 0K = 0 MB: + ---- was used for 2048036 objects, in 364573 frames in 0 x 800K = 0K = 0 MB: 33.7% inter_tree_node_array 58 x 8192 = 475136 objects, 41813824 bytes 20.9% text_stream_array 4616 x 100 = 461600 objects, 25997312 bytes - 19.8% linked_list 43887 objects, 24576720 bytes + 19.8% linked_list 43888 objects, 24577280 bytes 11.3% inter_symbol_array 132 x 1024 = 135168 objects, 14061696 bytes 10.6% inter_error_stash_array 101 x 1024 = 103424 objects, 13241504 bytes 8.3% parse_node 129712 objects, 10376960 bytes @@ -20,9 +20,9 @@ Total memory consumption was 120953K = 118 MB 1.4% vocabulary_entry_array 161 x 100 = 16100 objects, 1808352 bytes 1.2% dict_entry_array 473 x 100 = 47300 objects, 1528736 bytes 1.2% match_trie_array 11 x 1000 = 11000 objects, 1496352 bytes - 1.2% inter_symbols_table 26592 objects, 1489152 bytes + 1.2% inter_symbols_table 26593 objects, 1489208 bytes 1.1% i6_schema_array 23 x 100 = 2300 objects, 1380736 bytes - 1.0% inter_package 26592 objects, 1276416 bytes + 1.0% inter_package 26593 objects, 1276464 bytes 0.9% map_data 671 objects, 1127280 bytes 0.8% id_body 942 objects, 1077648 bytes 0.8% adjective_meaning 202 objects, 1000304 bytes @@ -42,7 +42,7 @@ Total memory consumption was 120953K = 118 MB 0.2% compilation_subtask 3355 objects, 268400 bytes 0.2% inter_annotation_array 2 x 8192 = 16384 objects, 262208 bytes 0.2% inference_subject 666 objects, 261072 bytes - 0.1% vanilla_function 3683 objects, 235712 bytes + 0.1% vanilla_function 3684 objects, 235776 bytes 0.1% binary_predicate 322 objects, 170016 bytes 0.1% hierarchy_location 1124 objects, 161856 bytes 0.1% linguistic_stock_item 3318 objects, 159264 bytes @@ -247,7 +247,7 @@ Total memory consumption was 120953K = 118 MB 100.0% was used for memory not allocated for objects: - 56.8% text stream storage 70350844 bytes in 478783 claims + 56.8% text stream storage 70350608 bytes in 478781 claims 4.2% dictionary storage 5297152 bytes in 7590 claims ---- sorting 1520 bytes in 159 claims 5.8% source text 7200000 bytes in 3 claims @@ -255,7 +255,7 @@ Total memory consumption was 120953K = 118 MB 0.2% documentation fragments 262144 bytes in 1 claim ---- linguistic stock array 81920 bytes in 2 claims ---- small word set array 105600 bytes in 22 claims - 3.6% inter symbols storage 4553008 bytes in 27952 claims + 3.6% inter symbols storage 4553136 bytes in 27953 claims 13.5% inter bytecode storage 16767568 bytes in 14 claims 5.0% inter links storage 6222976 bytes in 11 claims 0.1% inter tree location list storage 191232 bytes in 32 claims @@ -265,5 +265,5 @@ Total memory consumption was 120953K = 118 MB ---- code generation workspace for objects 3480 bytes in 19 claims 0.2% emitter array storage 280288 bytes in 1999 claims --150.0% was overhead - -185886160 bytes = -181529K = -177 MB +-150.0% was overhead - -185886888 bytes = -181530K = -177 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index ecb19e40d..d68c47421 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,33 +1,34 @@ 100.0% in inform7 run - 71.2% in compilation to Inter - 50.9% in //Sequence::undertake_queued_tasks// + 71.0% in compilation to Inter + 50.6% in //Sequence::undertake_queued_tasks// 4.6% in //MajorNodes::pre_pass// 3.5% in //MajorNodes::pass_1// - 1.9% in //ImperativeDefinitions::assess_all// + 1.8% in //ImperativeDefinitions::assess_all// 1.4% in //RTKindConstructors::compile// 1.4% in //RTPhrasebook::compile_entries// - 1.0% in //Sequence::lint_inter// - 0.6% in //MajorNodes::pass_2// - 0.6% in //World::stage_V// - 0.4% in //ImperativeDefinitions::compile_first_block// - 0.4% in //Sequence::undertake_queued_tasks// - 0.4% in //Sequence::undertake_queued_tasks// - 0.2% in //CompletionModule::compile// - 0.2% in //InferenceSubjects::emit_all// - 0.2% in //RTKindConstructors::compile_permissions// - 0.2% in //Task::make_built_in_kind_constructors// - 0.2% in //World::stages_II_and_III// - 2.5% not specifically accounted for - 25.7% in running Inter pipeline - 10.1% in step 14/15: generate inform6 -> auto.inf + 1.1% in //Sequence::lint_inter// + 0.5% in //MajorNodes::pass_2// + 0.5% in //Sequence::undertake_queued_tasks// + 0.5% in //World::stage_V// + 0.3% in //ImperativeDefinitions::compile_first_block// + 0.3% in //Sequence::undertake_queued_tasks// + 0.1% in //CompletionModule::compile// + 0.1% in //InferenceSubjects::emit_all// + 0.1% in //RTKindConstructors::compile_permissions// + 0.1% in //Task::make_built_in_kind_constructors// + 0.1% in //World::stages_II_and_III// + 2.8% not specifically accounted for + 25.9% in running Inter pipeline + 10.0% in step 14/15: generate inform6 -> auto.inf 5.7% in step 5/15: load-binary-kits - 5.4% in step 6/15: make-synoptic-module + 5.6% in step 6/15: make-synoptic-module 1.4% in step 9/15: make-identifiers-unique - 0.4% in step 12/15: eliminate-redundant-operations - 0.4% in step 4/15: compile-splats - 0.4% in step 7/15: shorten-wiring - 0.2% in step 11/15: eliminate-redundant-labels - 0.2% in step 8/15: detect-indirect-calls - 1.2% not specifically accounted for - 2.5% in supervisor - 0.5% not specifically accounted for + 0.5% in step 4/15: compile-splats + 0.3% in step 12/15: eliminate-redundant-operations + 0.3% in step 7/15: shorten-wiring + 0.3% in step 8/15: detect-indirect-calls + 0.1% in step 10/15: reconcile-verbs + 0.1% in step 11/15: eliminate-redundant-labels + 0.9% not specifically accounted for + 2.6% in supervisor + 0.4% not specifically accounted for diff --git a/inform7/Internal/Inter/BasicInformKit/Sections/MStack.i6t b/inform7/Internal/Inter/BasicInformKit/Sections/MStack.i6t index 300215d00..76aad41a6 100644 --- a/inform7/Internal/Inter/BasicInformKit/Sections/MStack.i6t +++ b/inform7/Internal/Inter/BasicInformKit/Sections/MStack.i6t @@ -176,27 +176,16 @@ where it is to be written, of course: that would corrupt the sentinel. @h Rulebook Variables. Each rulebook has a slate of variables, usually empty, with ID number the same as the rulebook's own ID number. (Rulebook IDs number upwards from 0 -in order of creation in the source text.) The associated creator functions, -usually null, are stored in an array if there is no problem about memory -usage, but with a switch statement if |MEMORY_ECONOMY| is in force; this -costs a very small amount of time, but saves 1K of readable memory. +in order of creation in the source text.) = [ MStack_CreateRBVars rb cr; - #ifdef MEMORY_ECONOMY; cr = MStack_GetRBVarCreator(rb); - #ifnot; - cr = rulebook_var_creators-->rb; - #endif; if (cr) Mstack_Create_Frame(cr, rb); ]; [ MStack_DestroyRBVars rb cr; - #ifdef MEMORY_ECONOMY; cr = MStack_GetRBVarCreator(rb); - #ifnot; - cr = rulebook_var_creators-->rb; - #endif; if (cr) Mstack_Destroy_Frame(cr, rb); ]; diff --git a/inform7/Internal/Inter/BasicInformKit/Sections/Rulebooks.i6t b/inform7/Internal/Inter/BasicInformKit/Sections/Rulebooks.i6t index e892e8932..c629c6f06 100644 --- a/inform7/Internal/Inter/BasicInformKit/Sections/Rulebooks.i6t +++ b/inform7/Internal/Inter/BasicInformKit/Sections/Rulebooks.i6t @@ -98,12 +98,10 @@ Global debugging_rules = false; ! Are we tracing rule invocations? spv = parameter_value; parameter_value = parameter; ! we won't need parameter again, so can reuse it parameter = debugging_rules; - #ifndef MEMORY_ECONOMY; if (debugging_rules) { DebugRulebooks(rulebook, parameter); process_rulebook_count = process_rulebook_count + debugging_rules; } - #endif; if ((rulebook >= 0) && (rulebook < NUMBER_RULEBOOKS_CREATED)) { rv = rulebooks_array-->rulebook; if (rv ~= EMPTY_RULEBOOK) { @@ -121,7 +119,6 @@ Global debugging_rules = false; ! Are we tracing rule invocations? else if (rv) rv = rulebook; } if (rv) { - #ifndef MEMORY_ECONOMY; if (debugging_rules) { process_rulebook_count = process_rulebook_count - debugging_rules; if (process_rulebook_count < 0) process_rulebook_count = 0; @@ -129,7 +126,6 @@ Global debugging_rules = false; ! Are we tracing rule invocations? if (latest_rule_result-->0 == RS_SUCCEEDS) print "[stopped: success]^"; if (latest_rule_result-->0 == RS_FAILS) print "[stopped: fail]^"; } - #endif; } else { if (debugging_rules) process_rulebook_count = process_rulebook_count - debugging_rules; diff --git a/inform7/Internal/Inter/WorldModelKit/Sections/Actions.i6t b/inform7/Internal/Inter/WorldModelKit/Sections/Actions.i6t index f48e48d3e..b7f629905 100644 --- a/inform7/Internal/Inter/WorldModelKit/Sections/Actions.i6t +++ b/inform7/Internal/Inter/WorldModelKit/Sections/Actions.i6t @@ -394,11 +394,9 @@ more discussion of this. switch (rv) { RS_SUCCEEDS: print "succeeded"; RS_FAILS: print "failed"; - #IFNDEF MEMORY_ECONOMY; if (reason_the_action_failed) print " the ", (RulePrintingRule) reason_the_action_failed; - #ENDIF; default: print "ended without result"; } print "]^"; say__p = 1; diff --git a/inter/pipeline-module/Chapter 5/Rules.w b/inter/pipeline-module/Chapter 5/Rules.w index 8c4414f25..231c9cb4a 100644 --- a/inter/pipeline-module/Chapter 5/Rules.w +++ b/inter/pipeline-module/Chapter 5/Rules.w @@ -21,8 +21,12 @@ void SynopticRules::compile(inter_tree *I, pipeline_step *step, tree_inventory * if (me_s) economy = InterSymbol::evaluate_to_int(me_s); @; @; - if (economy) @ - else @; + if (economy) { + @; + } else { + @; + @; + } @; @; } @@ -83,6 +87,20 @@ so we change the values of these constants accordingly. Synoptic::numeric_entry(0); Synoptic::end_array(I); +@ = + inter_name *iname = HierarchyLocations::iname(I, SLOW_LOOKUP_HL); + Synoptic::begin_function(I, iname); + inter_symbol *rb_s = Synoptic::local(I, I"rb", NULL); + Produce::inv_primitive(I, RETURN_BIP); + Produce::down(I); + Produce::inv_primitive(I, LOOKUP_BIP); + Produce::down(I); + Produce::val_iname(I, K_value, HierarchyLocations::iname(I, RULEBOOK_VAR_CREATORS_HL)); + Produce::val_symbol(I, K_value, rb_s); + Produce::up(I); + Produce::up(I); + Synoptic::end_function(I, step, iname); + @ = inter_name *iname = HierarchyLocations::iname(I, SLOW_LOOKUP_HL); Synoptic::begin_function(I, iname);