inline functions

P

Peter van Merkerk

E. Robert Tisdale said:
The typical application here at the Lab is about 2 MBytes.
The typical processing node has 2 GBytes memory --
the application code absorbs about 0.1% of that.

That is all very nice...but how big is your processor cache? A L1 cache
is usually only a few kilobytes, L2 caches typically a few hundred
kilobytes and if you are lucky enough to have a L3 cache you might get
up to a few Megabytes. Unfortunately the larger the cache the slower it
gets (that is why there are multiple cache levels instead of just one
big cache). On todays processors running at high clock frequencies cache
misses are performance wise very expensive. In other words code bloat is
not just about memory usage but potentially also hurts performance. When
writing high performance code, memory usage and memory access patterns
are a concern.

Note that inlining does not necessarily result in more code. For very
small functions the inlined code may be less than the code needed to
call a non-inlined function. Hence inlining should be used judiciously.
 
E

E. Robert Tisdale

That is all very nice...but how big is your processor cache?
An L1 cache is usually only a few kilobytes,
L2 caches typically a few hundred kilobytes and,
if you are lucky enough to have a L3 cache,
you might get up to a few Megabytes.
Unfortunately, the larger the cache the slower it gets
(that is why there are multiple cache levels instead of just one big cache).
On todays processors, running at high clock frequencies, cache
misses are performance wise very expensive.
In other words, code bloat is not just about memory usage
but potentially also hurts performance.
When writing high performance code,
memory usage and memory access patterns are a concern.

I don't see this in the applications that we run.
But I don't claim that our application are typical.
They are high perfprmance numerical (usually data processing)
algorithms that spend most of their time in tight loops
which will easily fit in the L1 [instruction] cache.

Can you show us an application
where performance is affected by "code bloat"?
Note that inlining does not necessarily result in more code.
For very small functions, the inlined code
may be less than the code needed to call a non-inlined function.
Hence inlining should be used judiciously.

Please show us an example C++ program
where code runs slower when functions are inlined.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,501
Latest member
Ledmyplace

Latest Threads

Top