diff --git a/src/Ceres.MCTS/Evaluators/LeafEvaluatorTransposition.cs b/src/Ceres.MCTS/Evaluators/LeafEvaluatorTransposition.cs index 294f6490..3b05e9af 100644 --- a/src/Ceres.MCTS/Evaluators/LeafEvaluatorTransposition.cs +++ b/src/Ceres.MCTS/Evaluators/LeafEvaluatorTransposition.cs @@ -37,6 +37,13 @@ namespace Ceres.MCTS.Evaluators /// public sealed partial class LeafEvaluatorTransposition : LeafEvaluatorBase { + // If TestMetric and TestCounter should track the number of + // virtual visits whih obviate node allocation (TestCounter1) + // and also the number of nodes which subsequently had to be materialized (TestMetric) + // and were therefore not ultimately actual memory savings. + // Disabled by default due to performance impact (especially due to false sharing). + internal const bool TRACK_VIRTUAL_VISITS = false; + // TODO: Transposition counts temporarily disabled for performance reasons (false sharing) static ulong NumHits = 0; static ulong NumMisses = 0; diff --git a/src/Ceres.MCTS/MCTSNodes/Struct/MCTSNodeStructClone.cs b/src/Ceres.MCTS/MCTSNodes/Struct/MCTSNodeStructClone.cs index f53ac823..85e6ba4d 100644 --- a/src/Ceres.MCTS/MCTSNodes/Struct/MCTSNodeStructClone.cs +++ b/src/Ceres.MCTS/MCTSNodes/Struct/MCTSNodeStructClone.cs @@ -161,7 +161,10 @@ public static MCTSNodeStructIndex TryCloneChild(MCTSTree tree, // TODO: avoid ChildAtIndex to avoid dictionary lookup? targetChildRef.CopyUnexpandedChildrenFromOtherNode(tree, new MCTSNodeStructIndex(sourceChildRef.Index.Index)); - MCTSEventSource.TestMetric1++; + if (LeafEvaluatorTransposition.TRACK_VIRTUAL_VISITS) + { + MCTSEventSource.TestMetric1++; + } Debug.Assert(!double.IsNaN(sourceParentRef.W)); Debug.Assert(!double.IsNaN(sourceChildRef.W)); diff --git a/src/Ceres.MCTS/Search/MCTSApply.cs b/src/Ceres.MCTS/Search/MCTSApply.cs index a641c199..ba156751 100644 --- a/src/Ceres.MCTS/Search/MCTSApply.cs +++ b/src/Ceres.MCTS/Search/MCTSApply.cs @@ -237,7 +237,10 @@ void ApplyResult(Span nodes, int selectorID, MCTSNode node, Leaf numToApply = Math.Min(nodeRef.NumVisitsPendingTranspositionRootExtraction, numToApply); // Increment count of number of "extra" (beyond 1) values used without tree replication. - if (nodeRef.NumVisitsPendingTranspositionRootExtraction > 1) MCTSEventSource.TestCounter1++; + if (LeafEvaluatorTransposition.TRACK_VIRTUAL_VISITS && nodeRef.NumVisitsPendingTranspositionRootExtraction > 1) + { + MCTSEventSource.TestCounter1++; + } // Switch to propagate this "pseudo V" for this node and all nodes above vToApply = node.PendingTranspositionV;