Skip to content

Commit

Permalink
Disable statistics tracking of virtual visits by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
dje-dev committed Sep 26, 2021
1 parent 629e4e2 commit cef9465
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/Ceres.MCTS/Evaluators/LeafEvaluatorTransposition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ namespace Ceres.MCTS.Evaluators
/// </summary>
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;
Expand Down
5 changes: 4 additions & 1 deletion src/Ceres.MCTS/MCTSNodes/Struct/MCTSNodeStructClone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
5 changes: 4 additions & 1 deletion src/Ceres.MCTS/Search/MCTSApply.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ void ApplyResult(Span<MCTSNodeStruct> 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;
Expand Down

0 comments on commit cef9465

Please sign in to comment.