spark最適化データ構造(メモリ削減)

1184 ワード

公式サイトでは、
The first way to reduce memory consumption is to avoid the Java features that add overhead, such as pointer-based data structures and wrapper objects. There are several ways to do this:
1、Design your data structures to prefer arrays of objects, and primitive types, instead of the standard Java or Scala collection classes (e.g. HashMap). The fastutil library provides convenient collection classes for primitive types that are compatible with the Java standard library. 2、Avoid nested structures with a lot of small objects and pointers when possible. 3、Consider using numeric IDs or enumeration objects instead of strings for keys. 4、If you have less than 32 GB of RAM, set the JVM flag -XX:+UseCompressedOops to make pointers be four bytes instead of eight. You can add these options in spark-env.sh.

要するに、hashmap、linkedlistなどの複雑なタイプを使用するのではなく、オリジナルタイプまたは配列をできるだけ使用します.これは、より多くのストレージスペースを消費するためです.
次に、多くの小さなオブジェクトのネストされた構造のポインタを使用しないでください.(これはあまり読めませんでした)
次に、文字列を使用しないで、できるだけ数値、または列挙タイプを使用します.文字列はより多くのメモリ領域を消費するためです.
ノードメモリが32 G未満の場合(なぜ32 Gになるのか分からない)、設計JVMパラメータ-XX:+UseCompressedOpsはオブジェクトポインタを使用して8バイトから4バイトに変更します.