Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
b4135dca
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b4135dca
编写于
2月 21, 2013
作者:
S
sewen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adjusted cost heuristics / comparisons.
上级
fad6d505
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
42 deletion
+43
-42
pact/pact-compiler/src/main/java/eu/stratosphere/pact/compiler/costs/Costs.java
.../main/java/eu/stratosphere/pact/compiler/costs/Costs.java
+15
-25
pact/pact-compiler/src/main/java/eu/stratosphere/pact/compiler/costs/DefaultCostEstimator.java
...tratosphere/pact/compiler/costs/DefaultCostEstimator.java
+28
-17
未找到文件。
pact/pact-compiler/src/main/java/eu/stratosphere/pact/compiler/costs/Costs.java
浏览文件 @
b4135dca
...
...
@@ -35,6 +35,8 @@ package eu.stratosphere.pact.compiler.costs;
*/
public
class
Costs
implements
Comparable
<
Costs
>,
Cloneable
{
public
static
final
long
UNKNOWN
=
-
1
;
private
long
networkCost
;
// network cost, in transferred bytes
private
long
diskCost
;
// bytes to be written and read, in bytes
...
...
@@ -322,7 +324,7 @@ public class Costs implements Comparable<Costs>, Cloneable {
this
.
cpuCost
+=
other
.
cpuCost
;
}
// ----------
relative
costs ----------
// ----------
heuristic
costs ----------
this
.
heuristicNetworkCost
+=
other
.
heuristicNetworkCost
;
this
.
heuristicDiskCost
+=
other
.
heuristicDiskCost
;
...
...
@@ -389,43 +391,31 @@ public class Costs implements Comparable<Costs>, Cloneable {
*/
@Override
public
int
compareTo
(
Costs
o
)
{
// check the network cost. first heuristic, then quantifiable
if
(
this
.
heuristicNetworkCost
<
o
.
heuristicNetworkCost
)
{
// check the network cost. if we have actual costs on both, use them, otherwise use the heuristic costs.
if
(
this
.
networkCost
>
-
1
&&
o
.
networkCost
>
-
1
)
{
return
this
.
networkCost
<
o
.
networkCost
?
-
1
:
this
.
networkCost
>
o
.
networkCost
?
1
:
0
;
}
else
if
(
this
.
heuristicNetworkCost
<
o
.
heuristicNetworkCost
)
{
return
-
1
;
}
else
if
(
this
.
heuristicNetworkCost
>
o
.
heuristicNetworkCost
)
{
return
1
;
}
else
if
(
this
.
networkCost
!=
-
1
&&
(
this
.
networkCost
<
o
.
networkCost
||
o
.
networkCost
==
-
1
))
{
return
-
1
;
}
else
if
(
o
.
networkCost
!=
-
1
&&
(
this
.
networkCost
>
o
.
networkCost
||
this
.
networkCost
==
-
1
))
{
return
1
;
}
else
if
(
this
.
networkCost
==
-
1
&&
o
.
networkCost
==
-
1
)
{
// both have unknown network cost (and equal or no heuristic net cost). treat the costs as equal
return
0
;
}
// next, check the disk cost. again heuristic before quantifiable
if
(
this
.
heuristicDiskCost
<
o
.
heuristicDiskCost
)
{
// next, check the disk cost. again, if we have actual costs on both, use them, otherwise use the heuristic costs.
if
(
this
.
diskCost
>
-
1
&&
o
.
diskCost
>
-
1
)
{
return
this
.
diskCost
<
o
.
diskCost
?
-
1
:
this
.
diskCost
>
o
.
diskCost
?
1
:
0
;
}
else
if
(
this
.
heuristicDiskCost
<
o
.
heuristicDiskCost
)
{
return
-
1
;
}
else
if
(
this
.
heuristicDiskCost
>
o
.
heuristicDiskCost
)
{
return
1
;
}
else
if
(
this
.
diskCost
!=
-
1
&&
(
this
.
diskCost
<
o
.
diskCost
||
o
.
diskCost
==
-
1
))
{
return
-
1
;
}
else
if
(
o
.
diskCost
!=
-
1
&&
(
this
.
diskCost
>
o
.
diskCost
||
this
.
diskCost
==
-
1
))
{
return
1
;
}
else
if
(
this
.
diskCost
==
-
1
&&
o
.
diskCost
==
-
1
)
{
// both have unknown disk cost (and equal or no heuristic net cost). treat the costs as equal
return
0
;
}
// finally, check the CPU cost. heuristic before quantifiable
if
(
this
.
heuristicCpuCost
<
o
.
heuristicCpuCost
)
{
// next, check the disk cost. again, if we have actual costs on both, use them, otherwise use the heuristic costs.
if
(
this
.
cpuCost
>
-
1
&&
o
.
cpuCost
>
-
1
)
{
return
this
.
cpuCost
<
o
.
cpuCost
?
-
1
:
this
.
cpuCost
>
o
.
cpuCost
?
1
:
0
;
}
else
if
(
this
.
heuristicCpuCost
<
o
.
heuristicCpuCost
)
{
return
-
1
;
}
else
if
(
this
.
heuristicCpuCost
>
o
.
heuristicCpuCost
)
{
return
1
;
}
else
if
(
this
.
cpuCost
!=
-
1
&&
(
this
.
cpuCost
<
o
.
cpuCost
||
o
.
cpuCost
==
-
1
))
{
return
-
1
;
}
else
if
(
o
.
cpuCost
!=
-
1
&&
(
this
.
cpuCost
>
o
.
cpuCost
||
this
.
cpuCost
==
-
1
))
{
return
1
;
}
else
{
return
0
;
}
...
...
pact/pact-compiler/src/main/java/eu/stratosphere/pact/compiler/costs/DefaultCostEstimator.java
浏览文件 @
b4135dca
...
...
@@ -48,10 +48,11 @@ public class DefaultCostEstimator extends CostEstimator
// partitioning. no disk costs.
final
long
estOutShipSize
=
estimates
.
getEstimatedOutputSize
();
if
(
estOutShipSize
<=
0
)
{
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
);
costs
.
setNetworkCost
(
Costs
.
UNKNOWN
);
}
else
{
costs
.
addNetworkCost
(
estOutShipSize
);
}
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
);
}
@Override
...
...
@@ -60,10 +61,11 @@ public class DefaultCostEstimator extends CostEstimator
// partitioning. no disk costs.
final
long
estOutShipSize
=
estimates
.
getEstimatedOutputSize
();
if
(
estOutShipSize
<=
0
)
{
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
);
costs
.
setNetworkCost
(
Costs
.
UNKNOWN
);
}
else
{
costs
.
addNetworkCost
(
estOutShipSize
);
}
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
);
}
@Override
...
...
@@ -74,14 +76,14 @@ public class DefaultCostEstimator extends CostEstimator
final
long
sampled
=
(
long
)
(
dataSize
*
0.1f
);
// set shipping costs
costs
.
addNetworkCost
(
dataSize
+
sampled
);
// we assume a two phase merge sort, so all in all 2 I/O operations per block
costs
.
addDiskCost
(
2
*
sampled
);
}
else
{
// no costs known. use the same assumption as above on the heuristic costs
final
long
sampled
=
(
long
)
(
HEURISTIC_COST_BASE
*
0.1f
);
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
+
sampled
);
costs
.
addHeuristicDiskCost
(
2
*
sampled
);
costs
.
setNetworkCost
(
Costs
.
UNKNOWN
);
}
// no costs known. use the same assumption as above on the heuristic costs
final
long
sampled
=
(
long
)
(
HEURISTIC_COST_BASE
*
0.1f
);
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
+
sampled
);
costs
.
addHeuristicDiskCost
(
2
*
sampled
);
}
@Override
...
...
@@ -89,10 +91,11 @@ public class DefaultCostEstimator extends CostEstimator
// assumption: we need ship the whole data over the network to each node.
final
long
estOutShipSize
=
estimates
.
getEstimatedOutputSize
();
if
(
estOutShipSize
<=
0
)
{
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
*
replicationFactor
);
costs
.
setNetworkCost
(
Costs
.
UNKNOWN
);
}
else
{
costs
.
addNetworkCost
(
replicationFactor
*
estOutShipSize
);
}
costs
.
addHeuristicNetworkCost
(
HEURISTIC_COST_BASE
*
replicationFactor
);
}
// --------------------------------------------------------------------------------------------
...
...
@@ -104,8 +107,9 @@ public class DefaultCostEstimator extends CostEstimator
if
(
fileSizeInBytes
>=
0
)
{
costs
.
addDiskCost
(
fileSizeInBytes
);
}
else
{
costs
.
addHeuristicDiskCost
(
HEURISTIC_COST_BASE
);
costs
.
setDiskCost
(
Costs
.
UNKNOWN
);
}
costs
.
addHeuristicDiskCost
(
HEURISTIC_COST_BASE
);
}
@Override
...
...
@@ -113,10 +117,11 @@ public class DefaultCostEstimator extends CostEstimator
final
long
s
=
estimates
.
getEstimatedOutputSize
();
// we assume a two phase merge sort, so all in all 2 I/O operations per block
if
(
s
<=
0
)
{
costs
.
addHeuristicDiskCost
(
2
*
HEURISTIC_COST_BASE
);
costs
.
setDiskCost
(
Costs
.
UNKNOWN
);
}
else
{
costs
.
addDiskCost
(
2
*
s
);
}
costs
.
addHeuristicDiskCost
(
2
*
HEURISTIC_COST_BASE
);
}
@Override
...
...
@@ -143,8 +148,9 @@ public class DefaultCostEstimator extends CostEstimator
if
(
bs
>
0
&&
ps
>
0
)
{
costs
.
addDiskCost
(
bs
+
ps
);
}
else
{
costs
.
addHeuristicDiskCost
(
2
*
HEURISTIC_COST_BASE
);
costs
.
setDiskCost
(
Costs
.
UNKNOWN
);
}
costs
.
addHeuristicDiskCost
(
2
*
HEURISTIC_COST_BASE
);
}
@Override
...
...
@@ -158,9 +164,11 @@ public class DefaultCostEstimator extends CostEstimator
costs
.
addDiskCost
(
oc
*
is
);
}
}
else
{
// hack: assume 100k loops (should be expensive enough)
costs
.
addHeuristicDiskCost
(
HEURISTIC_COST_BASE
*
100000
);
costs
.
setDiskCost
(
Costs
.
UNKNOWN
);
}
// hack: assume 100k loops (should be expensive enough)
costs
.
addHeuristicDiskCost
(
HEURISTIC_COST_BASE
*
100000
);
}
@Override
...
...
@@ -172,9 +180,11 @@ public class DefaultCostEstimator extends CostEstimator
long
loops
=
Math
.
max
(
os
/
blockSize
,
1
);
costs
.
addDiskCost
(
loops
*
is
);
}
else
{
// hack: assume 1k loops (much cheaper than the streamed variant!)
costs
.
addHeuristicDiskCost
(
HEURISTIC_COST_BASE
*
1000
);
costs
.
setDiskCost
(
Costs
.
UNKNOWN
);
}
// hack: assume 1k loops (much cheaper than the streamed variant!)
costs
.
addHeuristicDiskCost
(
HEURISTIC_COST_BASE
*
1000
);
}
// --------------------------------------------------------------------------------------------
...
...
@@ -189,9 +199,10 @@ public class DefaultCostEstimator extends CostEstimator
final
long
s
=
estimates
.
getEstimatedOutputSize
();
// we assume spilling and re-reading
if
(
s
<=
0
)
{
costs
.
addHeuristicDiskCost
(
2
*
HEURISTIC_COST_BASE
);
costs
.
setDiskCost
(
Costs
.
UNKNOWN
);
}
else
{
costs
.
addDiskCost
(
2
*
s
);
}
costs
.
addHeuristicDiskCost
(
2
*
HEURISTIC_COST_BASE
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录