Skip to content
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

Add Target Feature Recommendations to Arrow Crate Docs #2305

Merged
merged 1 commit into from
Aug 3, 2022
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
53 changes: 53 additions & 0 deletions arrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,42 @@
//! A complete, safe, native Rust implementation of [Apache Arrow](https://arrow.apache.org), a cross-language
//! development platform for in-memory data.
//!
//! # Performance Tips
//!
//! Arrow aims to be as fast as possible out of the box, whilst not compromising on safety. However,
//! it relies heavily on LLVM auto-vectorisation to achieve this. Unfortunately the LLVM defaults,
//! particularly for x86_64, favour portability over performance, and LLVM will consequently avoid
//! using more recent instructions that would result in errors on older CPUs.
//!
//! To address this it is recommended that you specify the override the LLVM defaults either
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops wording error here, will fix 😅

//! by setting the `RUSTFLAGS` environment variable, or by setting `rustflags` in your
//! [Cargo configuration](https://doc.rust-lang.org/cargo/reference/config.html)
//!
//! Enable all features supported by the current CPU
//!
//! ```ignore
//! RUSTFLAGS="-C target-cpu=native"
//! ```
//!
//! Enable all features supported by the current CPU, and enable full use of AVX512
//!
//! ```ignore
//! RUSTFLAGS="-C target-cpu=native -C target-feature=-prefer-256-bit"
//! ```
//!
//! Enable all features supported by CPUs more recent than haswell (2013)
//!
//! ```ignore
//! RUSTFLAGS="-C target-cpu=haswell"
//! ```
//!
//! For a full list of features and target CPUs use
//!
//! ```ignore
//! $ rustc --print target-cpus
//! $ rustc --print target-features
//! ```
//!
//! # Columnar Format
//!
//! The [`array`] module provides statically typed implementations of all the array
Expand Down Expand Up @@ -57,6 +93,23 @@
//! assert_eq!(sum(&TimestampNanosecondArray::from(vec![1, 2, 3])), 6);
//! ```
//!
//! And the following is generic over all arrays with comparable values
//!
//! ```rust
//! # use arrow::array::{ArrayAccessor, ArrayIter, Int32Array, StringArray};
//! # use arrow::datatypes::ArrowPrimitiveType;
//! #
//! fn min<T: ArrayAccessor>(array: T) -> Option<T::Item>
//! where
//! T::Item: Ord
//! {
//! ArrayIter::new(array).filter_map(|v| v).min()
//! }
//!
//! assert_eq!(min(&Int32Array::from(vec![4, 2, 1, 6])), Some(1));
//! assert_eq!(min(&StringArray::from(vec!["b", "a", "c"])), Some("a"));
//! ```
//!
//! For more examples, consult the [`array`] docs.
//!
//! # Type Erasure / Trait Objects
Expand Down