Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19222#discussion_r174361814
  
    --- Diff: 
common/unsafe/src/main/java/org/apache/spark/unsafe/array/LongArray.java ---
    @@ -80,7 +76,7 @@ public void zeroOut() {
       public void set(int index, long value) {
         assert index >= 0 : "index (" + index + ") should >= 0";
         assert index < length : "index (" + index + ") should < length (" + 
length + ")";
    -    Platform.putLong(baseObj, baseOffset + index * WIDTH, value);
    +    memory.putLong(memory.getBaseOffset() + index * WIDTH, value);
    --- End diff --
    
    @cloud-fan good point. We will want use `memory.putLong(index * WIDTH, 
value).
    I expect that JIT compiler could move loop invariants out of a loop or 
could map the sequence to a scaled index instruction `move targetreg, [basereg 
+ scalereg * constant + offsetreg]` well.
    
    I will investigate what happens in the native code using the example that 
you pointed out.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to