Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hadoop中map、shuffle、merge和reduce时间的精确定义_Hadoop - Fatal编程技术网

Hadoop中map、shuffle、merge和reduce时间的精确定义

Hadoop中map、shuffle、merge和reduce时间的精确定义,hadoop,Hadoop,在Hadoop中,作业执行后会提供以下指标: 地图时间 缩短时间 洗牌时间 合并时间 我找不到这些时间的确切定义,因为所有来源都不清楚这些时间是如何准确计算的。我是这样看的: 映射时间是读取输入并应用映射功能和对数据进行排序的时间 Reduce time是应用Reduce函数并写入输出的时间 Shuffle time是将映射排序后的数据传输到还原器的时间 Merge time是仅在reduce侧合并映射输出的时间 我对粗体字的东西没有把握。我的分析正确吗?我决定研究Hadoop代码以获得

在Hadoop中,作业执行后会提供以下指标:

  • 地图时间
  • 缩短时间
  • 洗牌时间
  • 合并时间
我找不到这些时间的确切定义,因为所有来源都不清楚这些时间是如何准确计算的。我是这样看的:

  • 映射时间是读取输入并应用映射功能和对数据进行排序的时间
  • Reduce time是应用Reduce函数并写入输出的时间
  • Shuffle time是将映射排序后的数据传输到还原器的时间
  • Merge time是仅在reduce侧合并映射输出的时间

我对粗体字的东西没有把握。我的分析正确吗?

我决定研究Hadoop代码以获得更多的洞察力。下图解释了我的发现。

我发现:

  • 映射时间是映射任务所用的时间。Map任务负责读取输入、应用Map功能、排序数据和合并数据
  • 洗牌时间是将映射输出数据复制到reduce任务的时间,这是reduce任务的一部分
  • 合并时间是在reduce端合并映射输出的时间,这是reduce任务的一部分
  • Reduce time是应用Reduce函数并写入输出的时间
以下代码支持这些发现:

在a使用的类中,我们看到“复制”阶段后面跟着“排序”阶段

在这个类中,我们看到shuffletime是排序阶段之前的时间,而排序时间是shuffle和reduce阶段之间的时间

public void setPhase(Phase phase){
  TaskStatus.Phase oldPhase = getPhase();
  if (oldPhase != phase){
    // sort phase started
    if (phase == TaskStatus.Phase.SORT){
      if (oldPhase == TaskStatus.Phase.MAP) {
        setMapFinishTime(System.currentTimeMillis());
      }
      else {
        setShuffleFinishTime(System.currentTimeMillis());
      }
    }else if (phase == TaskStatus.Phase.REDUCE){
      setSortFinishTime(System.currentTimeMillis());
    }
    this.phase = phase;
  }
  ...
在这个类中,我们看到洗牌时间对应于复制时间,合并时间就是我们上面提到的“排序”时间

switch (task.getType()) {
    case MAP:
      successfulMapAttempts += successful;
      failedMapAttempts += failed;
      killedMapAttempts += killed;
      if (attempt.getState() == TaskAttemptState.SUCCEEDED) {
        numMaps++;
        avgMapTime += (attempt.getFinishTime() - attempt.getLaunchTime());
      }
      break;
    case REDUCE:
      successfulReduceAttempts += successful;
      failedReduceAttempts += failed;
      killedReduceAttempts += killed;
      if (attempt.getState() == TaskAttemptState.SUCCEEDED) {
        numReduces++;
        avgShuffleTime += (attempt.getShuffleFinishTime() - attempt
            .getLaunchTime());
        avgMergeTime += attempt.getSortFinishTime()
            - attempt.getShuffleFinishTime();
        avgReduceTime += (attempt.getFinishTime() - attempt
            .getSortFinishTime());
      }
}
关于reduce和map任务如何工作的更多信息可以分别从类和派生

最后,我想指出,我在链接中提到的源代码主要对应于Hadoop 2.7.1代码

switch (task.getType()) {
    case MAP:
      successfulMapAttempts += successful;
      failedMapAttempts += failed;
      killedMapAttempts += killed;
      if (attempt.getState() == TaskAttemptState.SUCCEEDED) {
        numMaps++;
        avgMapTime += (attempt.getFinishTime() - attempt.getLaunchTime());
      }
      break;
    case REDUCE:
      successfulReduceAttempts += successful;
      failedReduceAttempts += failed;
      killedReduceAttempts += killed;
      if (attempt.getState() == TaskAttemptState.SUCCEEDED) {
        numReduces++;
        avgShuffleTime += (attempt.getShuffleFinishTime() - attempt
            .getLaunchTime());
        avgMergeTime += attempt.getSortFinishTime()
            - attempt.getShuffleFinishTime();
        avgReduceTime += (attempt.getFinishTime() - attempt
            .getSortFinishTime());
      }
}