Sign in to follow this  

Dereferencing Performance Hit

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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" ;)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this