Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📦 NEW: Add hashful to info output #343

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ impl Arena {
}
}

pub fn full(&self) -> bool {
pub fn full(&self) -> usize {
self.owned_mappings.lock().unwrap().len() * 1000 / self.max_chunks
}

pub fn is_full(&self) -> bool {
let owned_mappings = self.owned_mappings.lock().unwrap();
owned_mappings.len() > self.max_chunks
}
Expand Down
6 changes: 4 additions & 2 deletions src/search_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ impl SearchTree {
let new_node = match self.descend(&state, choice, tld) {
Ok(r) => r,
Err(ArenaError::Full) => {
self.ttable.flip_if_full(|| self.root_node.clear_children_links());
self.ttable
.flip_if_full(|| self.root_node.clear_children_links());
return true;
}
};
Expand Down Expand Up @@ -499,12 +500,13 @@ impl SearchTree {
let eval = eval_in_cp(edge.reward().average as f32 / SCALE);

let info_str = format!(
"info depth {} seldepth {} nodes {} nps {} tbhits {} score {} time {} multipv {} pv {}",
"info depth {} seldepth {} nodes {} nps {} tbhits {} hashful {} score {} time {} multipv {} pv {}",
depth.max(1),
sel_depth.max(1),
nodes,
nps,
self.tb_hits(),
self.ttable.full(),
eval,
search_time_ms,
idx + 1,
Expand Down
11 changes: 10 additions & 1 deletion src/transposition_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ impl TranspositionTable {
Self { table, arena }
}

#[must_use]
pub fn full(&self) -> usize {
self.arena.full()
}

#[must_use]
pub fn arena(&self) -> &Arena {
&self.arena
Expand Down Expand Up @@ -109,6 +114,10 @@ impl LRTable {
Self::new(TranspositionTable::empty(), TranspositionTable::empty())
}

pub fn full(&self) -> usize {
(self.left.arena().full() + self.right.arena().full()) / 2
}

pub fn insert<'a>(&'a self, key: &State, value: &'a PositionNode) -> &'a PositionNode {
self.current_table().insert(key, value)
}
Expand Down Expand Up @@ -170,7 +179,7 @@ impl LRTable {
{
let _lock = self.flip_lock.lock().unwrap();

if self.current_table().arena().full() {
if self.current_table().arena().is_full() {
self.flip_tables();
f();
}
Expand Down
Loading