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

analyze: add scripts for computing pointwise metrics #1074

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

spernsteiner
Copy link
Collaborator

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.

@spernsteiner spernsteiner requested a review from fw-immunant April 1, 2024 23:43
Copy link
Contributor

@fw-immunant fw-immunant left a comment

Choose a reason for hiding this comment

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

Deduplicate the nearly-identical scripts somehow, otherwise looks good.

Comment on lines 24 to 26
d="$(dirname "$f")"
f="$d/${name}_safe_${func}.rs"
cp "$d/$name.rs" "$f"
Copy link
Contributor

Choose a reason for hiding this comment

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

These are the only difference between these two scripts--it would be good to just make these conditional and avoid the duplication.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've updated this to deduplicate the similar scripts.

@spernsteiner spernsteiner force-pushed the analyze-metrics-scripts-base branch from 63ce33e to d85b4d0 Compare April 22, 2024 18:56
@spernsteiner spernsteiner force-pushed the analyze-metrics-scripts branch from ef5fa94 to 08fb475 Compare April 22, 2024 18:56
@spernsteiner spernsteiner changed the base branch from analyze-metrics-scripts-base to master April 22, 2024 18:56
@spernsteiner spernsteiner merged commit 3d85abc into master Apr 29, 2024
7 of 9 checks passed
spernsteiner added a commit that referenced this pull request Apr 29, 2024
In #1074, I had commented out a line to speed up testing, and
accidentally left it that way when I merged the branch.
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