473,806 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inline Performance impact

GJ
The performance can be DEGRADED by making a function "inline". Is it TRUE in
any case ?

--
GJ
Oct 18 '05 #1
9 1534
GJ wrote:
The performance can be DEGRADED by making a function "inline". Is it TRUE
in any case ?


Yes.

Oct 18 '05 #2
GJ

"Rolf Magnus" <ra******@t-online.de> wrote in message
news:dj******** *****@news.t-online.com...
GJ wrote:
The performance can be DEGRADED by making a function "inline". Is it TRUE in any case ?


Yes.

When I mean what scenario ?
Oct 18 '05 #3
I could think of:
Huge inlined function, used (called) from many places
-> program gets huge -> hooks up all memory and the
machine starts to swap.

Cheers,
marc

Oct 18 '05 #4

Rolf Magnus wrote:
GJ wrote:
The performance can be DEGRADED by making a function "inline". Is it TRUE
in any case ?


Yes.

Is that the same story on template code, where the implementation is
resident in a .hh file (or a .h file).

class whatever {
public:
template<typena me T>
void some_method(T& var) {}
};

If memory serves though, I think implementations in a header file is
already inlined?

Oct 18 '05 #5
GJ wrote:
> The performance can be DEGRADED by making a function "inline". Is it TRUE > in any case ?


Yes.

When I mean what scenario ?


If the function gets called from many places, too much inlining can increase
code size significantly, which will lower the cache efficiency on systems
that do use caching (which is the majority these days). On modern
workstation-like computers, the cache is extremely important for fast code
execution. Reading a value from RAM can take several hundred clock cycles.
Similarly, if there is conditional code or a loop in the inline function,
the branch prediction unit gets stressed more.
Unfortunatly, this is not an effect that you can simply measure on a per
function basis to find out whether inlining it is faster or not. It's more
like a tendency, and it likely depends on the CPU model, even for different
CPUs of the same architecture.
Oct 18 '05 #6
ben
> Is that the same story on template code, where the implementation is
resident in a .hh file (or a .h file).

class whatever {
public:
template<typena me T>
void some_method(T& var) {}
};

If memory serves though, I think implementations in a header file is
already inlined?


They are, in fact, candidate for inlining. There are lots of functions
that are simply impossible to be inlined.

Even the 'inline' keyword would not guarantee the function to be
actually inlined. The compiler does a great job in deciding whether or
not inlining such a function would give you a performance gain.

Inlining is an optimization technique because it allows more thorough
data flow analysis across caller/callee. Where there's not much to be
optimized from caller/callee data flow analysis, there's not much to be
optimized from inlining, simply.

Ben
Oct 18 '05 #7
In article <43************ ***********@new s.optusnet.com. au>,
ben <be******@yahoo .com.au> wrote:
If memory serves though, I think implementations in a header file is
already inlined?


They are, in fact, candidate for inlining. There are lots of functions
that are simply impossible to be inlined.


I think the OP was referring to implicitly inlines, which happen
in classes_ not in headers per se. But OP, he's right: just having
a function in a header does not automatically have it being inline'd.
Ditto for using the inline keyword is not the sole determination
for inline'ing nor is its absence (implicitly or otherwise)
the sole determination for not inline'ing. In the end it's
a hint and the compiler can get along w/o it, or use the advise.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Oct 18 '05 #8

ma******@gmail. com wrote:
Rolf Magnus wrote:
GJ wrote:
The performance can be DEGRADED by making a function "inline". Is it TRUE
in any case ?


Yes.

Is that the same story on template code, where the implementation is
resident in a .hh file (or a .h file).

class whatever {
public:
template<typena me T>
void some_method(T& var) {}
};

If memory serves though, I think implementations in a header file is
already inlined?


If the implementation of a class method appears within a class
declaration yes it has been declared inline.

Function templates are not declared inline merely by virtue of being
defined in a header file. It is still necessary to specify the inline
keyword if the intent is to declare a function template inline.

Greg

Oct 18 '05 #9
Rolf Magnus wrote:
If the function gets called from many places, too much inlining can increase
code size significantly, which will lower the cache efficiency on systems
that do use caching (which is the majority these days).
On modern workstation-like computers,
the cache is extremely important for fast code execution.
Reading a value from RAM can take several hundred clock cycles.
Similarly, if there is conditional code or a loop in the inline function,
the branch prediction unit gets stressed more.
Unfortunatly, this is not an effect that you can simply measure on a per
function basis to find out whether inlining it is faster or not.
It's more like a tendency, and it likely depends on the CPU model,
even for different CPUs of the same architecture.


This is pure nonsense.
You can't contrive an example that will show this.
Oct 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
746
by: Rubén Campos | last post by:
I haven't found any previous message related to what I'm going to ask here, but accept my anticipated excuses if I'm wrong. I want to ask about the real usefulness of the 'inline' keyword. I've read many authors (and it's my belief, too) who discourage the use of the 'inline' keyword, because: - The 'inline' word only advice the compiler about wich functions should be expanded, but not force it to expand them. Also, the compiler can...
2
1252
by: Steven T. Hatton | last post by:
I don't really understand the details of what happens when a compiler inlines a given function. I know that basically it's supposed to cause the function to be placed directly on the stack per invocation (or something like that.) That would be in contrast to loading one instance of the function and branching to it each time. I don't believe that means I would have a separate instance of a member function loaded per object instance. But...
8
1748
by: John Ratliff | last post by:
Can the compiler ever inline a method when there is a pointer to the member used? Thanks, --John Ratliff
1
2795
by: dandorey1 | last post by:
I'm currently in the process of writing a realtime telephony application. I've designed it with a fairly simply plugin architecture. When I first started reading about this the general suggestion was to load each plugin in a seperate app domain. However performance is a large concern for me. Can anyone give me an idea of the performance impact I'm going to take if I do start using a different app domain? Many of these plugins will be...
32
2098
by: Immortal Nephi | last post by:
I want to know if the practice is the best. Do I need to place inline keyword inside class definition or outside member function definition. For example class A { public: A(); ~A();
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.