Apache Spark - 访问 RDD 上的内部数据?

Apache Spark - accessing internal data on RDDs?

我开始做 amp-camp 5 exercises。我尝试了以下两种情况:

场景 #1

val pagecounts = sc.textFile("data/pagecounts")
pagecounts.checkpoint
pagecounts.count

场景 #2

val pagecounts = sc.textFile("data/pagecounts")
pagecounts.count

两者在 Spark shell 应用程序 UI 中显示的总时间不同 场景。
场景#1用了0.5秒,而场景#2只用了0.2秒 s

在场景 #1 中,checkpoint 命令什么都不做,它既不是 转变也不是行动。它说一旦 RDD 实现 操作后,继续并保存到磁盘。我在这里错过了什么吗?

问题:

  1. 我知道场景 #1 需要更多时间,因为 RDD 是 检查点(写入磁盘)。有没有办法让我知道所花的时间 对于检查点,从总时间开始?
    Spark shell 应用程序 UI 显示以下内容 - 调度程序延迟、任务 反序列化时间、GC时间、Result序列化时间、获取结果 时间。但是,不显示检查点的故障。

  2. 有没有办法访问上述指标,例如调度程序延迟,GC 时间 并以编程方式保存它们?我想记录上面的一些指标 在 RDD 上调用的每个操作。

  3. 如何以编程方式访问以下信息:

    • RDD 的大小,当在检查点上持久化到磁盘时?
    • RDD 当前在内存中的百分比是多少?
    • 计算一个 RDD 的总时间?

如果您需要更多信息,请告诉我。

Spark REST API 几乎可以满足您的所有需求。

一些例子;

How much percentage of an RDD is in memory currently?

GET /api/v1/applications/[app-id]/storage/rdd/0

将回复:

{
  "id" : 0,
  "name" : "ParallelCollectionRDD",
  "numPartitions" : 2,
  "numCachedPartitions" : 2,
  "storageLevel" : "Memory Deserialized 1x Replicated",
  "memoryUsed" : 28000032,
  "diskUsed" : 0,
  "dataDistribution" : [ {
    "address" : "localhost:54984",
    "memoryUsed" : 28000032,
    "memoryRemaining" : 527755733,
    "diskUsed" : 0
  } ],
  "partitions" : [ {
    "blockName" : "rdd_0_0",
    "storageLevel" : "Memory Deserialized 1x Replicated",
    "memoryUsed" : 14000016,
    "diskUsed" : 0,
    "executors" : [ "localhost:54984" ]
  }, {
    "blockName" : "rdd_0_1",
    "storageLevel" : "Memory Deserialized 1x Replicated",
    "memoryUsed" : 14000016,
    "diskUsed" : 0,
    "executors" : [ "localhost:54984" ]
  } ]
}

Overall time taken for computing an RDD?

计算一个RDD也被称为Job、stage或attempt。 GET /applications/[app-id]/stages/[stage-id]/[stage-attempt-id]/taskSummary

将回复:

{
  "quantiles" : [ 0.05, 0.25, 0.5, 0.75, 0.95 ],
  "executorDeserializeTime" : [ 2.0, 2.0, 2.0, 2.0, 2.0 ],
  "executorRunTime" : [ 3.0, 3.0, 4.0, 4.0, 4.0 ],
  "resultSize" : [ 1457.0, 1457.0, 1457.0, 1457.0, 1457.0 ],
  "jvmGcTime" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "resultSerializationTime" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "memoryBytesSpilled" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "diskBytesSpilled" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "shuffleReadMetrics" : {
    "readBytes" : [ 340.0, 340.0, 342.0, 342.0, 342.0 ],
    "readRecords" : [ 10.0, 10.0, 10.0, 10.0, 10.0 ],
    "remoteBlocksFetched" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
    "localBlocksFetched" : [ 2.0, 2.0, 2.0, 2.0, 2.0 ],
    "fetchWaitTime" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
    "remoteBytesRead" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
    "totalBlocksFetched" : [ 2.0, 2.0, 2.0, 2.0, 2.0 ]
  }
}

你的问题太笼统了,我就不一一回复了。我相信 spark 必须反映的一切都反映在 REST API.