字符串处理
- 纯 Rust 编写的 SIMD 加速的 UTF-8 验证库:https://github.com/rusticstuff/simdutf8
- basic API for the fastest validation, optimized for valid UTF-8
- compat API as a fully compatible replacement for std::str::from_utf8()
- Up to 22 times faster than the std library on non-ASCII, up to three times faster on ASCII
- As fast as or faster than the original simdjson implementation
- Supports AVX 2 and SSE 4.2 implementations on x86 and x86-64. ARMv7 and ARMv8 neon support is planned
- Selects the fastest implementation at runtime based on CPU support
- Written in pure Rust
- No dependencies
- No-std support
- Falls back to the excellent std implementation if SIMD extensions are not supported
查看系统 CPU 支持的 simd:
cat /proc/cpuinfo # 关注 flags
benchmark & test tools
- Criterion.rs:https://bheisler.github.io/criterion.rs/book/index.html | https://github.com/BurntSushi/critcmp
- 内存分析:https://valgrind.org/docs/manual/ms-manual.html | https://blog.csdn.net/u010168781/article/details/83788559
insta: https://github.com/mitsuhiko/insta
Snapshot tests are particularly useful if your reference values are very large or change often.GUI
A data-first Rust-native UI design toolkit: https://github.com/linebender/druid
Rust 社区在 Rust GUI 领域重点尝试的方向
Its main goal is to offer a polished user experience. There are many factors to this goal, including performance, a rich palette of interactions (hence a widget library to support them), and playing well with the native platform.
- a new VR, web and native-rendering UI framework for Rust: https://github.com/makepad/makepad
Makepad is a creative software development platform for Rust that compiles to wasm/webGL, osx/metal, windows/dx11 linux/opengl
TUI
https://github.com/gyscos/cursive/wiki/Backends
- https://docs.rs/crossterm + https://docs.rs/tui
https://docs.rs/ncurses/latest/ncurses/
WASM
wasmtime: https://github.com/bytecodealliance/wasmtime
DataFrame
polars:https://github.com/pola-rs/polars
- Fast multi-threaded DataFrame library in Rust and Python(py 和 Rust 都可以使用的库)
- benchmark: https://h2oai.github.io/db-benchmark/
- goal: a lightning fast DataFrame library that utilizes all available cores on your machine. Its ideal use case lies in data too big for Pandas but too small for Spark. If you need to process data that does not fit in memory of a single machine (even after filtering), Polars is not the solution to your problem.
- book: https://pola-rs.github.io/polars-book/user-guide
- 专业支持 DataFrame ,单机高性能,与 py-polars 孪生
- peroxide:https://github.com/axect/peroxide
- Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with farmiliar syntax (R, MATLAB & Python syntax)
- 功能比较宽泛,亮点是支持其他编程语言语法形式来处理数据,但是各方面的功能都不太深入,对 DataFrame 功能支持很简陋
- Connector-x:https://github.com/sfu-db/connector-x
- Rust 和 Python 中将数据从 DB 加载到 DataFrame 的最快库(py 和 Rust 都可以使用的库)
- 相比于 modin | pandas | dask:ConnectorX uses up to 3x less memory and 21x less time
- Rust 文档:https://docs.rs/connectorx
- 现有解决方案在下载数据时或多或少会多次冗余数据。此外,在 Python 中实现数据密集型应用程序会带来额外的成本。ConnectorX 是用 Rust 编写的,并遵循“零拷贝”原则。这允许它通过变得对缓存和分支预测器友好来充分利用 CPU。此外,ConnectorX 的架构确保数据将直接从源复制到目标一次。
- 列存储相关(arrow):
- arrow-rs:官方实现
- arrow2
DataBase
11 database drivers and ORMs for Rust that are ready for productionlog
Rust 的 Logging 推荐
src: https://rustcc.cn/article?id=91b91a60-cbe9-4f8a-a5ec-8825da34457b 内容整理自 Reddit 的讨论:What is the current recommendation for logging in Rust? : rust。 问题简述:除了标准的 log,还有不少选择:env_logger,tracing,slog,simplelog 等等,最佳实践是什么? 来自 Koxiaet 的答复:通常有两类与日志相关的 crate:日志接口和日志消费者。接口提供了想要记录某些东西时调用的函数,消费者处理将结构化日志数据格式化到某个地方(stderr 或文件)。两个主要的接口是 log 和 tracing,后者功能更强大因为它支持结构化日志记录,但前者更普遍。还有另一个结构化日志接口 slog,比 tracing 更古老但用的较少。每个日志接口都有自己生态系统,可以根据自己的需要选择。如果在写一个库,log 是个不错的选择,因为所有的日志记录接口都与它兼容。但如果你确实需要结构化日志记录,则可以改用 tracing,这取决于你的需求,比如你是需要写到文件还是只是终端。 其他网友的推荐:
- File Logging:emabee/flexi_logger: A flexible logger for rust programs that can write to stderr or to log files。(来自 cfsamson)
- tracing 的接口:tracing_log - Rust,有多个同时操作交错日志消息时特别方便,可以按某些属性对它们进行分组并单独查看它们。(来自 class_two_perversion)
- estk/log4rs: A highly configurable logging framework for Rust,log4rs 是一个高度可配置的日志框架,以 Java 的 Logback 和 log4j 库为模型。通过 Yaml 配置,到 sdout 和文件,带有文件大小限制选项,还可以配置不同级别的日志。(来自 tms102)
- tracing-appender - crates.io: Rust Package Registry,推荐者所知道的唯一线程外日志记录解决方案,不仅适用于异步应用程序。(来自 Pand9)
- daboross/fern: Simple, efficient logging for Rust,像 Python 的 logging 和 JS 的 Winston。(来自 RapBeautician)
邮件
- 案例文章:How to send emails with Rust
- 库: