Skip to content

Commit 0d9b49b

Browse files
committed
add Nix based compilation + rr
1 parent 877bc8f commit 0d9b49b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+664
-473
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ FROM mcr.microsoft.com/devcontainers/base:ubuntu24.04
33
# Note: there is no OpenJDK installed. Mill uses its own.
44
# Look at the top of build.mill to see the most-used version.
55

6+
# For build tools happiness
67
RUN apt-get update \
7-
&& apt-get install -y \
8-
build-essential \
9-
libmsgpack-cxx-dev clang-tools clangd cmake ninja-build \
10-
wget ssh sudo gdb \
11-
python3-dev swig
8+
&& apt-get install -y clangd
129

1310
RUN wget https://go.dev/dl/go1.24.0.linux-amd64.tar.gz
1411
RUN tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
}
1919
},
2020
"postCreateCommand": {
21-
"autocomplete": "rm -rf out/ .scala-build/ .bloop/ .bsp/ .metals/ && ./mill mill.tabcomplete/install && echo source ~/.cache/mill/download/mill-completion.sh >>~/.bashrc"
21+
"autocomplete": "rm -rf out/ .scala-build/ .bloop/ .bsp/ .metals/ && ./mill mill.tabcomplete/install && echo source ~/.cache/mill/download/mill-completion.sh >>~/.bashrc",
22+
"nix": "bash -c \"sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --no-daemon\" && echo . /home/vscode/.nix-profile/etc/profile.d/nix.sh >>~/.bashrc && mkdir -p ~/.config/nix/ && echo experimental-features = nix-command flakes >>~/.config/nix/nix.conf"
2223
},
2324
"features": {
2425
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}

omnilink/GitRepo.mill renamed to omnilink/GitRepoModule.mill

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package build.omnilink
22

33
import mill.*
44

5-
trait GitRepo extends Module:
5+
trait GitRepoModule extends Module:
66
repo =>
77
def origin: T[String]
88

