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: Use scc map #345

Merged
merged 1 commit into from
Sep 1, 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
163 changes: 23 additions & 140 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ path = "src/main.rs"
[dependencies]
arc-swap = "=1.6.0"
arrayvec = "=0.7.4"
dashmap = "=5.5.3"
fastapprox = "=0.3.1"
goober = { git = "https://github.com/jw1912/goober/", rev = "32b9b52" }
nohash-hasher = "=0.2.0"
memmap = "=0.7.0"
scc = "=2.1.16"
scoped_threadpool = "=0.1.9"

[features]
Expand Down
2 changes: 1 addition & 1 deletion src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Arena {
}

pub fn allocator(&self) -> Allocator {
let id = IDS.fetch_add(1, Ordering::SeqCst);
let id = IDS.fetch_add(1, Ordering::Relaxed);

Allocator {
id,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

extern crate arc_swap;
extern crate arrayvec;
extern crate dashmap;
extern crate fastapprox;
extern crate memmap;
extern crate nohash_hasher;
extern crate scc;

mod arena;
mod mem;
Expand Down
10 changes: 4 additions & 6 deletions src/search_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl PositionNode {
let hots = unsafe { &*(self.hots.cast_mut()) };

for h in hots {
h.child.store(null_mut(), Ordering::SeqCst);
h.child.store(null_mut(), Ordering::Relaxed);
}
}

Expand Down Expand Up @@ -432,16 +432,14 @@ impl SearchTree {
self.search_options.mcts_options.policy_temperature,
)?;

// Copy any history
self.ttable.lookup_into(state, &mut created_here);

// Copy node to arena memory
let created = tld.allocator.alloc_node()?;

*created = created_here;

if let Some(node) = choice.set_or_get_child(created) {
return Ok(node);
}

// Insert the child into the ttable
let inserted = self.ttable.insert(state, created);
let inserted_ptr = ptr::from_ref(inserted).cast_mut();
choice.child.store(inserted_ptr, Ordering::Relaxed);
Expand Down
Loading
Loading