Skip to content

Commit d1645e2

Browse files
committed
[bot/publish-github-release-after-steps]: Merge remote-tracking branch 'origin/master' into bot/publish-github-release-after-steps
2 parents f38edba + 6493aa6 commit d1645e2

17 files changed

Lines changed: 91 additions & 97 deletions

File tree

.github/actions/keynote-bench-setup/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ runs:
1919
shell: bash
2020
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
2121

22+
- name: Set up sccache
23+
uses: mozilla-actions/sccache-action@v0.0.10
24+
25+
- name: Enable sccache
26+
shell: bash
27+
run: |
28+
echo "SCCACHE_GHA_ENABLED=true" >>"$GITHUB_ENV"
29+
echo "RUSTC_WRAPPER=sccache" >>"$GITHUB_ENV"
30+
2231
- name: Cache Rust dependencies
2332
uses: Swatinem/rust-cache@v2
2433
with:

.github/workflows/ci.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ jobs:
110110
- name: Set default rust toolchain
111111
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
112112

113+
- name: Set up sccache
114+
uses: mozilla-actions/sccache-action@v0.0.10
115+
116+
- name: Enable sccache
117+
shell: bash
118+
run: |
119+
echo "SCCACHE_GHA_ENABLED=true" >>"$GITHUB_ENV"
120+
echo "RUSTC_WRAPPER=sccache" >>"$GITHUB_ENV"
121+
113122
- name: Cache Rust dependencies
114123
uses: Swatinem/rust-cache@v2
115124
with:
@@ -428,16 +437,24 @@ jobs:
428437
- name: Set default rust toolchain
429438
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
430439

440+
- name: Set up sccache
441+
uses: mozilla-actions/sccache-action@v0.0.10
442+
443+
- name: Enable sccache
444+
run: |
445+
echo "SCCACHE_GHA_ENABLED=true" >>"$GITHUB_ENV"
446+
echo "RUSTC_WRAPPER=sccache" >>"$GITHUB_ENV"
447+
431448
- name: Cache Rust dependencies
432449
uses: Swatinem/rust-cache@v2
433450
with:
434451
workspaces: ${{ github.workspace }}
435-
shared-key: spacetimedb
436-
save-if: false
452+
shared-key: spacetimedb-index-scan
453+
cache-on-failure: false
437454
prefix-key: v1
438455

439456
- name: Run index scan benchmark regression check
440-
run: cargo bench -p spacetimedb-bench --bench index_scan_gate
457+
run: cargo run --release -p spacetimedb-index-scan-gate
441458

442459
lints:
443460
needs: [merge_queue_noop]

.github/workflows/llm-benchmark-periodic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
114114
LLM_VENDOR: openrouter
115115
LLM_BENCHMARK_API_KEY: ${{ secrets.LLM_BENCHMARK_API_KEY }}
116-
LLM_BENCHMARK_UPLOAD_URL: ${{ inputs.LLM_BENCHMARK_UPLOAD_URL }}
116+
LLM_BENCHMARK_UPLOAD_URL: ${{ vars.LLM_BENCHMARK_UPLOAD_URL }}
117117
DOTNET_MULTILEVEL_LOOKUP: "0"
118118
DOTNET_CLI_HOME: ${{ runner.temp }}/dotnet-home
119119
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ permissions:
5454
packages: write
5555

5656
concurrency:
57-
group: manual-release
57+
group: manual-release-${{ inputs.release_tag }}${{ inputs.dry_run && format('-dry-run-{0}', github.run_id) || '' }}
5858
cancel-in-progress: true
5959

