Skip to content

Commit 5253448

Browse files
committed
Parallelize rendering of people's pages
1 parent 9c0552c commit 5253448

File tree

3 files changed

+77
-19
lines changed

3 files changed

+77
-19
lines changed

Cargo.lock

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ toml = "0.9"
1515
serde_json = "1.0"
1616
rust_team_data = { git = "https://github.com/rust-lang/team" }
1717
percent-encoding = "2.3.2"
18+
rayon = "1"
1819

1920
[dev-dependencies]
2021
time = { version = "0.3.44", features = ["parsing"] }

src/render.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use crate::{BaseUrl, ENGLISH, LAYOUT};
77
use anyhow::Context;
88
use handlebars::Handlebars;
99
use handlebars_fluent::{Loader, SimpleLoader};
10+
use rayon::iter::IntoParallelRefIterator;
11+
use rayon::iter::ParallelIterator;
1012
use serde::Serialize;
1113
use std::ffi::OsStr;
1214
use std::fs::File;
@@ -238,25 +240,28 @@ pub fn render_governance(render_ctx: &RenderCtx) -> anyhow::Result<()> {
238240

239241
// A specific page for each team member
240242
let all_person_data = render_ctx.teams.all_person_data();
241-
for person in all_person_data {
242-
// Use <username>/index.html for a nicer URL (/people/foo vs /people/foo.html).
243-
for_all_langs(
244-
&format!(
245-
"governance/people/{}/index.html",
246-
person.github.to_lowercase()
247-
),
248-
|dst_path, lang| {
249-
render_ctx
250-
.page(
251-
"governance/person",
252-
"governance-person-title",
253-
&person,
254-
lang,
255-
)
256-
.render(dst_path)
257-
},
258-
)?;
259-
}
243+
all_person_data
244+
.par_iter()
245+
.map(|person| {
246+
// Use <username>/index.html for a nicer URL (/people/foo vs /people/foo.html).
247+
for_all_langs(
248+
&format!(
249+
"governance/people/{}/index.html",
250+
person.github.to_lowercase()
251+
),
252+
|dst_path, lang| {
253+
render_ctx
254+
.page(
255+
"governance/person",
256+
"governance-person-title",
257+
&person,
258+
lang,
259+
)
260+
.render(dst_path)
261+
},
262+
)
263+
})
264+
.collect::<anyhow::Result<Vec<_>>>()?;
260265

261266
Ok(())
262267
}

0 commit comments

Comments
 (0)