David Mollitor created SPARK-59382:
--------------------------------------

             Summary: Avoid redundant volatile reads of lazy caches in 
UTF8String
                 Key: SPARK-59382
                 URL: https://issues.apache.org/jira/browse/SPARK-59382
             Project: Spark
          Issue Type: Improvement
          Components: Spark Core
    Affects Versions: 4.1.0
            Reporter: David Mollitor


h2. Summary

{{UTF8String}} lazily computes and caches several values in {{volatile}} 
fields: {{numChars}}, {{isFullAscii}}, {{isValid}}, and {{numBytesValid}}. The 
accessor methods read the {{volatile}} field two (or three) times per call -- 
the "is it computed yet" check plus the return -- and two callers invoke 
{{numChars()}} twice. A {{volatile}} read cannot be kept in a register or 
hoisted by the JIT, and on AArch64 it compiles to a load-acquire ({{ldar}}) 
rather than a plain load. This reads each field once into a local, halving the 
volatile reads on the warm path.

This is a small, behavior-preserving micro-optimization; no functional change.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to