embulk-filter-calcite を使うと任意の SQL を書いてフィルタリングできて圧倒的に便利そうなので、拙作の embulk-filter-row および embulk-filter-column はお役御免にできるかと思って、速度比較をしてみました。
tl; dr
残念ながら calcite は速くはないようです(´・ω・`)
embulk-filter-row との比較
プラグイン | 演算 | かかった時間 |
---|---|---|
No Filter | 0m22.283s | |
embulk-filter-row (0.3.3) | 文字列の = 演算子 | 0m22.587s |
embulk-filter-row (0.3.3) | 文字列の REGEXP 演算子 | 1m33.207s |
embulk-filter-calcite (0.1.2) | 文字列の = 演算子 | 7m49.529s |
embulk-filter-calcite (0.1.2) | 文字列の LIKE 演算子 | 7m59.496s |
文字列 = 演算子比較だと 0.3s : 7m27.25s ≒ 1 : 1490 なので、embulk-filter-row に比べて約 1490 倍遅い ...
embulk-filter-column との比較
プラグイン | 演算 | かかった時間 |
---|---|---|
No Filter | 0m22.283s | |
embulk-filter-column (0.6.0) | カラムのコピー | 0m24.130s |
embulk-filter-calcite (0.1.2) | カラムのコピー | 6m31.064s |
スペック
計測ホストスペック
CPU: Intel(R) Xeon(R) CPU X5650 @ 2.67GHz 24コア
Memory: 12GB
テストデータ
手元にあった 1.4GB、2700万行程度の tsv ファイル。内容を少しだけ見せるとこんなかんじ
test.tsv
27 74813552 30111021 2 1411559797 1411559797 0
28 74813552 30111001 1 1411559797 1411559797 0
29 74813552 30121001 1 1411559797 1411559797 0
30 74813552 30111011 1 1411559797 1411559797 0
39 102516762 30111021 2 1411607973 1411607973 0
40 102516762 30111001 1 1411607973 1411607973 0
ベース設定ファイル
filter プラグインの速度比較をしたいので、一番ベーシックな input file プラグインと、何もパースしないパーサプラグイン embulk-parser-none を使って読み込むようにした。
設定ファイル
in:
type: file
path_prefix: 'test.tsv'
parser:
type: none
column_name: payload
out:
type: "null"
この時点での結果も time コマンドで計測
real 0m22.283s
user 0m39.431s
sys 0m1.332s
実行コマンド
あえて何もオプションを指定せずに標準のまま実行
time embulk run config.yml
行フィルタリング (WHERE) 比較
embulk-filter-row の場合
version: 0.3.3
文字列の = 演算子
設定ファイル
in:
type: file
path_prefix: 'test.tsv'
parser:
type: none
column_name: payload
filters:
- type: row
where: payload = '1411559797'
out:
type: "null"
結果 (手前味噌だけど速い)
real 0m22.587s
user 0m44.078s
sys 0m1.466s
文字列の REGEXP 演算子
設定ファイル
in:
type: file
path_prefix: 'test.tsv'
parser:
type: none
column_name: payload
filters:
- type: row
where: payload REGEXP '.*1411559797.*'
out:
type: "null"
結果
real 1m33.207s
user 27m57.026s
sys 0m2.370s
embulk-filter-calcite の場合
version: 0.1.2
文字列の = 演算子
設定ファイル
in:
type: file
path_prefix: 'test.tsv'
parser:
type: none
column_name: payload
filters:
- type: calcite
query: SELECT payload FROM $PAGES WHERE payload = '1411559797'
out:
type: "stdout"
結果
real 7m49.529s
user 48m13.759s
sys 0m52.662s
文字列の LIKE 演算子
設定ファイル
in:
type: file
path_prefix: 'test.tsv'
parser:
type: none
column_name: payload
filters:
- type: calcite
query: SELECT payload FROM $PAGES WHERE payload LIKE '%1411559797%'
out:
type: "stdout"
結果 (= も LIKE もそんなに変わらないのが解せない)
real 7m59.496s
user 49m43.281s
sys 0m53.719s
列フィルタリング
embulk-filter-column の場合
version: 0.6.0
カラムのコピー
設定ファイル
in:
type: file
path_prefix: 'test.tsv'
parser:
type: none
column_name: payload
filters:
- type: column
columns:
- { name: payload }
- { name: copy, src: payload }
out:
type: "null"
結果
real 0m24.130s
user 1m4.415s
sys 0m1.770s
embulk-filter-calcite の場合
version: 0.1.2
カラムのコピー
設定ファイル
in:
type: file
path_prefix: 'test.tsv'
parser:
type: none
column_name: payload
filters:
- type: calcite
query: SELECT payload,payload as copy FROM $PAGES
out:
type: "null"
結果
real 6m31.064s
user 32m30.606s
sys 0m42.977s
sonots
1862Contribution