Skip to content

Apache DataFusion SQL Query Engine

Updated user-guide library docs with optimized config (#976)

Matthew Turner50cce1afd2fb
diff --git a/docs/user-guide/src/library.md b/docs/user-guide/src/library.md
index d255d7800c..1a1bbfbeb4 100644
--- a/docs/user-guide/src/library.md
+++ b/docs/user-guide/src/library.md
@@ -19,6 +19,8 @@
# Using DataFusion as a library
+## Default Configuration
+
DataFusion is [published on crates.io](https://crates.io/crates/datafusion), and is [well documented on docs.rs](https://docs.rs/datafusion/).
To get started, add the following to your `Cargo.toml` file:
@@ -27,3 +29,33 @@ To get started, add the following to your `Cargo.toml` file:
[dependencies]
datafusion = "5.1.0"
```
+
+## Optimized Configuration
+
+For an optimized build several steps are required. First, use the below in your `Cargo.toml`. It is
+worth noting that using the settings in the `[profile.release]` section will significantly increase the build time.
+
+```toml
+[dependencies]
+datafusion = { version = "5.0" , features = ["simd"]}
+tokio = { version = "^1.0", features = ["macros", "rt", "rt-multi-thread"] }
+snmalloc-rs = {version = "0.2", features= ["cache-friendly"]}
+num_cpus = "1.0"
+
+[profile.release]
+lto = true
+codegen-units = 1
+```
+
+Then, in `main.rs.` update the memory allocator with the below after your imports:
+
+```rust
+#[global_allocator]
+static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
+```
+
+Finally, in order to build with the `simd` optimization `cargo nightly` is required. Based on the instruction
+set architecture you are building on you will want to configure the `target-cpu` as well, ideally
+with `native` or at least `avx2`.
+
+`RUSTFLAGS='-C target-cpu=native' cargo +nightly run --release`