Dereferencing Performance Hit

Started by
7 comments, last by Emmanuel Deloget 18 years, 11 months ago
How hard is the performance hit from dereferencing too much? My engine uses a lot of perhaps unneccesary dereferencing which I was thinking of changing if the performance difference was really big.
Advertisement
I don't have any exact numbers, but I believe a random access to RAM takes in the order of 100'ish cycles.
If you're reading sequentially (or even better, the data is already in the CPU cache) it shouldn't be more than a handful of cycles.

I suppose the best answer is "try changing it and see what happens" ;)
The best answer is: Profile first.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Quote:Original post by Washu
The best answer is: Profile first.
Seconded!
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Quote:Original post by iMalc
Quote:Original post by Washu
The best answer is: Profile first.
Seconded!


Thirded[smile]

The largest performance cost of dereferencing will come from cache misses (assuming you don't get any virtual memory page faults of course).

How badly cache misses are hurting you depends entirely on the code and data in your application, that's why there's no "one size fits all" answer and why you *must* profile.

It could be that the majority of the dereferencing in your app has great locality of reference - in which case it's probably not a problem; OTOH you might be suffering lots. The design of your application; your use of the programming language; your programming style; the compiler options in use; the version and type of compiler itself - they all can have an effect!
[oops, AP was me, sorry]

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Ok, will do.
Quote:Original post by Washu
The best answer is: Profile first.


Hmm, my best answer would be "If they're really unneccesary as you say, then you might as well get rid of them". ;)
They don't make the code simpler, and they are associated with a performance hit, even if it's not exactly huge.

Of course, if by "unneccsary" you mean "I could probably do without them, but it'd be messy", then do as Washu said. But if there's no reason whatsoever to use all this dereferencing, then you might as well get rid of it
Quote:Original post by Anonymous Poster
Quote:Original post by iMalc
Quote:Original post by Washu
The best answer is: Profile first.
Seconded!


Thirded[smile]


It's weird... "profile thirded?"

Oups, sorry, I shot in the wrong forum... [wink]

This topic is closed to new replies.

Advertisement