Operation Costs in CPU Clock Cycles
ithare.com
Operation Costs in CPU Clock Cycles
1–10 of 69 posts
Re: Operation Costs in CPU Clock Cycles
#2Re: Operation Costs in CPU Clock Cycles
#3Re: Operation Costs in CPU Clock Cycles
#4The small difference between direct C calls and virtual C++ calls surprised me, actually. I thought it would be much bigger.
Re: Operation Costs in CPU Clock Cycles
#5Great overview! Would be even better as a general guideline if it included costs for HD/SSD disk writes and network usage!
Re: Operation Costs in CPU Clock Cycles
#6The small difference between direct C calls and virtual C++ calls surprised me, actually. I thought it would be much bigger.
A virtual call in C++ is just a vtable lookup then a direct C call. Literally one pointer away. (or perhaps one pointer then one integer addition away? For the offset)
Re: Operation Costs in CPU Clock Cycles
#7The small difference between direct C calls and virtual C++ calls surprised me, actually. I thought it would be much bigger.
Eric Brumer has a great talk on this: https://channel9.msdn.com/Events/Build/2013/4-329
Re: Operation Costs in CPU Clock Cycles
#8[1] http://www.cs.cmu.edu/~chensm/Big_Data_reading_group/papers/...
Re: Operation Costs in CPU Clock Cycles
#9The small difference between direct C calls and virtual C++ calls surprised me, actually. I thought it would be much bigger.
As usual, memory access is the expensive operation. If the virtual function is already in L1 cache a virtual function should be only a minor slowdown. If it's all the way off in main memory it will be significantly slower. Eric Brumer has a great talk on this: https://channel9.msdn.com/Events/Build/2013/4-329
Still worth noting that every VM like Java or .NET or LuaJIT will optimize for the case that a virtual call usually has only one or two commonly invoked target functions. They will use a conditional fast-path for the common case(s) and fall back to slower virtual calls or less optimized paths for megamorphic calls. I don't know if any C++ compilers do this kind of thing, but I would be surprised if they did not.
Re: Operation Costs in CPU Clock Cycles
#10Edit: never mind, it was not a Intel guy. And i actually had the thing bookmarked (and it still worked).
https://www.infoq.com/presentations/click-crash-course-moder...