#Can __forceinline Optimizations Improve Performance in Time-Sensitive Networking Code?

36 messages ยท Page 1 of 1 (latest)

wide scaffoldBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

prisma kernel
#

Maybe I don't know something, but how will this help?

#

How is it different compared to just having a long function

brave patrol
#

Dude, I'm not sure, for example chatgpt warns me about this, I've read articles in many communities but he says it can give bad performance in long functions.

#

chatgpt just tells me not to use it in long functions

#

I'm just not sure if it's a step forward.

prisma kernel
#

I mean, if the point of __forceinline is to have the same performance as if you pasted the function body instead of calling it, then moving stuff to forceinline functions shouldn't change anything

#

But you can measure it, maybe something will change?

#

He = who?

brave patrol
wide scaffoldBOT
#
Large Language Models (LLMs)

We highly recommend against the use of LLMs and AI assistants because:

  • LLMs are bad at C and C++
  • LLMs are wrong more often than not
  • LLMs answer with complete confidence even when wrong
  • If you're new to C or C++ you likely don't know enough to know when answers are wrong
brave patrol
#

I compared the old and the new to artificial intelligence.

brave patrol
prisma kernel
#

Well so far it's not helping you much here bing_shrug

#

Or at least it seems like it

brave patrol
#

thanks buddy

prisma kernel
#

Not sure if you're being sarcastic ๐Ÿ˜›

#

It shouldn't make any difference. But test it yourself if you want to know for sure

wide scaffoldBOT
#

@brave patrol Has your question been resolved? If so, type !solved :)

green matrix
maiden schooner
#

the probabilty you have sufficent insight into the advantages for a __forceinline is slim. everything you'd need to know to make an informed decision is already stuff the compiler knows.

pliant estuary
#

__forceinline doesn't help with network code since the corresponding kernel-calls for networking are rather expensive.

brave patrol
#

I'll try and see, I don't think he'll come out ahead.

green matrix
#

Stop

#

optimizing c++ code

#

god damn, you can just optimize it later, you need just to care about 3 things: copy of objects, memory safety, and, probably, memory secure

prisma kernel
green matrix
#

why so? if compiler for some reason not optimize, it may help
if case is something like

auto very_long_func() -> deduce_idk {
// this func was > 60 lines of code long
auto r1 = helper1();
auto r2 = helper2(r1);
auto r3 = helper3(r2);
return helper4(r3);
}
eager musk
#

the moment you bring networking to your code, the network will be ur speed bottleneck kek

lime acorn
#

don't ever trust any numbers chatgpt gives you, it just makes stuff up.. and take the other stuff with a grain of salt

green matrix
#

means: 1. dont believe to chat gpt 2. dont be 100% sure of stuff other ppl saying

i was 100% sure that vector use mem*** operations for removing/relocating etc. operations for all types, because somebody said it long long time ago, until it dont, and was never done

brave patrol
prisma kernel
#

So why not test this? And compare the performance

brisk palm
#

This depends on the compiler. I wish I had a good analogy, but there's no real straight-forward answer to this kind of question. Based on __forceinline I assume this is CL. For single-use functions, yes you generally want them inlined. It's rather suspicious that the implementation wouldn't do this already with optimizations enabled, so I feel like you're not providing all the relevant information to adequately answer your question. You have to read the codegen, this blanket advice stuff is more like shooting in the dark.

brave patrol