Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9c221b9
docs: Add plan and tasks for removing legacy threading dead code
zzcgumn Feb 23, 2026
bea8dad
refactor(ci): Remove broken perf_sample CI job
zzcgumn Feb 23, 2026
96493a2
Add deprecation notices to legacy initialization APIs
zzcgumn Feb 23, 2026
0231c1d
Remove Threading enum from test harness
zzcgumn Feb 23, 2026
3e42c39
Document legacy C API compatibility
zzcgumn Feb 23, 2026
4203496
Complete final verification checklist
zzcgumn Feb 23, 2026
c6d8c9a
Fix calc DD table consistency by reusing SolverContext across declarers
zzcgumn Feb 24, 2026
382dd48
Address PR feedback on naming and docs
zzcgumn Feb 24, 2026
9a58102
Update docs/legacy_c_api.md
zzcgumn Feb 24, 2026
048921b
Update examples/migration_example.cpp
zzcgumn Feb 24, 2026
9844676
Update examples/migration_example.cpp
zzcgumn Feb 24, 2026
f5939ec
Update README.md
zzcgumn Feb 24, 2026
49da607
moves remove dead code instruction, plan and tasks into their complet…
zzcgumn Feb 24, 2026
aa26e59
Update library/src/api/dll.h
zzcgumn Feb 25, 2026
4ca1ada
Address review feedback on API examples and documentation
zzcgumn Feb 25, 2026
b1c8f70
Update docs/api_migration.md
zzcgumn Feb 25, 2026
1e7868b
Update docs/api_migration.md
zzcgumn Feb 25, 2026
4788af5
Update examples/migration_example.cpp
zzcgumn Feb 25, 2026
e0fd2a1
Update docs/api_migration.md
zzcgumn Feb 25, 2026
5370a65
Update docs/api_migration.md
zzcgumn Feb 25, 2026
e0e9e95
Update docs/api_migration.md
zzcgumn Feb 25, 2026
a2449b3
Update README.md
zzcgumn Feb 25, 2026
607221d
Update docs/legacy_c_api.md
zzcgumn Feb 25, 2026
5f575f8
Fix remaining review comments
zzcgumn Feb 25, 2026
d2c1875
Update copilot/tasks/completed/remove_dead_code/02_add_deprecation_no…
zzcgumn Feb 25, 2026
4ef2333
Update copilot/tasks/completed/remove_dead_code/04_document_c_api_com…
zzcgumn Feb 25, 2026
985e17e
Update copilot/plans/completed/remove_dead_code.md
zzcgumn Feb 25, 2026
0214e75
Update library/src/calc_tables.cpp
zzcgumn Feb 26, 2026
dd91f31
Update library/src/calc_tables.cpp
zzcgumn Feb 26, 2026
d7ea501
Update library/tests/args.cpp
zzcgumn Feb 26, 2026
e5fa724
Update README.md
zzcgumn Feb 26, 2026
1423248
Update copilot/instructions/completed/remove_dead_code.md
zzcgumn Feb 26, 2026
425548e
Update library/src/calc_tables.cpp
zzcgumn Feb 26, 2026
f7565d2
Update docs/legacy_c_api.md
zzcgumn Feb 26, 2026
085673e
Update docs/api_migration.md
zzcgumn Feb 26, 2026
70bf701
Fix calc_tables.cpp: initialize fut and enhance reuse comment
zzcgumn Feb 27, 2026
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
55 changes: 0 additions & 55 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,58 +32,3 @@ jobs:
# 5️⃣ Run all tests
- name: Run all tests
run: bazelisk test //...

perf_sample:
name: Perf sampling (perf -> flamegraph)
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' }}
needs: build_and_test
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Bazelisk
uses: bazel-contrib/setup-bazel@0.15.0

- name: Install perf and tools
run: |
sudo apt-get update
# Install perf (linux-tools) and other helpers
sudo apt-get install -y linux-tools-common linux-tools-$(uname -r) perf git perl

- name: Relax perf restrictions (may require sudo)
run: sudo sysctl -w kernel.perf_event_paranoid=-1 || true

- name: Build dtest with symbols
run: bazelisk build //library/tests:dtest -c opt --copt=-g

- name: Run perf capture via helper script
run: |
chmod +x copilot/perf/run_sample.sh
./copilot/perf/run_sample.sh --no-build --duration 30 --bench hands/list100.txt --name ci-linux || true

