Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 235 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(meaningful) cost of the jump instruction?

#1
I'm sorry... (premature) optimization is the root of all evil, but I'd like to know: how much more costly is to have a `jmp` instruction vs. not have it (branchless code)? I'm after the methodology for knowing how to calculate these things. This is purely exploratory, not practical, I'm trying to find my way into a theoretical problem and my testing code brought this up. Thanks.
Reply

#2
Well, it is better not to jump. In the early days conditional jumps were written so that the most probable condition wouldn't cause a jump. So not needing any instruction at all is obviously faster, but I can't tell you how costly it is compared to other instructions. Maybe you should measure a billion jumps one way or the other...

Reply

#3
You'll have to test it on your architecture if you really want to know.

But in general, on modern processors, there is minimal cost for an unconditional jump. It's basically pretty much free apart from a very small amount of instruction cache overhead. It will probably get executed in parallel with neighbouring instructions so might not even cost you a clock cycle. This is because the jump can be executed by one of several parallel [execution units][1].

Look at it this way - a single read of main memory is probably 100-200 times more expensive.

It's a subset of [branch prediction][2] more generally, but there no risk of a branch misprediction so you are safe from having to flush the [instruction pipeline][3], which is the main cost associated with conditional jumps.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through