Thread: Why doesn't Jagex use Bitwise OR for their buffers?

Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 39
  1. #11  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,611
    Thanks
    490
    Thanked 590 Times in 383 Posts
    Rep Power
    884
    In other words, it's platform dependant. A decent JVM implementation should apply optimisations if something like that is the case. For the developer, on the other hand, they're semantically equivalent here and nothing else (besides syntax differences obviously...)
    ~iKilem
    Reply With Quote  
     

  2. #12  
    Registered Member
    Killer 99's Avatar
    Join Date
    Dec 2007
    Posts
    1,436
    Thanks
    166
    Thanked 483 Times in 190 Posts
    Rep Power
    386
    Quote Originally Posted by iKilem View Post
    In other words, it's platform dependant. A decent JVM implementation should apply optimisations if something like that is the case. For the developer, on the other hand, they're semantically equivalent here and nothing else (besides syntax differences obviously...)
    There is absolutely no reason the bitwise or operator is slower than the addition operator unless the processor is specifically built for things like addition, which afaik no commercial ones are...

    and afaik the jvm optimization does not go that deep into code to check if certain bit ranges are effected that it might be able to just use bitwise or.

    it's not at all a syntax difference, it's a literal operation difference, the processor will be using a completely different circuit

    and finally, the os does not effect those instructions, lol

    Quote Originally Posted by Thee End View Post
    the performance gain, if any, is negligible.

    ------------
    they've used it for 10 years, so obviously back then it made a difference, and arguably still does today.

    And with those functions you are talking about millions of calls to it, serious statement



    Well anyway after all of these dull arguments, Flamable presented the best and most logical answer to the question, which makes a lot of sense to me
    Reply With Quote  
     

  3. Thankful user:


  4. #13  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,611
    Thanks
    490
    Thanked 590 Times in 383 Posts
    Rep Power
    884
    Quote Originally Posted by Killer 99 View Post
    There is absolutely no reason the bitwise or operator is slower than the addition operator unless the processor is specifically built for things like addition, which afaik no commercial ones are...

    and afaik the jvm optimization does not go that deep into code to check if certain bit ranges are effected that it might be able to just use bitwise or.

    it's not at all a syntax difference, it's a literal operation difference, the processor will be using a completely different circuit

    and finally, the os does not effect those instructions, lol
    I never said it was slower nor did I say the OS had any influence. I was referring to the CPU and the JVM when I said "platform".

    >It's a literal operation difference
    For the developer, not really. Even if the JVM doesn't do any optimisations, it's still negligible for something like this, like Thee End said.
    ~iKilem
    Reply With Quote  
     

  5. #14  
    Registered Member
    Killer 99's Avatar
    Join Date
    Dec 2007
    Posts
    1,436
    Thanks
    166
    Thanked 483 Times in 190 Posts
    Rep Power
    386
    Quote Originally Posted by iKilem View Post
    I never said it was slower nor did I say the OS had any influence. I was referring to the CPU and the JVM when I said "platform".

    >It's a literal operation difference
    For the developer, not really. Even if the JVM doesn't do any optimisations, it's still negligible for something like this, like Thee End said.
    Computing platform - Wikipedia, the free encyclopedia

    x86 instruction listings - Wikipedia, the free encyclopedia

    Code:
    ADD
    Code:
    OR

    Okay?
    Reply With Quote  
     

  6. #15  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,611
    Thanks
    490
    Thanked 590 Times in 383 Posts
    Rep Power
    884
    God damn you're a moron. Just because I say it's platform-dependant doesn't mean I consider the operating system to make a difference. The CPU and the JVM do, so it is platform-dependant. Why are you linking me to the x86 instruction set? Read my post carefully this time. Whether you use the addition operator or the bitwise OR operator in this case doesn't make a difference in terms of functionality. They are semantically equivalent. As far as the Java programmer is concerned, neither should impact performance more than the other. It's platform dependant. It's entirely down to preference. (I would personally use OR for consistency, but nonetheless...)
    ~iKilem
    Reply With Quote  
     

  7. #16  
    Programmer
    fl3x's Avatar
    Join Date
    Aug 2010
    Posts
    165
    Thanks
    47
    Thanked 43 Times in 26 Posts
    Rep Power
    0
    Quote Originally Posted by iKilem View Post
    God damn you're a moron. Just because I say it's platform-dependant doesn't mean I consider the operating system to make a difference. The CPU and the JVM do, so it is platform-dependant. Why are you linking me to the x86 instruction set? Read my post carefully this time. Whether you use the addition operator or the bitwise OR operator in this case doesn't make a difference in terms of functionality. They are semantically equivalent. As far as the Java programmer is concerned, neither should impact performance more than the other. It's platform dependant. It's entirely down to preference. (I would personally use OR for consistency, but nonetheless...)
    No it isn't. | is the correct choice. If you have two things that both always work, and one is most of the time faster, you'd have to be as stupid as you not to use it without alterior factors affecting your decision. I'd have to go with the guy that said it could affect their math obfuscation.
    Reply With Quote  
     

  8. #17  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,611
    Thanks
    490
    Thanked 590 Times in 383 Posts
    Rep Power
    884
    Quote Originally Posted by fl3x View Post
    No it isn't. | is the correct choice. If you have two things that both always work, and one is most of the time faster, you'd have to be as stupid as you not to use it without alterior factors affecting your decision. I'd have to go with the guy that said it could affect their math obfuscation.
    Don't get me wrong, I would use OR as well, but I wouldn't criticise someone for using addition either, for the reasons already stated. It's not most of the time faster. I don't think addition is used in the client due to the obfuscation, because it's been like that in the older clients which didn't mess with addition/subtraction.
    ~iKilem
    Reply With Quote  
     

  9. #18  
    Registered Member
    Killer 99's Avatar
    Join Date
    Dec 2007
    Posts
    1,436
    Thanks
    166
    Thanked 483 Times in 190 Posts
    Rep Power
    386
    Quote Originally Posted by iKilem View Post
    Don't get me wrong, I would use OR as well, but I wouldn't criticise someone for using addition either, for the reasons already stated. It's not most of the time faster. I don't think addition is used in the client due to the obfuscation, because it's been like that in the older clients which didn't mess with addition/subtraction.
    In RSC they used to multiply by 256 rather than using <<, so maybe they have room for improvement. If you want to use something that is slower, maybe not by much, but slower then go right ahead no one is stopping you. I'd like to note that java.nio.ByteBuffer uses OR. @"It's not most of the timer faster" It will always be faster it's just a matter of how much faster, no one has presented any benchmarks so buzz off and stop trying to defend it just because you don't like being wrong. Of course you are going to make a snotty response about me saying that, but do I really care? No, this was just a simple question I had and I didn't want some guy who probably doesn't even know how to use bit-wise operators tell me how a computer works
    Reply With Quote  
     

  10. Thankful user:


  11. #19  
    Registered Member

    Join Date
    Jan 2008
    Posts
    2,611
    Thanks
    490
    Thanked 590 Times in 383 Posts
    Rep Power
    884
    Quote Originally Posted by Killer 99 View Post
    In RSC they used to multiply by 256 rather than using <<, so maybe they have room for improvement. If you want to use something that is slower, maybe not by much, but slower then go right ahead no one is stopping you. I'd like to note that java.nio.ByteBuffer uses OR. @"It's not most of the timer faster" It will always be faster it's just a matter of how much faster, no one has presented any benchmarks so buzz off and stop trying to defend it just because you don't like being wrong. Of course you are going to make a snotty response about me saying that, but do I really care? No, this was just a simple question I had and I didn't want some guy who probably doesn't even know how to use bit-wise operators tell me how a computer works
    I disagree with the statement "it's faster most of the time" because it depends on the platform. If in practice it does turn out to be the case, then it's correct in that sense, sure. Benchmarks aren't really relevant to what I'm saying. Whether java.nio.ByteBuffer uses OR depends on the implementation. See this: java.nio: ByteBufferHelper.java. It's used by some class ByteBufferImpl that extends ByteBuffer. It uses addition.
    ~iKilem
    Reply With Quote  
     

  12. #20  
    Programmer
    fl3x's Avatar
    Join Date
    Aug 2010
    Posts
    165
    Thanks
    47
    Thanked 43 Times in 26 Posts
    Rep Power
    0
    Quote Originally Posted by iKilem View Post
    I disagree with the statement "it's faster most of the time" because it depends on the platform. If in practice it does turn out to be the case, then it's correct in that sense, sure. Benchmarks aren't really relevant to what I'm saying. Whether java.nio.ByteBuffer uses OR depends on the implementation. See this: java.nio: ByteBufferHelper.java. It's used by some class ByteBufferImpl that extends ByteBuffer. It uses addition.
    No. It is a simpler operation, period. It will always be faster. Are you too stupid to understand that?
    Reply With Quote  
     


Page 2 of 4 FirstFirst 1234 LastLast
Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Buffers for C I/O!
    By Cups in forum Application Development
    Replies: 9
    Last Post: 10-18-2011, 11:55 PM
  2. Bitwise opperators in java
    By Pilldom in forum Help
    Replies: 2
    Last Post: 07-20-2011, 04:55 AM
  3. Bitwise help
    By Lmctruck30 in forum Help
    Replies: 3
    Last Post: 06-26-2010, 06:02 PM
  4. My calculation of bitwise operators
    By 03data in forum Application Development
    Replies: 10
    Last Post: 05-24-2010, 07:42 PM
  5. Flipping the Stream buffers
    By Virus X3 in forum Help
    Replies: 3
    Last Post: 12-16-2009, 04:39 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •