Skip to content
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

bench-api: Always get a Config from CLI flags #5541

Closed

Conversation

alexcrichton
Copy link
Member

This commit fixes an issue that I ran into just now where benchmarking one *.so with --engine-flags was giving wildly unexpected results comparing to something without --engine-flags. The root cause here appears to that when specifying --engine-flags the CLI parsing code is used to create a Config and when omitted a Config::new instance is created. The main difference between these is that for the CLI caching is enabled by default and for Config::new it is not. Coupled with the fact that caching doesn't really work for the main branch this ended up giving wild results.

The fix here is to first always use the CLI parsing code to create a Config to ensure that a config is consistently created. Next the --disable-cache flag is unconditionally passed to the CLI parsing to ensure that compilation actually happens.

Once applied this enables comparing an engine without flags and an engine with flags which provides consistent results.

This commit fixes an issue that I ran into just now where benchmarking
one `*.so` with `--engine-flags` was giving wildly unexpected results
comparing to something without `--engine-flags`. The root cause here
appears to that when specifying `--engine-flags` the CLI parsing code is
used to create a `Config` and when omitted a `Config::new` instance is
created. The main difference between these is that for the CLI caching
is enabled by default and for `Config::new` it is not. Coupled with the
fact that caching doesn't really work for the `main` branch this ended
up giving wild results.

The fix here is to first always use the CLI parsing code to create a
`Config` to ensure that a config is consistently created. Next the
`--disable-cache` flag is unconditionally passed to the CLI parsing to
ensure that compilation actually happens.

Once applied this enables comparing an engine without flags and an
engine with flags which provides consistent results.
@alexcrichton alexcrichton requested a review from fitzgen January 6, 2023 20:12
Comment on lines 243 to 251
let flags = if self.execution_flags_ptr.is_null() {
"--disable-cache".to_string()
} else {
let execution_flags = unsafe {
std::slice::from_raw_parts(self.execution_flags_ptr, self.execution_flags_len)
};
let execution_flags = std::str::from_utf8(execution_flags)
.context("given execution flags string is not valid UTF-8")?;
format!("--disable-cache {execution_flags}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do a null pointer and zero len for flags when not provided, always parse the Config from that resulting potentially-empty flags string, and then rely on #5542 for disabling the cache?

@alexcrichton
Copy link
Member Author

Merging this into #5542

@alexcrichton alexcrichton deleted the fix-bench-api branch February 21, 2023 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants