Rust_concurrency❤️최적화 - Rayon을 써야 할 때와 tokio를 써야 할 상황 알아 보기 &❤️futures concurrency
Rayon 기초
rayon
https://github.com/rayon-rs/rayon
예문
https://youtu.be/_AQDYmZRmRc
에러 관리
https://youtu.be/FJl0mQ_gNE4
tokio를 쓰면 안 되는 3가지 case
이럴 경우는 tokio보다는 rayon을 써야 더 빠르다
When not to use Tokio
Although Tokio is useful for many projects that need to do a lot of things simultaneously, there are also some use-cases where Tokio is not a good fit.
- Speeding up CPU-bound computations by running them in parallel on several threads. Tokio is designed for IO-bound applications where each individual task spends most of its time waiting for IO. If the only thing your application does is run computations in parallel, you should be using rayon. That said, it is still possible to "mix & match" if you need to do both
- Reading a lot of files. Although it seems like Tokio would be useful for projects that simply need to read a lot of files, Tokio provides no advantage here compared to an ordinary threadpool. This is because operating systems generally do not provide asynchronous file APIs.
- Sending a single web request. The place where Tokio gives you an advantage is when you need to do many things at the same time. If you need to use a library intended for asynchronous Rust such as reqwest, but you don't need to do a lot of things at once, you should prefer the blocking version of that library, as it will make your project simpler. Using Tokio will still work, of course, but provides no real advantage over the blocking API. If the library doesn't provide a blocking API, see the chapter on bridging with sync code.
출처 https://tokio.rs/tokio/tutorial
tokio의 장점
tokio
https://tokio.rs/
tokio tutorial
https://tokio.rs/tokio/tutorial
빅 O Big-O차트 그림으로 이해하기 14분 ~
Rust Code로 빅 O(Big-O Complexity Chart) 이해하기 14분 부터 보면 됨
https://youtu.be/6IhopmZhWQI
출처: https://economiceco.tistory.com/13738 [경제PLUS]
빅 O Big-O 차트 보는 방법
RustConf 2021 - Writing the Fastest GBDT Library in Rust by Isabella Tromba
내장되어 있는 std
futures -> tokio 에서도 나온다 다 연결되네 ㅋ
Future Trait가 있다. ㅎㅎㅎ
https://rust-lang.github.io/async-book/02_execution/02_future.html
Futures concurrency
Rust ❤️Asynchronous Programming
https://rust-lang.github.io/async-book/01_getting_started/01_chapter.html