Skip to content

Commit 9a5da1e

Browse files
committed
start collecting compiler metrics optionally
1 parent 4ca2a3d commit 9a5da1e

7 files changed

+163
-33
lines changed

.sqlx/query-43d0bb3b88356af3abdae506b7699ec762a6f1debbbda49a3479fddaa8917e17.json renamed to .sqlx/query-4242ea977833de52a1b11e1bf418750e53a36222d36ab26140a7692e200fd35b.json

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-ebb47544b1090567139f3bdf2c22993c3a3aaef41c6520095a2c3bfaf6035da6.json renamed to .sqlx/query-9633480047fdf3519d16bc5b4035b2e2d0e4403aa54c5cefbd64188ba3b41132.json

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ services:
1919
- "/var/run/docker.sock:/var/run/docker.sock"
2020
- ".rustwide-docker:/opt/docsrs/rustwide"
2121
- "cratesio-index:/opt/docsrs/prefix/crates.io-index"
22+
- "./ignored/cratesfyi-prefix/metrics:/opt/docsrs/prefix/metrics"
2223
- "./static:/opt/docsrs/static:ro"
2324
environment:
2425
DOCSRS_RUSTWIDE_WORKSPACE: /opt/docsrs/rustwide
26+
DOCSRS_COMPILER_METRICS_PATH: /opt/docsrs/prefix/metrics
2527
DOCSRS_DATABASE_URL: postgresql://cratesfyi:password@db
2628
DOCSRS_STORAGE_BACKEND: s3
2729
S3_ENDPOINT: http://s3:9000

src/bin/cratesfyi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ impl BuildSubcommand {
469469
.as_ref()
470470
.map(|s| PackageKind::Registry(s.as_str()))
471471
.unwrap_or(PackageKind::CratesIo),
472+
true,
472473
)
473474
.context("Building documentation failed")?;
474475
}

src/build_queue.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub(crate) struct QueuedCrate {
2929
pub(crate) version: String,
3030
pub(crate) priority: i32,
3131
pub(crate) registry: Option<String>,
32+
pub(crate) attempt: i32,
3233
}
3334

3435
#[derive(Debug)]
@@ -165,7 +166,7 @@ impl AsyncBuildQueue {
165166

166167
Ok(sqlx::query_as!(
167168
QueuedCrate,
168-
"SELECT id, name, version, priority, registry
169+
"SELECT id, name, version, priority, registry, attempt
169170
FROM queue
170171
WHERE attempt < $1
171172
ORDER BY priority ASC, attempt ASC, id ASC",
@@ -495,7 +496,7 @@ impl BuildQueue {
495496
let to_process = match self.runtime.block_on(
496497
sqlx::query_as!(
497498
QueuedCrate,
498-
"SELECT id, name, version, priority, registry
499+
"SELECT id, name, version, priority, registry, attempt
499500
FROM queue
500501
WHERE
501502
attempt < $1 AND
@@ -646,7 +647,7 @@ impl BuildQueue {
646647
return Err(err);
647648
}
648649

649-
builder.build_package(&krate.name, &krate.version, kind)
650+
builder.build_package(&krate.name, &krate.version, kind, krate.attempt == 0)
650651
})?;
651652

652653
Ok(processed)

src/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub struct Config {
7878
// for the remote archives?
7979
pub(crate) local_archive_cache_path: PathBuf,
8080

81+
// Where to collect metrics for the metrics initiative.
82+
// When empty, we won't collect metrics.
83+
pub(crate) compiler_metrics_collection_path: Option<PathBuf>,
84+
8185
// Content Security Policy
8286
pub(crate) csp_report_only: bool,
8387

@@ -226,6 +230,8 @@ impl Config {
226230
prefix.join("archive_cache"),
227231
)?,
228232

233+
compiler_metrics_collection_path: maybe_env("DOCSRS_COMPILER_METRICS_PATH")?,
234+
229235
temp_dir,
230236

231237
rustwide_workspace: env("DOCSRS_RUSTWIDE_WORKSPACE", PathBuf::from(".workspace"))?,

0 commit comments

Comments
 (0)