Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[LifetimeSafety] Enhance benchmark script for ExpiredLoans analysis#149577

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
usx95 wants to merge1 commit intousers/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry
base:users/usx95/07-14-users_usx95_lifetime-safety-add-loan-expiry
Choose a base branch
Loading
fromusers/usx95/07-18-add-loan-analysis-to-benchmark

Conversation

usx95
Copy link
Contributor

@usx95usx95 commentedJul 18, 2025
edited
Loading

Enhanced the lifetime safety analysis benchmark script with more detailed performance metrics and a new nested loop test case. This is a worst case for loan expiry analysis.

What changed?

  • Added a new test casenested_loops that generates code with N levels of nested loops to test how analysis performance scales with loop nesting depth
  • Improved the trace file analysis to extract durations for sub-phases of the lifetime analysis (FactGenerator, LoanPropagation, ExpiredLoans)
  • Enhanced the markdown report generation to include:
    • Relative timing results as percentages of total Clang time
    • More detailed complexity analysis for each analysis phase

Report

Lifetime Analysis Performance Report

Generated on: 2025-07-18 20:07:39


Test Case: Pointer Cycle in Loop

Relative Timing Results (% of Total Clang Time):

N (Input Size)Total AnalysisFact GeneratorLoan PropagationExpired Loans
10 %27.34%0.00%27.08%0.00%
25 %87.68%0.00%87.61%0.00%
50 %98.64%0.00%98.61%0.00%
75 %99.62%0.00%99.60%0.00%
100 %99.84%0.00%99.83%0.01%
150 %99.96%0.00%99.95%0.01%

Complexity Analysis:

Analysis PhaseComplexity O(nk)
Total AnalysisO(n3.84 ± 0.01)
FactGenerator~ O(1) (Negligible)
LoanPropagationO(n3.84 ± 0.00)
ExpiredLoans~ O(1) (Negligible)

Test Case: CFG Merges

Relative Timing Results (% of Total Clang Time):

N (Input Size)Total AnalysisFact GeneratorLoan PropagationExpired Loans
10 %0.00%0.00%0.00%0.00%
50 %73.08%0.00%72.77%0.00%
100 %94.25%0.00%94.14%0.00%
200 %98.88%0.00%98.85%0.00%
400 %99.76%0.00%99.75%0.01%
800 %99.95%0.00%99.94%0.00%

Complexity Analysis:

Analysis PhaseComplexity O(nk)
Total AnalysisO(n3.02 ± 0.00)
FactGenerator~ O(1) (Negligible)
LoanPropagationO(n3.02 ± 0.00)
ExpiredLoans~ O(1) (Negligible)

Test Case: Deeply Nested Loops

Relative Timing Results (% of Total Clang Time):

N (Input Size)Total AnalysisFact GeneratorLoan PropagationExpired Loans
10 %0.00%0.00%0.00%0.00%
50 %52.40%0.00%46.50%5.69%
100 %82.74%0.00%73.38%9.27%
200 %95.35%0.00%84.62%10.69%
400 %98.76%0.00%87.15%11.59%
800 %99.63%0.00%88.20%11.42%

Complexity Analysis:

Analysis PhaseComplexity O(nk)
Total AnalysisO(n2.97 ± 0.00)
FactGenerator~ O(1) (Negligible)
LoanPropagationO(n2.97 ± 0.00)
ExpiredLoansO(n2.94 ± 0.01)

@usx95Graphite App
Copy link
ContributorAuthor

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stackon Graphite.
Learn more

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@usx95usx95 changed the titleadd-loan-analysis-to-benchmark[LifetimeSafety] Enhance benchmark script for end timingJul 18, 2025
@usx95usx95 changed the title[LifetimeSafety] Enhance benchmark script for end timing[LifetimeSafety] Enhance benchmark script for ExpiredLoans analysisJul 18, 2025
@github-actionsGitHub Actions
Copy link

⚠️ Python code formatter, darker found issues in your code.⚠️

You can test this locally with the following command:
darker --check --diff -r HEAD~1...HEAD clang/test/Analysis/LifetimeSafety/benchmark.py
View the diff from darker here.
--- benchmark.py2025-07-18 19:49:32.000000 +0000+++ benchmark.py2025-07-18 19:51:58.973643 +0000@@ -115,20 +115,20 @@         return "// Nesting depth must be positive."      cpp_code = "struct MyObj { int id; ~MyObj() {} };\n\n"     cpp_code += f"void nested_loops_{n}() {{\n"     cpp_code += "    MyObj* p = nullptr;\n"-+     for i in range(n):         indent = "    " * (i + 1)         cpp_code += f"{indent}for(int i{i}=0; i{i}<2; ++i{i}) {{\n"         cpp_code += f"{indent}    MyObj s{i}; p = &s{i};\n"      for i in range(n - 1, -1, -1):         indent = "    " * (i + 1)         cpp_code += f"{indent}}}\n"-+     cpp_code += "}\n"     cpp_code += f"\nint main() {{ nested_loops_{n}(); return 0; }}\n"     return cpp_code@@ -238,18 +238,18 @@             report.append(" ".join(row))          report.append("\n**Complexity Analysis:**\n")         report.append("| Analysis Phase    | Complexity O(n<sup>k</sup>) |")         report.append("|:------------------|:--------------------------|")-+         analysis_phases = {             "Total Analysis": data["lifetime_ms"],             "FactGenerator": data["fact_gen_ms"],             "LoanPropagation": data["loan_prop_ms"],             "ExpiredLoans": data["expired_loans_ms"],         }-+         for phase_name, y_data in analysis_phases.items():             k, delta = calculate_complexity(n_data, np.array(y_data))             if k is not None and delta is not None:                 complexity_str = f"O(n<sup>{k:.2f}</sup> &pm; {delta:.2f})"             else:@@ -291,11 +291,13 @@         print(f"Compilation failed for N={n}!", file=sys.stderr)         print(result.stderr, file=sys.stderr)         return {}      durations_us = analyze_trace_file(trace_file)-    return {key.replace('_us', '_ms'): value / 1000.0 for key, value in durations_us.items()}+    return {+        key.replace("_us", "_ms"): value / 1000.0 for key, value in durations_us.items()+    }   if __name__ == "__main__":     parser = argparse.ArgumentParser(         description="Generate, compile, and benchmark C++ test cases for Clang's lifetime analysis."@@ -360,11 +362,11 @@             )             if durations_ms:                 results[test_name]["n"].append(n)                 for key, value in durations_ms.items():                     results[test_name][key].append(value)-+                 print(                     f"    Total Analysis: {human_readable_time(durations_ms['lifetime_ms'])} | "                     f"FactGen: {human_readable_time(durations_ms['fact_gen_ms'])} | "                     f"LoanProp: {human_readable_time(durations_ms['loan_prop_ms'])} | "                     f"ExpiredLoans: {human_readable_time(durations_ms['expired_loans_ms'])}"@@ -374,10 +376,10 @@     print("Generating Markdown Report...")     print("=" * 80 + "\n")      markdown_report = generate_markdown_report(results)     print(markdown_report)-+     report_filename = os.path.join(args.output_dir, "performance_report.md")     with open(report_filename, "w") as f:         f.write(markdown_report)     print(f"Report saved to: {report_filename}")

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@usx95

[8]ページ先頭

©2009-2025 Movatter.jp