-
Notifications
You must be signed in to change notification settings - Fork 102
DataFusion solution [WIP] #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3a983fd
Datafusion solution
Dandandan b1f613e
Datafusion solution
Dandandan 51ce127
Query fix
Dandandan 3343428
Undo change
Dandandan d1e7ff3
Increase batch size
Dandandan 58be012
Rename to ans
Dandandan d87c92d
Fix
Dandandan 2b67e2a
Add q7/q10
Dandandan d217e37
Use multiple threads better
Dandandan 5a3e5ec
Add exec script
Dandandan f839050
Some cleanup
Dandandan 6cb14f5
Rename
Dandandan 63fe38b
Fix disabled snmalloc
Dandandan cbecfbc
Use arrow master again
Dandandan 88ba391
Update benchmark code
Dandandan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,3 +30,5 @@ run.out | |
| clickhouse/etc_sudoers.bak | ||
| workdir/ | ||
| timeout-exit-codes.out | ||
| */target | ||
| *.lock | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [package] | ||
| name = "db-benchmark" | ||
| version = "0.1.0" | ||
| edition = "2018" | ||
|
|
||
| [dependencies] | ||
| datafusion = { git = "https://github.com/apache/arrow.git", features = ["simd"] } | ||
| arrow = { git = "https://github.com/apache/arrow.git", features = ["simd"] } | ||
| tokio = { version = "0.2", features = ["macros", "rt-core", "rt-threaded"] } | ||
| snmalloc-rs = "0.2" | ||
|
|
||
| [profile.release] | ||
| lto = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| use arrow::datatypes::{DataType, Field, Schema}; | ||
| use datafusion::datasource::{CsvFile, MemTable}; | ||
| use datafusion::error::Result; | ||
| use datafusion::prelude::*; | ||
| use std::env; | ||
| use std::time::Instant; | ||
|
|
||
| #[cfg(feature = "snmalloc")] | ||
| #[global_allocator] | ||
| static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<()> { | ||
| let mut ctx = ExecutionContext::new(); | ||
| let data = format!("../data/{}.csv", env::var("SRC_DATANAME").unwrap()); | ||
|
|
||
| let schema = Schema::new(vec![ | ||
| Field::new("id1", DataType::Utf8, false), | ||
| Field::new("id2", DataType::Utf8, false), | ||
| Field::new("id3", DataType::Utf8, false), | ||
| Field::new("id4", DataType::Int32, false), | ||
| Field::new("id5", DataType::Int32, false), | ||
| Field::new("id6", DataType::Int32, false), | ||
| Field::new("v1", DataType::Int32, false), | ||
| Field::new("v2", DataType::Int32, false), | ||
| Field::new("v3", DataType::Float64, false), | ||
| ]); | ||
| let options = CsvReadOptions::new().schema(&schema).has_header(true); | ||
|
|
||
| let csv = CsvFile::try_new(&data, options).unwrap(); | ||
| let batch_size = 65536; | ||
| let memtable = MemTable::load(&csv, batch_size).await?; | ||
| ctx.register_table("t", Box::new(memtable)); | ||
|
|
||
| // "q1" | ||
| let start = Instant::now(); | ||
| let df = ctx.sql("SELECT id1, SUM(v1) AS v1 FROM t GROUP BY id1")?; | ||
|
|
||
| let _results = df.collect().await?; | ||
|
|
||
| println!("q1 took {} ms", start.elapsed().as_millis()); | ||
|
|
||
| // "q2" | ||
| let start = Instant::now(); | ||
| let df = ctx.sql("SELECT id1, id2, SUM(v1) AS v1 FROM t GROUP BY id1, id2")?; | ||
|
|
||
| let _results = df.collect().await?; | ||
|
|
||
| println!("q2 took {} ms", start.elapsed().as_millis()); | ||
|
|
||
| // "q3" | ||
| let start = Instant::now(); | ||
| let df = ctx.sql("SELECT id3, SUM(v1) AS v1, AVG(v3) AS v3 FROM t GROUP BY id3")?; | ||
|
|
||
| let _results = df.collect().await?; | ||
|
|
||
| println!("q3 took {} ms", start.elapsed().as_millis()); | ||
|
|
||
| // "q4" | ||
| let start = Instant::now(); | ||
| let df = | ||
| ctx.sql("SELECT id4, AVG(v1) AS v1, AVG(v2) AS v2, AVG(v3) AS v3 FROM t GROUP BY id4")?; | ||
|
|
||
| let _results = df.collect().await?; | ||
|
|
||
| println!("q4 took {} ms", start.elapsed().as_millis()); | ||
|
|
||
| // "q5" | ||
| let start = Instant::now(); | ||
| let df = | ||
| ctx.sql("SELECT id6, SUM(v1) AS v1, SUM(v2) AS v2, SUM(v3) AS v3 FROM t GROUP BY id6")?; | ||
|
|
||
| let _results = df.collect().await?; | ||
|
|
||
| println!("q5 took {} ms", start.elapsed().as_millis()); | ||
|
|
||
| Ok(()) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| cd datafusion | ||
|
|
||
| cargo update | ||
|
|
||
| cd ../ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cargo tree | grep "├── datafusion (.*)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would chain this two lines into single line, variable can be named
ansfor consistency to other scripts. Query for each question need to be run two times. After each query we do extra computation on theans(and measure its timing as well) to ensure that actual query was not lazy by forcing computation onans. Those two timings for each query we needs to be written to csv file with timings (mem usage can be ignored), which should be handled by a helper function, like this one:db-benchmark/_helpers/helpers.py
Line 8 in 070d3b7
After both run of a query finished we need to print head-3 and tail-3 of
ans.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @jangorecki - im picking up work on this. do you still need a rust version of
write_log?