@@ -11,14 +11,18 @@ trait GitRepo extends Module:
1111
def commitHash: T[String]
1212
def dir: T[PathRef] = Task:
1313
os.call(
14-
List("git", "clone", origin()),
14+
List[os.Shellable](
15+
"git",
16+
"clone",
17+
origin(),
18+
),
1519
cwd = Task.dest,
1620
stdout = os.Inherit,
1721
stderr = os.Inherit,
1822
)
1923
val cloneDir = os.list(Task.dest).filter(os.isDir).head
2024
os.call(
21-
List(
25+
List[os.Shellable](
2226
"git",
2327
"-c",
2428
"advice.detachedHead=false",
@@ -32,4 +36,4 @@ trait GitRepo extends Module:
3236
PathRef(cloneDir)
3337
end dir
3438
end CommitHash
35-
end GitRepo
39+
end GitRepoModule

omnilink/createTables.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ CREATE TABLE IF NOT EXISTS config (
66
CREATE TABLE IF NOT EXISTS experiment (
77
config_id VARCHAR,
88
idx INTEGER,
9-
github VARCHAR,
10-
branch VARCHAR,
119
spec_path VARCHAR,
1210
mc_spec_path VARCHAR,
1311
mc_config_path VARCHAR,

omnilink/evaldb/package.mill

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package build.omnilink.evaldb
2+
3+
import mill.*
4+
5+
import scalasql.*, PostgresDialect.*
6+
import mill.api.BuildCtx
7+
import scala.util.Using
8+
import java.time.LocalDateTime
9+
10+
trait EvalDBTrait:
11+
def dbPath: os.SubPath
12+
def createTablesSQL: os.SubPath
13+
14+
final case class AutoCloseClient(client: DbClient, closeFn: () => Unit)
15+
extends AutoCloseable:
16+
export client.*
17+
def close(): Unit =
18+
closeFn()
19+
end AutoCloseClient
20+
21+
private lazy val fn =
22+
Class.forName("org.duckdb.DuckDBDriver")
23+
val fn = () =>
24+
@scala.annotation.tailrec
25+
def retry(): AutoCloseClient =
26+
try
27+
val conn = java.sql.DriverManager.getConnection(
28+
s"jdbc:duckdb:${BuildCtx.workspaceRoot / dbPath}",
29+
)
30+
val client = DbClient.Connection(conn)
31+
AutoCloseClient(client, conn.close)
32+
catch
33+
case ex: java.sql.SQLException =>
34+
if ex.getMessage().contains("Could not set lock on file")
35+
then
36+
println(s"DuckDB file lock contention, backing off...")
37+
Thread.sleep(1000)
38+
retry()
39+
else throw ex
40+
end retry
41+
retry()
42+
end fn
43+
44+
Using.resource(fn()): conn =>
45+
conn.getAutoCommitClientConnection
46+
.updateRaw(os.read(BuildCtx.workspaceRoot / createTablesSQL))
47+
48+
fn
49+
end fn
50+
51+
def dbClient: () => AutoCloseClient = fn
52+
end EvalDBTrait
53+
54+
object EvalDB extends Module, EvalDBTrait:
55+
def createTablesSQL = os.sub / "omnilink" / "createTables.sql"
56+
def dbPath = os.sub / "omnilink" / "eval.duckdb"
57+
58+
given workspacePathMapper: TypeMapper[os.Path] =
59+
TypeMapper[String].bimap(
60+
_.relativeTo(BuildCtx.workspaceRoot).toString,
61+
os.Path(_, BuildCtx.workspaceRoot),
62+
)
63+
64+
case class Config[T[_]](
65+
id: T[String],
66+
expectedExperimentCount: T[Int],
67+
)
68+
object Config extends Table[Config]
69+
70+
case class Experiment[T[_]](
71+
configId: T[String],
72+
idx: T[Int],
73+
github: T[String],
74+
branch: T[String],
75+
specPath: T[os.Path],
76+
mcSpecPath: T[os.Path],
77+
mcConfigPath: T[os.Path],
78+
startTime: T[LocalDateTime],
79+
endTime: T[LocalDateTime],
80+
)
81+
object Experiment extends Table[Experiment]
82+
83+
case class Trace[T[_]](
84+
configId: T[String],
85+
experimentIdx: T[Int],
86+
id: T[Int],
87+
trace: T[geny.Bytes],
88+
)
89+
object Trace extends Table[Trace]
90+
91+
case class GatherLog[T[_]](
92+
configId: T[String],
93+
experimentIdx: T[Int],
94+
name: T[String],
95+
text: T[String],
96+
)
97+
object GatherLog extends Table[GatherLog]
98+
99+
case class Validation[T[_]](
100+
configId: T[String],
101+
experimentIdx: T[Int],
102+
logTxt: T[String],
103+
startTime: T[LocalDateTime],
104+
endTime: T[LocalDateTime],
105+
success: T[Boolean],
106+
counterExampleBin: T[Option[geny.Bytes]],
107+
)
108+
object Validation extends Table[Validation]
109+
end EvalDB

omnilink/nativebuilds/package.mill

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package build.omnilink.nativebuilds
2+
3+
import mill.*
4+
import mill.api.Task.Simple
5+
6+
object Nix extends Module:
7+
def whichNix: T[(String, String)] = Task.Input:
8+
val exePath = "nix"
9+
val result = os.call(
10+
List[os.Shellable](exePath, "--version"),
11+
stdout = os.Inherit,
12+
stderr = os.Inherit,
13+
)
14+
(exePath, result.out.text())
15+
end whichNix
16+
17+
def nixExe: T[String] = whichNix()._1
18+
19+
trait FlakeModule extends Module:
20+
def flakeDescriptor: T[String]
21+
22+
def buildResult: T[PathRef] = Task:
23+
os.call(
24+
List[os.Shellable](nixExe(), "build", flakeDescriptor()),
25+
stdout = os.Inherit,
26+
stderr = os.Inherit,
27+
cwd = Task.dest,
28+
)
29+
PathRef(Task.dest / "result")
30+
end buildResult
31+
32+
trait OutputModule(path: os.SubPath) extends Module:
33+
def out: T[PathRef] =
34+
PathRef(buildResult().path / path)
35+
end OutputModule
36+
end FlakeModule
37+
end Nix
38+
39+
object rr extends Nix.FlakeModule:
40+
def flakeDescriptor = "github:sidkshatriya/rr.soft"
41+
object bin extends OutputModule(os.sub / "bin" / "rr")
42+
end rr

omnilink/omnilink-lib.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <initializer_list>
1212
#include <limits>
1313
#include <memory>
14-
#include <msgpack/v3/object_decl.hpp>
1514
#include <sstream>
1615
#include <vector>
1716
#include <thread>

0 commit comments

Comments
 (0)