Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8509005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:18:56+00:00 2026-06-11T03:18:56+00:00

The documentation seems to be wrong. Could someone tell me which is true? In

  • 0

The documentation seems to be wrong. Could someone tell me which is true?

In Performance Myths section is:

On devices without a JIT, caching field accesses is about 20% faster than repeatedly accesssing the field. With a JIT, field access costs about the same as local access.

In Avoid Internal Getters/Setters section is:

Without a JIT, direct field access is about 3x faster than invoking a trivial getter. With the JIT (where direct field access is as cheap as accessing a local), direct field access is about 7x faster than invoking a trivial getter.

It’s clear that without JIT local access is faster. It’s also clear that accessing field is faster while accessing directly than with getter.

But why in the first case performance is 20% better and in the second case performance is 133% better for the same reason, that is JIT optimization for calling object field?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:18:58+00:00Added an answer on June 11, 2026 at 3:18 am

    I think you’re comparing apples and oranges. the Performance Myths reference discusses the advantage of a JIT for field access, while the second reference discusses the advantage of a JIT for method access.

    As I understand it, an analogy for direct field access vs. local access (not local field access as you wrote in your post – there is no such thing as a local field) is the following:

    class foo {
        int bar = 42;
    
        int doStuff(){
            int x = 1;
            x += bar;
            x += bar;
            x += bar;
            return x;
        }
    }
    

    Each reference to bar has an associated performance cost. A good compiler will recognize the opportunity for optimization and ‘rewrite’ the code as such:

    int doStuff(){
        int x = 1f;
        int local_bar = bar;
        x += local_bar;
        x += local_bar;
        x += local_bar;
        return x;
    }
    

    Without a JIT, this is a handy optimization, which gets you a 20% bump in performance.

    With a JIT, the optimization is unneccessary, as the JIT removes the performance hit from the access to bar in the first place.

    The second reference describes the following scenario:

    class foo {
        int bar = 42;
    
        int getBar() { return bar; }
    
        int doStuff(){
            int x = 1;
            x += getBar();
            x += getBar();
            x += getBar();
            return x;
        }
    }
    

    Each function call has an associated performance penalty. A compiler can NOT cache the multiple getBar() method calls (as it cached the multiple direct field accesses to bar in the previous example), because getBar() might return a completely different number each time it is called (i.e. if it had a random or time-based component to its return value). Therefore, it must execute three method calls.

    It is vital to understand that the above function would execute at approximatley the same speed with or without a JIT.

    If you were to manually replace getBar() in the above function with simply bar, you would achieve a performance boost. On a machine without a JIT, that performance boost is roughly 3x, because field access is still somewhat slow, so replacing the very slow methods with somewhat slow field accesses only yields a moderate boost. With a JIT, however, field access is fast, so replacing the very slow methods with fast field access yields a much greater (7x) boost.

    I hope that makes sense!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following MongoDB documentation example seems to be wrong. Any suggestion? a== 1 and a
Is the documentation for Rich Edit Controls really as bad (wrong?) as it seems
So I'm using the excellent Ancestry gem But while the documentation seems very complete
I'm getting mixed signals. The warning in the PDO documentation seems pretty clear that
Reading the documentation it seems this might not be possible, but it seems that
I've gone over the SWIG FAQ and dynamic module documentation and there seems to
There seems to be a plethora of documentation tools for Python. Another one that
There seems to be a distinct lack of documentation of the GObjects module for
The documentation for .NET's Excel interop API at msdn.com seems rather sparse. Does anyone
reading the documentation for java org.w3c.dom.ls it seems as a Element only can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.