Skip to content

Commit

Permalink
chore: Store progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillbobyrev committed Jun 24, 2024
1 parent 157c112 commit a1dd724
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 240 deletions.
30 changes: 0 additions & 30 deletions CHANGELOG.md

This file was deleted.

8 changes: 4 additions & 4 deletions Cargo.lock

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

14 changes: 2 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,12 @@ name = "cycles"
harness = false
name = "time"

# This is not the most perofrmmance-optimized profile. Use `fast` instead. Read
# BUILDING.md for more information.
[profile.release]
panic = "abort"
# Needed for cargo flamegraph.
debug = true

# TODO: Test this out once the benchmarks are available and tweak specific
# values. So far, this gives around -8% on parsing FEN/EPD positions.
[profile.fast]
debug = false
[profile.release]
codegen-units = 1
inherits = "release"
lto = "fat"
panic = "abort"
strip = true
# TODO: Oh-oh, this is dangerous! Maybe measure if it gives any benefits.
# overflow-checks = false
# TODO: Tweak inline-threshold.
# TODO: Set profile-generate and profile-use (https://github.com/kirillbobyrev/pabi/issues/9).
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ COMPILE_FLAGS := RUSTFLAGS='-C target-feature=+avx2,+fma,+bmi1,+bmi2'

# Compile the target and add a link to the binary for OpenBench to pick up.
openbench:
$(COMPILE_FLAGS) cargo rustc --profile=fast --bin=pabi -- --emit link=$(EXE)$(EXE_SUFFIX)
$(COMPILE_FLAGS) cargo rustc --profile=release --bin=pabi -- --emit link=$(EXE)$(EXE_SUFFIX)

.PHONY: openbench
9 changes: 6 additions & 3 deletions benches/cycles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ use std::fs;
use pabi::chess::position::Position;

fn parse_stockfish_book_positions() {
for line in fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/data/positions.fen"))
.unwrap()
.lines()
for line in fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/data/positions.fen"
))
.unwrap()
.lines()
{
iai::black_box(Position::try_from(line).expect("benchmarks are given valid positions"));
}
Expand Down
31 changes: 20 additions & 11 deletions benches/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ use shakmaty::{CastlingMode, Chess, Position as ShakmatyPosition};

// TODO: Add Throughput.
fn parse(c: &mut Criterion) {
let positions = fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/data/positions.fen"))
.unwrap()
.lines()
.map(ToString::to_string)
.collect::<Vec<_>>();
let positions = fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/data/positions.fen"
))
.unwrap()
.lines()
.map(ToString::to_string)
.collect::<Vec<_>>();
c.bench_with_input(
BenchmarkId::new(
"stockfish books",
Expand Down Expand Up @@ -46,9 +49,12 @@ fn generate_moves(positions: &[Position]) {
fn movegen_bench(c: &mut Criterion) {
let mut group = c.benchmark_group("Move generation");
let mut positions = vec![];
for line in fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/data/positions.fen"))
.unwrap()
.lines()
for line in fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/data/positions.fen"
))
.unwrap()
.lines()
{
positions.push(Position::try_from(line).unwrap());
}
Expand All @@ -69,9 +75,12 @@ fn movegen_bench(c: &mut Criterion) {
// it's not important to be faster than this but it's an important reference
// point.
let mut shakmaty_positions = Vec::<Chess>::new();
for line in fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/data/positions.fen"))
.unwrap()
.lines()
for line in fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/data/positions.fen"
))
.unwrap()
.lines()
{
let shakmaty_setup: shakmaty::fen::Fen = line.parse().unwrap();
shakmaty_positions.push(
Expand Down
15 changes: 8 additions & 7 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
compile_flags := "RUSTFLAGS='-C target-feature=+avx2,+fma,+bmi1,+bmi2'"

build:
{{ compile_flags }} cargo build --profile=fast
{{ compile_flags }} cargo build --profile=release

# Runs the engine and enters UCI mode.
run:
{{ compile_flags}} cargo run --profile=fast
{{ compile_flags}} cargo run --profile=release

fmt:
cargo +nightly fmt --all
Expand All @@ -24,19 +24,20 @@ fix:
cargo +nightly fmt --all
cargo +nightly clippy --all-targets --all-features --fix --allow-staged

# Run most tests that are fast and are run by default.
# Run most tests in debug mode to (potentially) cat more errors with
# debug_assert.
test:
{{ compile_flags }} cargo test --profile=fast
{{ compile_flags }} cargo test

# Run tests that are slow and are not run by default.
test_slow:
{{ compile_flags }} cargo test --profile=fast -- --ignored
{{ compile_flags }} cargo test --profile=release -- --ignored

# Run all tests.
test_all: test test_slow

bench:
{{ compile_flags }} cargo bench --profile=fast
{{ compile_flags }} cargo bench --profile=release

# Lists all fuzzing targets that can be used as inputs for fuzz command.
list_fuzz_targets:
Expand All @@ -45,7 +46,7 @@ list_fuzz_targets:

fuzz target:
cd fuzz
{{ compile_flags }} cargo +nightly --profile=fast fuzz run {{ target }}
{{ compile_flags }} cargo +nightly --profile=release fuzz run {{ target }}

# Play a single game between two engine versions in 2'+1'' format and save the
# game PGN.
Expand Down
Loading

0 comments on commit a1dd724

Please sign in to comment.