-
Notifications
You must be signed in to change notification settings - Fork 1k
Preserve artifact cache unless stale #1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a563e25
f31d354
195bbce
99aa012
17973ef
e81b456
851a77a
a3b0fcf
b323c28
a2808f8
0657d41
0384ae7
4b1bb0a
a8bcce4
50b7ccc
b6c1a07
2ad5262
3723806
e44c451
6c19164
dad5285
1ede201
2d51b52
36a33e8
69f6a44
d3254f5
f4d22fa
39448ff
3a2c1cd
a02cb06
53e4557
d4f3083
9d2142e
931aae1
5de4e8e
a0b71c5
c85adfe
b897f1c
89ada31
868426a
652bec7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
fn main() { | ||
get_wasmtime_version(); | ||
} | ||
|
||
pub fn get_wasmtime_version() { | ||
|
||
// we only care about the root of the tree | ||
match std::process::Command::new("cargo") | ||
.args(&["tree", "--package=wasmtime", "--depth=0"]) | ||
.output() | ||
{ | ||
Ok(out) if out.status.success() => { | ||
// wasmtime vX.X.X | ||
let version = String::from_utf8_lossy(&out.stdout); | ||
if let Some(version) = version.strip_prefix("wasmtime v") { | ||
println!("cargo:rustc-env=SUBSTRATE_WASMTIME_VERSION={}", version); | ||
} else { | ||
println!("cargo:warning=build.rs: unexpected result {}", version); | ||
} | ||
}, | ||
Ok(out) => println!( | ||
"cargo:warning=build.rs: `cargo tree` {}", | ||
String::from_utf8_lossy(&out.stderr), | ||
), | ||
Err(err) => { | ||
println!("cargo:warning=build.rs: Could not run `cargo tree`: {}", err); | ||
}, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -58,7 +58,9 @@ | |||||
use crate::{host::PrecheckResultSender, LOG_TARGET}; | ||||||
use always_assert::always; | ||||||
use polkadot_core_primitives::Hash; | ||||||
use polkadot_node_core_pvf_common::{error::PrepareError, prepare::PrepareStats, pvf::PvfPrepData}; | ||||||
use polkadot_node_core_pvf_common::{ | ||||||
error::PrepareError, prepare::PrepareStats, pvf::PvfPrepData, RUNTIME_VERSION, | ||||||
}; | ||||||
use polkadot_node_primitives::NODE_VERSION; | ||||||
use polkadot_parachain_primitives::primitives::ValidationCodeHash; | ||||||
use polkadot_primitives::ExecutorParamsHash; | ||||||
|
@@ -106,9 +108,10 @@ macro_rules! concat_const { | |||||
}} | ||||||
} | ||||||
|
||||||
const RUNTIME_PREFIX: &str = "wasmtime_"; | ||||||
const RUNTIME_PREFIX: &str = "wasmtime_v"; | ||||||
const NODE_PREFIX: &str = "polkadot_v"; | ||||||
const ARTIFACT_PREFIX: &str = concat_const!(RUNTIME_PREFIX, NODE_PREFIX, NODE_VERSION); | ||||||
const ARTIFACT_PREFIX: &str = | ||||||
concat_const!(RUNTIME_PREFIX, RUNTIME_VERSION, "_", NODE_PREFIX, NODE_VERSION); | ||||||
|
const ARTIFACT_PREFIX: &str = | |
concat_const!(RUNTIME_PREFIX, RUNTIME_VERSION, "_", NODE_PREFIX, NODE_VERSION); |
This is over the top. We don't need this macro, nor do we need to concat this at compile time. We are using format anyway to generate the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean we do something like this instead?
fn artifact_prefix() -> String {
format!("{}{}_{}{}", RUNTIME_PREFIX, RUNTIME_VERSION, NODE_PREFIX, NODE_VERSION)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the very first version. Now it still feels odd to compute the same thing over and over.. I understand this is not remotely close to hot and this isn't about performance. I understand that the macro thing may feel like too much at the first glance. When I looked at how much cleaner the code became with the const/static compared to a function call, I felt it's worth it. A const is just so much easier to use than a function, as when a value is static, it probably should be used as one. Besides, isn't it nice that drop/dealloc/format calls are wiped off from the assembly? :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a function you can at least put it behind a OnceCell
or something. Otherwise I did a search and there are some crates that do this: const_format
, concat_const
, etc. But it would be sad to pull in a whole dependency for this. I wish std had this... Meh, let's just merge as-is (with the function). I'll press the green button once conflicts are resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a function you can at least put it behind a OnceCell or something.
Function, cell, lazy static, considered all that before doing the macro as it results in the simplest interface, a static str. I won't change it back. Let's get this merged. 🚀 I'm just trying to understand why is a function call better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just trying to understand why is a function call better here.
The problem with the macro is that it's a lot of code for readers to understand, just to declare a constant. TBH, all the options are kind of meh, but given that the code is cold, optimizing for maintainability with a plain function seems like the right call.
Uh oh!
There was an error while loading. Please reload this page.