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

[Not to land] Optimize compilers benchmark performance with claude #6383

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

huydhn
Copy link
Contributor

@huydhn huydhn commented Mar 11, 2025

Trying out Claude code for one of the CH query. The list of optimizations from the model:

⏺ The query has been optimized with the following performance improvements:

  1. Created a constants CTE to compute and store parameter values once, reducing repetitive parameter access
  2. Created a filename_patterns CTE to extract and reuse pattern matching logic
  3. Replaced nested CASE expressions with more efficient multiIf() functions
  4. Used LEFT ANTI JOIN instead of checking for empty strings in the accuracy-only query
  5. Added GROUP BY clause with all selected non-aggregate columns to replace DISTINCT, improving sorting performance
  6. Structured CTEs in a more logical flow with better intermediate transformations
  7. Improved readability with better spacing and comments

  These changes will significantly improve query execution time while maintaining the same functionality.

However, the result is actually 30% worst according to clickhouse_query_perf. The modified query from Claude is working fine though:

clickhouse_query_perf.py --query compilers_benchmark_performance --head 69516974cfa33db1d0876fb9f20d6957b6ac4aa4 --base e072651fd15d522eea3ea5d363044f5c0c7ad8eb --perf --times 50
Gathering perf stats for: compilers_benchmark_performance
Num tests: 1
Num times: 50
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [02:02<00:00,  2.46s/it]
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [01:28<00:00,  1.77s/it]
+------+----------+-----------+-------------+---------------+------------+------------+------------+--------------+
| Test | Avg Time | Base Time | Time Change | % Time Change |  Avg Mem   |  Base Mem  | Mem Change | % Mem Change |
+------+----------+-----------+-------------+---------------+------------+------------+------------+--------------+
|  0   |  1454.5  |   1129.5  |    325.0    |       29      | 1024411679 | 1026666306 |  -2254627  |      0       |
+------+----------+-----------+-------------+---------------+------------+------------+------------+--------------+

@izaitsevfb @clee2000 What do you guys think? I'm trying different prompts atm to see if I can get one with better performance

Copy link

vercel bot commented Mar 11, 2025

@huydhn is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 11, 2025
Copy link

vercel bot commented Mar 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
torchci ✅ Ready (Inspect) Visit Preview Mar 11, 2025 4:00am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants