JaffarPlus
High-performance best-first search optimizer for tool-assisted speedruns
Loading...
Searching...
No Matches
inputHistoryFactory.hpp File Reference

Builds the configured InputHistory strategy from the "Store Input History" config object. More...

#include "inputHistory.hpp"
#include "inputHistoryNone.hpp"
#include "inputHistoryRaw.hpp"
#include "inputHistoryTrie.hpp"
#include <jaffarCommon/exceptions.hpp>
#include <jaffarCommon/json.hpp>

Go to the source code of this file.

Functions

std::string jaffarPlus::inputHistory::getType (const nlohmann::json &config)
 The configured strategy name ("None" | "Raw" | "Trie").
 
std::shared_ptr< void > jaffarPlus::inputHistory::createSharedBacking (const nlohmann::json &config, const uint32_t numShards)
 Creates the shared backing for the configured strategy (the trie for "Trie"; nullptr otherwise).
 
size_t jaffarPlus::inputHistory::getSharedBackingMaxMemoryBytes (const std::shared_ptr< void > &backing)
 Hard upper bound (bytes) on the shared backing's memory: the trie's node-storage ceiling for the "Trie" strategy, 0 for None/Raw (their per-state history lives in the StateDb slot, already budgeted).
 
size_t jaffarPlus::inputHistory::getSharedBackingApproxMemoryBytes (const std::shared_ptr< void > &backing)
 Current (approximate) live memory of the shared backing: the trie's node-storage footprint for the "Trie" strategy, 0 for None/Raw.
 
bool jaffarPlus::inputHistory::isSharedBackingExhausted (const std::shared_ptr< void > &backing)
 True if the shared backing (the trie) has hit its hard node-storage ceiling.
 
std::unique_ptr< InputHistoryjaffarPlus::inputHistory::create (const nlohmann::json &config, const uint32_t maxInputIndex, const uint32_t numShards, const uint32_t shardId, const std::shared_ptr< void > &backing)
 Creates one runner's input-history instance bound to backing.
 

Detailed Description

Builds the configured InputHistory strategy from the "Store Input History" config object.

The shared backing (the trie, for the "Trie" strategy) is created once per search via createSharedBacking() and then bound into each runner's instance via create(). None/Raw have no shared backing. Default type when unspecified: "Trie".

Definition in file inputHistoryFactory.hpp.

Function Documentation

◆ create()

std::unique_ptr< InputHistory > jaffarPlus::inputHistory::create ( const nlohmann::json &  config,
const uint32_t  maxInputIndex,
const uint32_t  numShards,
const uint32_t  shardId,
const std::shared_ptr< void > &  backing 
)

Creates one runner's input-history instance bound to backing.

Parameters
configThe "Store Input History" configuration object ("Type" plus any per-strategy keys).
maxInputIndexOne past the highest input index (per-step bit width for raw/snapshot encoding).
numShardsShard count the backing was created with (the last shard is the manager shard).
shardIdThis runner's free-list shard (its worker thread id; 0 for standalone runners).
backingThe shared handle from createSharedBacking() (ignored by None/Raw).

Definition at line 75 of file inputHistoryFactory.hpp.

◆ createSharedBacking()

std::shared_ptr< void > jaffarPlus::inputHistory::createSharedBacking ( const nlohmann::json &  config,
const uint32_t  numShards 
)

Creates the shared backing for the configured strategy (the trie for "Trie"; nullptr otherwise).

Parameters
configThe "Store Input History" configuration object (its "Type" selects the strategy).
numShardsNumber of contention-free free-list shards (one per worker thread + one for the StateDb/driver manager operations).
Returns
An opaque shared handle held by the caller for the lifetime of the search; pass it to create().

Definition at line 35 of file inputHistoryFactory.hpp.

◆ getSharedBackingApproxMemoryBytes()

size_t jaffarPlus::inputHistory::getSharedBackingApproxMemoryBytes ( const std::shared_ptr< void > &  backing)

Current (approximate) live memory of the shared backing: the trie's node-storage footprint for the "Trie" strategy, 0 for None/Raw.

The driver polls this against the ceiling to stop gracefully before the trie's hard cap is hit.

Definition at line 53 of file inputHistoryFactory.hpp.

◆ getSharedBackingMaxMemoryBytes()

size_t jaffarPlus::inputHistory::getSharedBackingMaxMemoryBytes ( const std::shared_ptr< void > &  backing)

Hard upper bound (bytes) on the shared backing's memory: the trie's node-storage ceiling for the "Trie" strategy, 0 for None/Raw (their per-state history lives in the StateDb slot, already budgeted).

Used by the engine's RAM guard to account for this otherwise-uncounted, unbounded-growth structure.

Definition at line 44 of file inputHistoryFactory.hpp.

◆ getType()

std::string jaffarPlus::inputHistory::getType ( const nlohmann::json &  config)

The configured strategy name ("None" | "Raw" | "Trie").

Required – JaffarPlus configs must set every option explicitly, so an absent "Type" is an error (thrown by the strict accessor).

Definition at line 26 of file inputHistoryFactory.hpp.

◆ isSharedBackingExhausted()

bool jaffarPlus::inputHistory::isSharedBackingExhausted ( const std::shared_ptr< void > &  backing)

True if the shared backing (the trie) has hit its hard node-storage ceiling.

False for None/Raw (which have no such ceiling – their history lives in the StateDb slot, already budgeted).

Definition at line 61 of file inputHistoryFactory.hpp.