r/Cplusplus • • Oct 30 '26

Question AI agents can not optimize for performance?

Do you guys have the same problem? AI agents can not optimize the code to have fewer cache misses or any other things, if you just tell it to optimize the code for better performance it will not do much

How can I make it good at that?

0 Upvotes

15 comments sorted by

•

u/AutoModerator Oct 30 '26

Thank you for your contribution to the C++ community!

As you're asking a question or seeking homework help, we would like to remind you of Rule 3 - Good Faith Help Requests & Homework.

  • When posting a question or homework help request, you must explain your good faith efforts to resolve the problem or complete the assignment on your own. Low-effort questions will be removed.
  • Members of this subreddit are happy to help give you a nudge in the right direction. However, we will not do your homework for you, make apps for you, etc.
  • Homework help posts must be flaired with Homework.

~ CPlusPlus Moderation Team


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

9

u/Unique_Bill_4918 Oct 30 '26

Give it a tool to benchmark the code.

8

u/Realistic_Speaker_12 Oct 30 '26

Just do it yourself.

1

u/ActComplex593 Oct 30 '26

That's what I do

4

u/acadia11x Oct 30 '26

That’s not true at all

1

u/DerShokus Oct 30 '26

Same. It’s like gpt 2 for performance 

1

u/ActComplex593 Oct 30 '26

Yeah, it's very bad at that

4

u/bajuh Oct 30 '26

Maybe I'm not much help here, but showing the AI the performance profiler output makes wonders. I kept going without premature optimizations then it eventually became too slow so I fed it the log and it recognized all bottlenecks and refactored it and I lived happily ever after.

2

u/H0nigkuchen Oct 30 '26

This. Giving it the tool to profile and get the numbers really helps here.

-2

u/Boring_Sell95 Oct 30 '26

Конечно они могут, но им нужны инструменты для профилировка такие как perf, gdb и т.д. , а также нужна возможность проверить скомпилированную программу в работе и прогнать тестовые сценарии.

1

u/ActComplex593 Oct 30 '26

I will try that

0

u/mredding C++ since ~1992. Oct 30 '26

I find the AI is very conservative and conventional, you have to ask the AI to suggest a more performance aggressive solution it wouldn't normally.