{"id":13438527,"url":"https://github.com/rayon-rs/rayon","last_synced_at":"2025-05-12T18:16:00.739Z","repository":{"id":21407059,"uuid":"24725038","full_name":"rayon-rs/rayon","owner":"rayon-rs","description":"Rayon: A data parallelism library for Rust","archived":false,"fork":false,"pushed_at":"2025-04-11T18:30:37.000Z","size":3519,"stargazers_count":11722,"open_issues_count":206,"forks_count":519,"subscribers_count":104,"default_branch":"main","last_synced_at":"2025-05-12T18:15:53.120Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rayon-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-10-02T15:38:05.000Z","updated_at":"2025-05-12T13:48:41.000Z","dependencies_parsed_at":"2023-01-13T21:27:41.465Z","dependency_job_id":"51041fd2-59ff-40aa-acea-5efe9899a37f","html_url":"https://github.com/rayon-rs/rayon","commit_stats":{"total_commits":1685,"total_committers":157,"mean_commits":10.73248407643312,"dds":0.5721068249258161,"last_synced_commit":"6ca44bd18e7e6004d0ad3e17137da030ca1adf2a"},"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayon-rs%2Frayon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayon-rs%2Frayon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayon-rs%2Frayon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayon-rs%2Frayon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rayon-rs","download_url":"https://codeload.github.com/rayon-rs/rayon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253795161,"owners_count":21965487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:06.245Z","updated_at":"2025-05-12T18:16:00.710Z","avatar_url":"https://github.com/rayon-rs.png","language":"Rust","funding_links":[],"categories":["Libraries","Rust","库 Libraries","其他_机器学习与深度学习","Data","库","语言资源库","others","Parallel and Async Library","Awesome Tools","\u003ca name=\"Rust\"\u003e\u003c/a\u003eRust","Other","Machine Learning"],"sub_categories":["Concurrency","并发性 Concurrency","data parallel","并发","rust","并发 Concurrency","Languages","Performance"],"readme":"# Rayon\n\n[![Rayon crate](https://img.shields.io/crates/v/rayon.svg)](https://crates.io/crates/rayon)\n[![Rayon documentation](https://docs.rs/rayon/badge.svg)](https://docs.rs/rayon)\n![minimum rustc 1.63](https://img.shields.io/badge/rustc-1.63+-red.svg)\n[![build status](https://github.com/rayon-rs/rayon/workflows/main/badge.svg)](https://github.com/rayon-rs/rayon/actions)\n\nRayon is a data-parallelism library for Rust. It is extremely\nlightweight and makes it easy to convert a sequential computation into\na parallel one. It also guarantees data-race freedom. (You may also\nenjoy [this blog post][blog] about Rayon, which gives more background\nand details about how it works, or [this video][video], from the Rust\nBelt Rust conference.) Rayon is\n[available on crates.io](https://crates.io/crates/rayon), and\n[API documentation is available on docs.rs](https://docs.rs/rayon).\n\n[blog]: https://smallcultfollowing.com/babysteps/blog/2015/12/18/rayon-data-parallelism-in-rust/\n[video]: https://www.youtube.com/watch?v=gof_OEv71Aw\n\n## Parallel iterators and more\n\nRayon makes it drop-dead simple to convert sequential iterators into\nparallel ones: usually, you just change your `foo.iter()` call into\n`foo.par_iter()`, and Rayon does the rest:\n\n```rust\nuse rayon::prelude::*;\nfn sum_of_squares(input: \u0026[i32]) -\u003e i32 {\n    input.par_iter() // \u003c-- just change that!\n         .map(|\u0026i| i * i)\n         .sum()\n}\n```\n\n[Parallel iterators] take care of deciding how to divide your data\ninto tasks; it will dynamically adapt for maximum performance. If you\nneed more flexibility than that, Rayon also offers the [join] and\n[scope] functions, which let you create parallel tasks on your own.\nFor even more control, you can create [custom threadpools] rather than\nusing Rayon's default, global threadpool.\n\n[Parallel iterators]: https://docs.rs/rayon/*/rayon/iter/index.html\n[join]: https://docs.rs/rayon/*/rayon/fn.join.html\n[scope]: https://docs.rs/rayon/*/rayon/fn.scope.html\n[custom threadpools]: https://docs.rs/rayon/*/rayon/struct.ThreadPool.html\n\n## No data races\n\nYou may have heard that parallel execution can produce all kinds of\ncrazy bugs. Well, rest easy. Rayon's APIs all guarantee **data-race\nfreedom**, which generally rules out most parallel bugs (though not\nall). In other words, **if your code compiles**, it typically does the\nsame thing it did before.\n\nFor the most, parallel iterators in particular are guaranteed to\nproduce the same results as their sequential counterparts. One caveat:\nIf your iterator has side effects (for example, sending methods to\nother threads through a [Rust channel] or writing to disk), those side\neffects may occur in a different order. Note also that, in some cases,\nparallel iterators offer alternative versions of the sequential\niterator methods that can have higher performance.\n\n[Rust channel]: https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html\n\n## Using Rayon\n\n[Rayon is available on crates.io](https://crates.io/crates/rayon). The\nrecommended way to use it is to add a line into your Cargo.toml such\nas:\n\n```toml\n[dependencies]\nrayon = \"1.10\"\n```\n\nTo use the parallel iterator APIs, a number of traits have to be in\nscope. The easiest way to bring those things into scope is to use the\n[Rayon prelude](https://docs.rs/rayon/*/rayon/prelude/index.html). In\neach module where you would like to use the parallel iterator APIs,\njust add:\n\n```rust\nuse rayon::prelude::*;\n```\n\nRayon currently requires `rustc 1.63.0` or greater.\n\n### Usage with WebAssembly\n\nBy default, when building to WebAssembly, Rayon will treat it as any\nother platform without multithreading support and will fall back to\nsequential iteration. This allows existing code to compile and run\nsuccessfully with no changes necessary, but it will run slower as it\nwill only use a single CPU core.\n\nYou can build Rayon-based projects with proper multithreading support\nfor the Web, but you'll need an adapter and some project configuration\nto account for differences between WebAssembly threads and threads on\nthe other platforms.\n\nCheck out the\n[wasm-bindgen-rayon](https://github.com/RReverser/wasm-bindgen-rayon)\ndocs for more details.\n\n## Contribution\n\nRayon is an open source project! If you'd like to contribute to Rayon,\ncheck out\n[the list of \"help wanted\" issues](https://github.com/rayon-rs/rayon/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).\nThese are all (or should be) issues that are suitable for getting\nstarted, and they generally include a detailed set of instructions for\nwhat to do. Please ask questions if anything is unclear! Also, check\nout the\n[Guide to Development](https://github.com/rayon-rs/rayon/wiki/Guide-to-Development)\npage on the wiki. Note that all code submitted in PRs to Rayon is\nassumed to\n[be licensed under Rayon's dual MIT/Apache 2.0 licensing](https://github.com/rayon-rs/rayon/blob/main/README.md#license).\n\n## Quick demo\n\nTo see Rayon in action, check out the `rayon-demo` directory, which\nincludes a number of demos of code using Rayon. For example, run this\ncommand to get a visualization of an N-body simulation. To see the\neffect of using Rayon, press `s` to run sequentially and `p` to run in\nparallel.\n\n```text\n\u003e cd rayon-demo\n\u003e cargo run --release -- nbody visualize\n```\n\nFor more information on demos, try:\n\n```text\n\u003e cd rayon-demo\n\u003e cargo run --release -- --help\n```\n\n## Other questions?\n\nSee [the Rayon FAQ][faq].\n\n[faq]: https://github.com/rayon-rs/rayon/blob/main/FAQ.md\n\n## License\n\nRayon is distributed under the terms of both the MIT license and the\nApache License (Version 2.0). See [LICENSE-APACHE](LICENSE-APACHE) and\n[LICENSE-MIT](LICENSE-MIT) for details. Opening a pull request is\nassumed to signal agreement with these licensing terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frayon-rs%2Frayon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frayon-rs%2Frayon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frayon-rs%2Frayon/lists"}