Skip to content

Commit d0d4a6d

Browse files
authored
[2.0] Add DuckDB E2E query optimization task (#136)
* Document Frontier-CS 2.0 task authoring * Add DuckDB E2E query optimization task
1 parent 543e822 commit d0d4a6d

14 files changed

Lines changed: 1556 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tag: systems
2+
runtime:
3+
language: cpp
4+
timeout_seconds: 10800
5+
environment: "DuckDB source patch; TPC-H shell timing; experimental judge"
6+
apt_packages:
7+
- bash
8+
- build-essential
9+
- ca-certificates
10+
- ccache
11+
- cmake
12+
- git
13+
- ninja-build
14+
- pkg-config
15+
- python3
16+
judge_apt_packages:
17+
- bash
18+
- build-essential
19+
- ca-certificates
20+
- ccache
21+
- cmake
22+
- git
23+
- ninja-build
24+
- pkg-config
25+
- python3
26+
docker:
27+
# Experimental local images. Build them with
28+
# 2.0/problems/duckdb_e2e_query_optimization/docker/build_images.sh before running a
29+
# local Harbor trial.
30+
image: frontiercs/duckdb-e2e-query-optimization-agent:experimental-v1.5.3
31+
judge_image: frontiercs/duckdb-e2e-query-optimization-judge:experimental-v1.5.3
32+
environment:
33+
cpus: 8
34+
memory_mb: 16384
35+
storage_mb: 32768
36+
build_timeout_seconds: 7200
37+
evaluation:
38+
scale_factor: 1
39+
benchmark_repetitions: 3
40+
build_timeout_seconds: 7200
41+
query_timeout_seconds: 300
42+
duckdb_memory_limit: "6GB"
43+
duckdb_temp_limit: "2GB"
44+
child_memory_mb: 12288
45+
submission:
46+
kind: file
47+
path: /app/solution.patch
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Experimental DuckDB Images
2+
3+
This task needs DuckDB source trees in both the agent and judge containers.
4+
The standard Frontier-CS 2.0 adapter can select Docker base images, but it does
5+
not build problem-specific images by itself. Build these images before running
6+
a local Harbor trial:
7+
8+
```bash
9+
bash 2.0/problems/duckdb_e2e_query_optimization/docker/build_images.sh
10+
```
11+
12+
Defaults:
13+
14+
```text
15+
DUCKDB_REF=v1.5.3
16+
DUCKDB_BUILD_JOBS=1
17+
AGENT_TAG=frontiercs/duckdb-e2e-query-optimization-agent:experimental-v1.5.3
18+
JUDGE_TAG=frontiercs/duckdb-e2e-query-optimization-judge:experimental-v1.5.3
19+
```
20+
21+
The agent image contains:
22+
23+
```text
24+
/app/duckdb
25+
```
26+
27+
The judge image contains:
28+
29+
```text
30+
/opt/duckdb-vanilla
31+
/opt/duckdb-clean
32+
```
33+
34+
`/opt/duckdb-clean` is prebuilt with:
35+
36+
```bash
37+
CMAKE_BUILD_PARALLEL_LEVEL=1 GEN=ninja DISABLE_UNITY=1 DISABLE_PARQUET=1 BUILD_JEMALLOC=0 BUILD_BENCHMARK=1 BUILD_EXTENSIONS='tpch' make
38+
```
39+
40+
`DUCKDB_BUILD_JOBS` intentionally defaults to `1`; higher parallelism can make
41+
large DuckDB C++ objects exhaust Docker memory on local machines. Unity builds
42+
are disabled for the same reason. Jemalloc is disabled because DuckDB v1.5.3's
43+
non-unity build exposes a missing include in the jemalloc allocator wrapper;
44+
vanilla and patched binaries are built with the same allocator setting.
45+
46+
The judge copies that prebuilt tree to `/opt/duckdb-vanilla` during image
47+
construction. At evaluation time the evaluator first resets tracked files in
48+
`/opt/duckdb-clean` back to `HEAD` and removes untracked files under `src`
49+
without deleting ignored build artifacts, applies the submitted patch, performs
50+
an incremental rebuild of the DuckDB shell and optional benchmark runner,
51+
checks correctness against `/opt/duckdb-vanilla`, and then times TPC-H queries
52+
through DuckDB's shell and TPC-H extension. Keeping build artifacts in the clean
53+
tree is intentional; full DuckDB rebuilds are too slow for iterative Harbor
54+
submissions.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ubuntu:24.04
2+
3+
ARG DUCKDB_REF=v1.5.3
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
bash \
9+
build-essential \
10+
ca-certificates \
11+
ccache \
12+
cmake \
13+
git \
14+
ninja-build \
15+
pkg-config \
16+
python3 \
17+
python3-pip \
18+
curl \
19+
ripgrep && \
20+
rm -rf /var/lib/apt/lists/*
21+
22+
RUN git clone --branch "${DUCKDB_REF}" --depth 1 https://github.com/duckdb/duckdb.git /app/duckdb && \
23+
cd /app/duckdb && \
24+
git submodule update --init --recursive
25+
26+
WORKDIR /app
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
5+
TASK_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
6+
7+
DUCKDB_REF="${DUCKDB_REF:-v1.5.3}"
8+
DUCKDB_BUILD_JOBS="${DUCKDB_BUILD_JOBS:-1}"
9+
AGENT_TAG="${AGENT_TAG:-frontiercs/duckdb-e2e-query-optimization-agent:experimental-v1.5.3}"
10+
JUDGE_TAG="${JUDGE_TAG:-frontiercs/duckdb-e2e-query-optimization-judge:experimental-v1.5.3}"
11+
12+
docker build \
13+
--build-arg "DUCKDB_REF=$DUCKDB_REF" \
14+
-t "$AGENT_TAG" \
15+
"$TASK_DIR/docker/agent"
16+
17+
docker build \
18+
--build-arg "DUCKDB_REF=$DUCKDB_REF" \
19+
--build-arg "DUCKDB_BUILD_JOBS=$DUCKDB_BUILD_JOBS" \
20+
-t "$JUDGE_TAG" \
21+
"$TASK_DIR/docker/judge"
22+
23+
echo "Built:"
24+
echo " $AGENT_TAG"
25+
echo " $JUDGE_TAG"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# syntax=docker/dockerfile:1.7
2+
FROM ubuntu:24.04
3+
4+
ARG DUCKDB_REF=v1.5.3
5+
ARG DUCKDB_BUILD_JOBS=1
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
8+
RUN apt-get update && \
9+
apt-get install -y --no-install-recommends \
10+
bash \
11+
build-essential \
12+
ca-certificates \
13+
ccache \
14+
cmake \
15+
git \
16+
ninja-build \
17+
pkg-config \
18+
python3 && \
19+
rm -rf /var/lib/apt/lists/*
20+
21+
RUN git clone --branch "${DUCKDB_REF}" --depth 1 https://github.com/duckdb/duckdb.git /opt/duckdb-clean && \
22+
cd /opt/duckdb-clean && \
23+
git submodule update --init --recursive
24+
25+
RUN --mount=type=cache,target=/root/.cache/ccache \
26+
cd /opt/duckdb-clean && \
27+
GEN=ninja CMAKE_BUILD_PARALLEL_LEVEL="${DUCKDB_BUILD_JOBS}" DISABLE_UNITY=1 DISABLE_PARQUET=1 BUILD_JEMALLOC=0 BUILD_UNITTESTS=0 BUILD_BENCHMARK=1 BUILD_EXTENSIONS='tpch' make -j"${DUCKDB_BUILD_JOBS}" && \
28+
cp -a /opt/duckdb-clean /opt/duckdb-vanilla
29+
30+
WORKDIR /judge
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
AGENT_TAG="${AGENT_TAG:-frontiercs/duckdb-e2e-query-optimization-agent:experimental-v1.5.3}"
5+
JUDGE_TAG="${JUDGE_TAG:-frontiercs/duckdb-e2e-query-optimization-judge:experimental-v1.5.3}"
6+
7+
echo "[agent] checking $AGENT_TAG"
8+
docker run --rm "$AGENT_TAG" sh -lc '
9+
test -d /app/duckdb/.git
10+
git -C /app/duckdb rev-parse HEAD
11+
'
12+
13+
echo "[judge] checking $JUDGE_TAG"
14+
docker run --rm "$JUDGE_TAG" sh -lc '
15+
test -d /opt/duckdb-clean
16+
test -d /opt/duckdb-vanilla
17+
test -x /opt/duckdb-vanilla/build/release/duckdb
18+
test -x /opt/duckdb-vanilla/build/release/benchmark/benchmark_runner
19+
/opt/duckdb-vanilla/build/release/duckdb -c "LOAD tpch; SELECT count(*) FROM tpch_queries();"
20+
'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
5+
6+
if [[ $# -gt 0 ]]; then
7+
exec python3 "$SCRIPT_DIR/evaluator.py" "$@"
8+
fi
9+
10+
SOLUTION="/work/execution_env/solution_env/solution.patch"
11+
if [[ ! -f "$SOLUTION" ]]; then
12+
echo "Error: Missing $SOLUTION" >&2
13+
exit 1
14+
fi
15+
16+
python3 "$SCRIPT_DIR/evaluator.py" "$SOLUTION"

0 commit comments

Comments
 (0)