spark tungsten-sort shuffle 基于内存和CPU的瓶颈,Spark引入tungsten来改善性能。其中在shuffle中,引入了tungsten-sort shuflle。 tungsten-sort shuffle是基于java的Unsafe包实现的,相关的三个ShuffleWriter如下: writer desc ByPassMergeSortShuffleWriter 和hashShuffle实现基本相同,区别在与map task会输出汇总为一个文件。 SortShuffleWriter Sort Shuffle,在Map端基于partititonId排序,将所有的输出结果写入到一个文件中 UnsafeShuffleWriter Tungsten-sort,对序列化的指针进行排序,而不用进行序列化和反序列化的过程,减轻GC开销 SortShuffle在Spark Shuffle中介绍过,这里介绍下UnsafeShuffleWriter。 顾名思义,Writer的主要作用是进行Map端的写操作,看一下他的Writer方法。 public void write(scala.collection.Iterator<Product2<K, V>> records) throws IOException { // Keep track of success so we know if we encountered an exception // We do this rather than a standard try/catch/re-throw to handle // generic throwables.