- name: Post-process perf data (if present)
run: |
set -euo pipefail
ARTDIR=copilot/perf/artifacts
# Find newest .data file
DATA=$(ls -t ${ARTDIR}/*.data 2>/dev/null | head -n1 || true)
if [ -n "${DATA}" ]; then
echo "Found perf data: ${DATA}"
PERF_SCRIPT_OUT="${DATA%.data}.perf"
echo "Converting perf.data -> perf script (${PERF_SCRIPT_OUT})"
perf script -i "${DATA}" > "${PERF_SCRIPT_OUT}"
echo "Generating flamegraph (requires network to clone FlameGraph)"
git clone https://github.com/brendangregg/FlameGraph.git /tmp/FlameGraph
/tmp/FlameGraph/stackcollapse-perf.pl "${PERF_SCRIPT_OUT}" > "${PERF_SCRIPT_OUT}.folded"
/tmp/FlameGraph/flamegraph.pl "${PERF_SCRIPT_OUT}.folded" > "${PERF_SCRIPT_OUT}.svg"
echo "Flamegraph generated: ${PERF_SCRIPT_OUT}.svg"
else
echo "No perf .data file found in ${ARTDIR}; skipping post-processing"
fi

- name: Upload perf artifacts
uses: actions/upload-artifact@v4
with:
name: perf-artifacts
path: copilot/perf/artifacts/
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,73 @@ Please report bugs to bo.haglund@bahnhof.se and soren.hein@gmail.com.
Version 3.0.0, preliminary change log
====

To build with C api include `<api/dll.h>`, for the full C++ api use <dds/dds.hpp>
## API Documentation

DDS 3.0 provides two API levels to suit different use cases:

### Modern C++ API (Recommended for New Projects)

The modern API uses instance-scoped `SolverContext` with automatic resource management (RAII):

```cpp
#include <dds/dds.hpp>

auto main() -> int
{
// Configure solver
SolverConfig cfg;
cfg.tt_kind_ = TTKind::Large;
cfg.tt_mem_default_mb_ = 2000;
cfg.tt_mem_maximum_mb_ = 2000;

// Create context (automatic cleanup on destruction)
SolverContext ctx(cfg);

// Solve boards
Deal deal{};
// ... initialize deal with cards ...

FutureTricks fut{};
SolveBoard(ctx, deal, -1, 3, 0, &fut);

return 0;
}
```

**Benefits:**
- Automatic memory management (no manual cleanup)
- Per-context configuration (different settings per thread)
- Better multithreading (no global state contention)
- Explicit transposition table control

### Legacy C API (Backward Compatible)

The legacy API uses global state and is maintained for backward compatibility:

```c
#include <api/dll.h>

struct Deal deal = {0};
struct FutureTricks fut = {0};

SetMaxThreads(4);
SetResources(2000, 4);
SolveBoard(deal, -1, 3, 0, &fut, 0);

FreeMemory();
```

**Note:** Legacy initialization functions (`SetThreading`, `SetMaxThreads`, `SetResources`, `FreeMemory`) are deprecated but remain functional. See [docs/api_migration.md](docs/api_migration.md) for migration guidance.

### Migration Guide

For detailed migration examples and best practices, see:
- **[API Migration Guide](docs/api_migration.md)** - Step-by-step migration from legacy to modern API
- **[Legacy C API Reference](docs/legacy_c_api.md)** - Full documentation of deprecated functions
- **[Migration Example](examples/migration_example.cpp)** - Side-by-side legacy and modern API sample
- **[SolverContext Documentation](library/src/README_SolverContext.md)** - Modern API details

**Quick decision:**
- **New C++ projects**: Use modern API (`#include <dds/dds.hpp>`)
- **Existing C projects**: Continue with legacy API (no changes required)
- **Migration**: Follow incremental migration guide in docs/api_migration.md
10 changes: 10 additions & 0 deletions copilot/instructions/completed/remove_dead_code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Retire the Threading Enum.

Global memory allocation has been replaced by per call memory allocation. Clients can cache, and reuse, transposition tables. Computers have a lot more RAM compared to 15 years ago and it has to guess what is efficient from hardware configurations only. There are, however, some lingering types related to the legacy threading model.

- Verify that C++ clients can cache, and either reuse or reset, transposition tables.
- Verify that Threading is dead code.
- Check for other pieces of dead code such as initialisations.
- Check if any now unnecessary methods should remain as no operation implementations in the legacy C API.
- Create a plan for removing all legacy threading code from the C++ interface and library.
- There is a CI step called `perf_sample` that attempted to measure performance but is skipped and is unlikely to run correctly. Remove it if it does not execute correctly.
Loading
Loading