6060
jobs:

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ members = [
1919
"crates/expr",
2020
"crates/guard",
2121
"crates/fs-utils",
22+
"crates/index-scan-gate",
2223
"crates/lib",
2324
"crates/metrics",
2425
"crates/paths",

crates/bench/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ harness = false
3030
name = "index"
3131
harness = false
3232

33-
[[bench]]
34-
name = "index_scan_gate"
35-
harness = false
36-
3733
[[bin]]
3834
name = "summarize"
3935

crates/cli/build.rs

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ fn discover_templates(templates_dir: &Path) -> Vec<TemplateInfo> {
202202
if !metadata_path.exists() {
203203
continue;
204204
}
205+
println!("cargo:rerun-if-changed={}", metadata_path.display());
205206

206207
let metadata_content = match fs::read_to_string(&metadata_path) {
207208
Ok(content) => content,
@@ -261,32 +262,7 @@ fn generate_template_entry(code: &mut String, template_path: &Path, source: &str
261262
panic!("Template '{}' has no git-tracked files! Check that the directory exists and contains files tracked by git.", source);
262263
}
263264

264-
// Example: /Users/user/SpacetimeDB
265265
let repo_root = get_repo_root();
266-
let repo_root_canonical = std::fs::canonicalize(&repo_root).unwrap();
267-
// Example: /Users/user/SpacetimeDB/crates/cli
268-
let manifest_canonical = Path::new(manifest_dir).canonicalize().unwrap();
269-
// Example: crates/cli
270-
let manifest_rel = manifest_canonical.strip_prefix(&repo_root_canonical).unwrap();
271-
272-
// Example for inside crate: /Users/user/SpacetimeDB/crates/cli/templates/basic-rs/server
273-
// Example for outside crate: /Users/user/SpacetimeDB/modules/chat-console-rs
274-
let resolved_canonical = repo_root.join(&resolved_base).canonicalize().unwrap();
275-
276-
// If the files are outside of the cli crate we need to copy them to the crate directory,
277-
// so they're included properly even when the crate is published
278-
let local_copy_dir = if resolved_canonical.strip_prefix(&manifest_canonical).is_err() {
279-
// Example source: "../../modules/quickstart-chat"
280-
// Sanitized: "parent_parent_modules_quickstart-chat"
281-
let sanitized_source = source.replace("/", "_").replace("\\", "_").replace("..", "parent");
282-
// Example: /Users/user/SpacetimeDB/crates/cli/.templates/parent_parent_modules_quickstart-chat
283-
let copy_dir = Path::new(manifest_dir).join(".templates").join(&sanitized_source);
284-
fs::create_dir_all(&copy_dir).expect("Failed to create .templates directory");
285-
286-
Some(copy_dir)
287-
} else {
288-
None
289-
};
290266

291267
code.push_str(" {\n");
292268
code.push_str(" let mut files = HashMap::new();\n");
@@ -313,38 +289,13 @@ fn generate_template_entry(code: &mut String, template_path: &Path, source: &str
313289
// Example: /Users/user/SpacetimeDB/modules/quickstart-chat/src/lib.rs
314290
let full_path = repo_root.join(&file_path);
315291
if full_path.exists() && full_path.is_file() {
316-
let include_path = if let Some(ref copy_dir) = local_copy_dir {
317-
// Outside crate: copy to .templates
318-
// Example dest_file: /Users/user/SpacetimeDB/crates/cli/.templates/parent_parent_modules_chat-console-rs/src/lib.rs
319-
let dest_file = copy_dir.join(relative_path);
320-
fs::create_dir_all(dest_file.parent().unwrap()).expect("Failed to create parent directory");
321-
copy_if_changed(&full_path, &dest_file)
322-
.unwrap_or_else(|_| panic!("Failed to copy file {:?} to {:?}", full_path, dest_file));
323-
324-
// Example relative_to_manifest: .templates/parent_parent_modules_chat-console-rs/src/lib.rs
325-
let relative_to_manifest = dest_file.strip_prefix(manifest_dir).unwrap();
326-
let path_str = relative_to_manifest.to_str().unwrap().replace("\\", "/");
327-
// Watch the original file for changes
328-
// Example: modules/chat-console-rs/src/lib.rs
329-
println!("cargo:rerun-if-changed={}", full_path.display());
330-
path_str
331-
} else {
332-
// Inside crate: use path relative to CARGO_MANIFEST_DIR
333-
// Example file_path: crates/cli/templates/basic-rs/server/src/lib.rs
334-
// Example manifest_rel: crates/cli
335-
// Result: templates/basic-rs/server/src/lib.rs
336-
let relative_to_manifest = file_path.strip_prefix(manifest_rel).unwrap();
337-
let path_str = relative_to_manifest.to_str().unwrap().replace("\\", "/");
338-
// Example: crates/cli/templates/basic-rs/server/src/lib.rs
339-
println!("cargo:rerun-if-changed={}", full_path.display());
340-
path_str
341-
};
292+
let include_path = file_path.to_str().unwrap().replace("\\", "/");
293+
println!("cargo:rerun-if-changed={}", full_path.display());
342294

343-
// Example include_path (inside crate): "templates/basic-rs/server/src/lib.rs"
344-
// Example include_path (outside crate): ".templates/parent_parent_modules_chat-console-rs/src/lib.rs"
295+
// Example include_path: "templates/basic-rs/src/main.rs"
345296
// Example relative_str: "src/lib.rs"
346297
code.push_str(&format!(
347-
" files.insert(\"{}\", include_str!(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/{}\")));\n",
298+
" files.insert(\"{}\", include_str!(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/../../{}\")));\n",
348299
relative_str, include_path
349300
));
350301
}
@@ -561,22 +512,6 @@ fn write_if_changed(path: &Path, contents: &[u8]) -> io::Result<()> {
561512
}
562513
}
563514

564-
fn copy_if_changed(src: &Path, dst: &Path) -> io::Result<()> {
565-
let src_bytes = fs::read(src)?;
566-
if let Ok(existing) = fs::read(dst)
567-
&& existing == src_bytes
568-
{
569-
return Ok(());
570-
}
571-
572-
if let Some(parent) = dst.parent() {
573-
fs::create_dir_all(parent)?;
574-
}
575-
576-
let mut file = fs::File::create(dst)?;
577-
file.write_all(&src_bytes)
578-
}
579-
580515
/// Discover skill directories under skills/. Each directory containing a SKILL.md
581516
/// file is considered a skill. Returns sorted skill names.
582517
fn discover_skill_names(skills_dir: &Path) -> Vec<String> {

crates/core/src/host/host_controller.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ pub struct ModuleHostWithBootstrap {
100100
/// The handle owns any wait state needed to prove that the database has a
101101
/// durable `st_module` row.
102102
pub struct BootstrapCompletion {
103-
program_hash: Hash,
103+
bootstrap_generation: u64,
104104
status: ProgramBootstrap,
105105
}
106106

107107
/// Has the module been bootstrapped from the controldb?
108108
///
109109
/// Once we have inserted into `st_module`, bootstrapping is no longer necessary,
110-
/// and the initial program bytes can be dropped fromt the controldb.
110+
/// and the initial program bytes can be dropped from the controldb.
111111
enum ProgramBootstrap {
112112
/// The module's program bytes have already been written to `st_module`
113113
Durable,
@@ -119,32 +119,32 @@ enum ProgramBootstrap {
119119
}
120120

121121
impl BootstrapCompletion {
122-
fn durable(program_hash: Hash) -> Self {
122+
fn durable(bootstrap_generation: u64) -> Self {
123123
Self {
124-
program_hash,
124+
bootstrap_generation,
125125
status: ProgramBootstrap::Durable,
126126
}
127127
}
128128

129-
fn pending(program_hash: Hash, tx_offset: TransactionOffset, durable_offset: Option<DurableOffset>) -> Self {
129+
fn pending(bootstrap_generation: u64, tx_offset: TransactionOffset, durable_offset: Option<DurableOffset>) -> Self {
130130
Self {
131-
program_hash,
131+
bootstrap_generation,
132132
status: ProgramBootstrap::Pending {
133133
tx_offset,
134134
durable_offset,
135135
},
136136
}
137137
}
138138

139-
pub fn program_hash(&self) -> Hash {
140-
self.program_hash
139+
pub fn bootstrap_generation(&self) -> u64 {
140+
self.bootstrap_generation
141141
}
142142

143143
/// Wait until it is safe to complete program bootstrap in controldb.
144144
/// That is, wait until the initial `st_module` insert becomes durable.
145-
pub async fn wait(self) -> anyhow::Result<Hash> {
145+
pub async fn wait(self) -> anyhow::Result<()> {
146146
match self.status {
147-
ProgramBootstrap::Durable => Ok(self.program_hash),
147+
ProgramBootstrap::Durable => Ok(()),
148148
ProgramBootstrap::Pending {
149149
tx_offset,
150150
durable_offset,
@@ -160,7 +160,7 @@ impl BootstrapCompletion {
160160
.context("failed waiting for initialized program to become durable")?;
161161
}
162162

163-
Ok(self.program_hash)
163+
Ok(())
164164
}
165165
}
166166
}
@@ -1132,7 +1132,8 @@ impl Host {
11321132
(program, true)
11331133
}
11341134
};
1135-
let mut bootstrap_completion = Some(BootstrapCompletion::durable(program.hash));
1135+
let bootstrap_generation = database.bootstrap_generation;
1136+
let mut bootstrap_completion = Some(BootstrapCompletion::durable(bootstrap_generation));
11361137

11371138
let relational_db = Arc::new(db);
11381139
let (program, launched) = match HostType::from(program.kind) {
@@ -1222,13 +1223,12 @@ impl Host {
12221223
};
12231224

12241225
if program_needs_init {
1225-
let program_hash = program.hash;
12261226
let InitDatabaseResult { reducer, tx_offset } = launched.module_host.init_database(program).await?;
12271227
if let Some(call_result) = reducer {
12281228
Result::from(call_result)?;
12291229
}
12301230
bootstrap_completion = Some(BootstrapCompletion::pending(
1231-
program_hash,
1231+
bootstrap_generation,
12321232
tx_offset,
12331233
launched.module_host.durable_tx_offset(),
12341234
));
@@ -1540,6 +1540,7 @@ pub(crate) async fn extract_schema_with_pools(
15401540
owner_identity,
15411541
host_type,
15421542
initial_program: program.hash,
1543+
bootstrap_generation: 0,
15431544
};
15441545

15451546
let core = AllocatedJobCore::default();

crates/core/src/host/instance_env.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ mod test {
13771377
owner_identity: Identity::ZERO,
13781378
host_type: HostType::Wasm,
13791379
initial_program: Hash::ZERO,
1380+
bootstrap_generation: 0,
13801381
},
13811382
replica_id: 0,
13821383
logger,

0 commit comments

Comments
 (0)