GitHub user sitalkedia opened a pull request:

    https://github.com/apache/spark/pull/12074

    [SPARK-14277] UnsafeSorterSpillReader should do buffered read from un…

    ## What changes were proposed in this pull request?
    
    While running a Spark job which is spilling a lot of data in reduce phase, 
we see that significant amount of CPU is being consumed in native Snappy 
ArrayCopy method (Please see the stack trace below).
    Stack trace - 
    org.xerial.snappy.SnappyNative.$$YJP$$arrayCopy(Native Method)
    org.xerial.snappy.SnappyNative.arrayCopy(SnappyNative.java)
    org.xerial.snappy.Snappy.arrayCopy(Snappy.java:85)
    org.xerial.snappy.SnappyInputStream.rawRead(SnappyInputStream.java:190)
    org.xerial.snappy.SnappyInputStream.read(SnappyInputStream.java:163)
    java.io.DataInputStream.readFully(DataInputStream.java:195)
    java.io.DataInputStream.readLong(DataInputStream.java:416)
    
org.apache.spark.util.collection.unsafe.sort.UnsafeSorterSpillReader.loadNext(UnsafeSorterSpillReader.java:71)
    
org.apache.spark.util.collection.unsafe.sort.UnsafeSorterSpillMerger$2.loadNext(UnsafeSorterSpillMerger.java:79)
    
org.apache.spark.sql.execution.UnsafeExternalRowSorter$1.next(UnsafeExternalRowSorter.java:136)
    
org.apache.spark.sql.execution.UnsafeExternalRowSorter$1.next(UnsafeExternalRowSorter.java:123)
    The reason for that is the SpillReader does a lot of small reads from the 
underlying snappy compressed stream and we pay a heavy cost of jni calls for 
these small reads. The SpillReader should instead do a buffered read from the 
underlying snappy compressed stream.
    
    
    ## How was this patch tested?
    
    Tested by running the job and we saw more than 10% cpu savings.
    
    (If this patch involves UI changes, please attach a screenshot; otherwise, 
remove this)
    
    
    …derlying compression stream

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sitalkedia/spark bufferedReader

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12074.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12074
    
----

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to