gpt4 book ai didi

hadoop - 为什么只有映射器的工作在真实集群中如此缓慢?

转载 作者:可可西里 更新时间:2023-11-01 16:34:42 24 4
gpt4 key购买 nike

我有一份映射器 PrepareData only 的工作,它需要将文本数据转换为 SequencialFile,使用 VLongWritable 作为 keyDoubleArrayWritable 作为一个

当我运行 455000x90 (~384 Mb) 数据时,例如:

13.124,123.12,12.12,... 1.12

23.12,1.5,12.6,... 6.123

...

本地模式下平均需要:

  1. 在 Athlon 64 X2 双核 5600+ 上 51 秒,2.79Γгц;
  2. 在 Athlon 64 处理器 3700+ 上 54 秒,1Γгц;

=> 平均 52-53 秒。

但是当我用这两台机器(Athlon 64 X2 双核 5600+、3700+)在真实集群中运行它时,最好的情况下需要 81 秒。

使用 4 个映射器( block 大小约为 96 MB)和 2 个缩减器执行的作业。

集群由 Hadoop 0.21.0 提供支持,配置为 jvm 重用。

映射器:

public class PrepareDataMapper
extends Mapper<LongWritable, Text, VLongWritable, DoubleArrayWritable> {

private int size;

// hint
private DoubleWritable[] doubleArray;
private DoubleArrayWritable mapperOutArray = new DoubleArrayWritable();
private VLongWritable mapOutKey = new VLongWritable();

@Override
protected void setup(Context context) throws IOException {
Configuration conf = context.getConfiguration();
size = conf.getInt("dataDimSize", 0);
doubleArray = new DoubleWritable[size];
for (int i = 0; i < size; i++) {
doubleArray[i] = new DoubleWritable();
}
}

@Override
public void map(
LongWritable key,
Text row,
Context context) throws IOException, InterruptedException {
String[] fields = row.toString().split(",");
for (int i = 0; i < size; i++) {
doubleArray[i].set(Double.valueOf(fields[i]));
}
mapperOutArray.set(doubleArray);
mapOutKey.set(key.get());
context.write(mapOutKey, mapperOutArray);
}
}

DoubleArrayWritable:

public class DoubleArrayWritable extends ArrayWritable {

public DoubleArrayWritable() {
super(DoubleWritable.class);
}

public DoubleArrayWritable(DoubleWritable[] values) {
super(DoubleWritable.class, values);
}

public void set(DoubleWritable[] values) {
super.set(values);
}

public DoubleWritable get(int idx) {
return (DoubleWritable) get()[idx];
}

public double[] getVector(int from, int to) {
int sz = to - from + 1;
double[] vector = new double[sz];
for (int i = from; i <= to; i++) {
vector[i-from] = get(i).get();
}
return vector;
}
}

最佳答案

我猜想不同之处在于工作启动时间。对于本地模式是几秒,而对于集群通常是几十秒。
要验证此假设,您可以放置​​更多数据并验证集群性能是否比单节点更好。
其他可能的原因 - 您可能没有足够的映射器来充分利用您的硬件。我建议尝试映射器数量 x 2 您拥有的核心数量。

关于hadoop - 为什么只有映射器的工作在真实集群中如此缓慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8120311/

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