-
Notifications
You must be signed in to change notification settings - Fork 254
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
analyze: add --rewrite-mode pointwise #1073
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26dde70
to
d397814
Compare
fw-immunant
approved these changes
Apr 3, 2024
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.
LGTM, the added loop around run2
seems like it could benefit from a refactor to multiply less work (or at least output less) but I'm not sure exactly which portions could be reused across all definitions as the analysis does have to vary.
e0a2de5
to
ff1fa02
Compare
d397814
to
a015ff3
Compare
spernsteiner
added a commit
that referenced
this pull request
Apr 29, 2024
Adds scripts for computing "pointwise success rate" metrics. For each function, we run the static analysis and rewrite that function in isolation, producing a new `.rs` file where that function has been rewritten but all other code remains the same. Then we remove the `unsafe` qualifier from the target function and try to compile the code. The "pointwise success rate" is the number of functions on which this procedure succeeds. The main entry point is `c2rust-analyze/scripts/run_pointwise_metrics_lighttpd.sh` (as the name suggests, this is designed to compute the success rate on lighttpd specifically). It uses a few helpers: `pointwise_try_build.sh` tries to remove `unsafe` and compile the rewritten code for a specific function, `pointwise_try_build_unmodified.sh` does the same but on the unmodified, non-rewritten code (used for computing a baseline success rate), and `pointwise_metrics.py` tallies up the results and prints overall counts. Current output on lighttpd: ``` pointwise: 98/1008 functions passed unmodified: 149/1008 functions passed improved 20 functions broke 71 functions ``` This PR depends on #1073, which implements the `pointwise` rewrite mode in `c2rust-analyze`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new --rewrite-mode called "pointwise", which rewrites each function in isolation, with all other definitions marked
FIXED
. The static analysis runs only once, then we run multiple rewriting passes using the same analysis results, making this much more efficient than running the wholec2rust-analyze
tool multiple times.The rewritten code is output to a separate file for each function. For example, given
foo.rs
containing a functionbar
, this mode will write tofoo.bar.rs
the new code produced by rewriting onlybar
.Pointwise mode is the basis for our new "pointwise success rate" metric.