Streaming Rust
Database Benchmark
database って色々あるけど何使えばいいの?
protocol 実装大会
どれくらい sha256 って早いの?
行列計算勝負 python numpy vs rust ndarray
- BLAS とか使えば一緒?
- mojo も参戦
Other tips
utoipa just serve the openapi.json
https://github.com/juhaku/utoipa/issues/598#issuecomment-1526374675
axum の 場合
pub fn api_doc() -> Json<utoipa::openapi::OpenApi> { Json(ApiDoc::openapi()) }
channels
std::mpsc::Sender
is !Sync (which means you need to wrap it with a Mutex or similar) where crossbeam::channel::Sender
is Sync.
Other than the perforance gains, seems like crossbeam
is status quo.
accessing the tokio’s runtime from other threads
we don’t want multiple runtimes in one app.
use std::thread; #[tokio::main] async fn main() { thread::spawn(move ||{ async_function().await; }); } async fn async_function() { }
but there might be situations that we want to fun async functions inside our dedicated thread.
in that case you get the handle of the runtime and use that
use tokio::runtime::Handle; let handle = Handle::current(); handle.spawn(async move{ async_function().await; });
other small things
const
or static
Almost always use const
. I guess when const
it lives in the binary, on the otherhand when it’s a static
it has a memory assigned and could be modified through unsafe
operations.