gpt4 book ai didi

scala - Spark 缓存 : RDD Only 8% cached

转载 作者:行者123 更新时间:2023-12-04 02:27:22 25 4
gpt4 key购买 nike

对于我的代码片段如下:

val levelsFile = sc.textFile(levelsFilePath)
val levelsSplitedFile = levelsFile.map(line => line.split(fileDelimiter, -1))
val levelPairRddtemp = levelsSplitedFile
.filter(linearr => ( linearr(pogIndex).length!=0))
.map(linearr => (linearr(pogIndex).toLong, levelsIndexes.map(x => linearr(x))
.filter(value => (!value.equalsIgnoreCase("") && !value.equalsIgnoreCase(" ") && !value.equalsIgnoreCase("null")))))
.mapValues(value => value.mkString(","))
.partitionBy(new HashPartitioner(24))
.persist(StorageLevel.MEMORY_ONLY_SER)

levelPairRddtemp.count // just to trigger rdd creation

信息
  • 文件大小为~4G
  • 我正在使用 2 executors (每个 5G)和
    12核。
  • Spark版本:1.5.2

  • 问题

    当我看着 SparkUIStorage tab ,我看到的是:

    enter image description here

    看内部 RDD , 似乎 24 个中只有 2 个 partitions被缓存。

    enter image description here

    对此行为的任何解释,以及如何解决此问题。

    编辑 1 :我刚刚尝试为 HashPartitioner 设置 60 个分区作为:
    ..
    .partitionBy(new HashPartitioner(60))
    ..

    工作过 .现在我得到了整个 RDD缓存。猜猜这里可能发生了什么?数据倾斜会导致这种行为吗?

    Edit-2 : 包含 BlockManagerInfo 的日志当我再次用 24 partitions 运行时.这次 3/24 partitions被缓存:
    16/03/17 14:15:28 INFO BlockManagerInfo: Added rdd_294_14 in memory on ip-10-1-34-66.ec2.internal:47526 (size: 107.3 MB, free: 2.6 GB) 
    16/03/17 14:15:30 INFO BlockManagerInfo: Added rdd_294_17 in memory on ip-10-1-34-65.ec2.internal:57300 (size: 107.3 MB, free: 2.6 GB)
    16/03/17 14:15:30 INFO BlockManagerInfo: Added rdd_294_21 in memory on ip-10-1-34-65.ec2.internal:57300 (size: 107.4 MB, free: 2.5 GB)

    最佳答案

    我相信这是因为达到了内存限制,或者更重要的是,您使用的内存选项不会让您的工作利用所有资源。

    增加#partitions 意味着减少每个任务的大小,这可能解释了行为。

    关于scala - Spark 缓存 : RDD Only 8% cached,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36058627/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com