3 ms·
I am interested in programming language theory and development but I am a beginner in both. Do JIT compilers suffer from boxing pointer chasing primitives sin
by samsquire 4y ago
I am interested in programming language theory and development but I am a beginner in both.
Do JIT compilers suffer from boxing pointer chasing primitives since everything is an object and not a memory location value type?
Can hot loops over arrays be efficient if every item in the array is a pointer?
- kaba0 4y agoI am by no means an expert on the topic, but I don’t think that “array of pointers”-chasing is the primary performance bottle neck of most managed language. It happens all too often with C programs as well (or even worse, linked lists) and if the pointed to objects are close to each other in memory/are in cache (as they might be in case of a generational GC) than it is not a big performance hit. Also, most apps don’t spend most of their time in a hot loop iterating over arrays, ordinary programs seldom have huge arrays. Dynamic properties, non-uniform object shapes may be more responsible for this generic slowness of very dynamic languages, and from what I gathered assuming a shape for these objects constitutes a kind of advanced optimization (done by JS engines, truffleruby, not sure about these engines), even if its done depending on language idioms it may not give that big of a boost. Ruby is a very dynamic language with e.g. hitting not implememted methods and dynamically handling, etc.
- samsquire 4y agoThank you for your explanation. My understanding is that determining jump target at compile time is a big source of performance gain at runtime. If you know the function to jump to at compile time and not wait to runtime to decide where to jump. I've looked into arrays of structs and structs or arrays for performance. But I am curious how to create a managed language that is fast. I think we look Java and C# for guidance.
- kaba0 4y ago> If you know the function to jump to at compile time and not wait to runtime to decide where to jump Well, I don’t know about more dynamic languages, but single dispatch can be very well optimized away, Java for example can determine how many possible implementation of a given method is loaded, and simply JIT compile or even inline the function if there is only a single implementation. Later, it can deoptimize that call, e.g. when a new class is loaded at runtime that also implements that method. This is one area where JIT is definitely in a better position than AOT compilers.