Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/user-guide/src/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention that using this will increase the build time considerably

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`