-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.
Description
(The actual data in my use-case is indices in a 100³ gilbert curve but isn't relevant here.)
$ { echo '['; seq $(( 100 * 100 * 100 )) | sed 's/.*/(0,0,0),/'; echo ']'; } > 100.rs
$ tr '\n' ' ' < 100.rs > 100s.rs
$ tr -d '\n' < 100.rs > 100d.rs
const GRID_SIZE: usize = 100;
static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100.rs");
fn main() {}
(this is the code used in #137678)
$ time rustc bugowcy.rs
warning: constant `GRID_SIZE` is never used
--> bugowcy.rs:1:7
|
1 | const GRID_SIZE: usize = 100;
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: static `GRID_GILBERT` is never used
--> bugowcy.rs:2:8
|
2 | static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100.rs");
| ^^^^^^^^^^^^
warning: 2 warnings emitted
real 0m32.474s
user 0m0.000s
sys 0m0.015s
Compare to
const GRID_SIZE: usize = 100;
static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100s.rs");
fn main() {}
(this is the code used in #137680, it's the same size as the original)
$ time rustc bugowcy.rs
warning: constant `GRID_SIZE` is never used
--> bugowcy.rs:1:7
|
1 | const GRID_SIZE: usize = 100;
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: static `GRID_GILBERT` is never used
--> bugowcy.rs:2:8
|
2 | static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100s.rs");
| ^^^^^^^^^^^^
warning: 2 warnings emitted
real 0m31.846s
user 0m0.000s
sys 0m0.000s
And to
const GRID_SIZE: usize = 100;
static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100d.rs");
fn main() {}
(1`000`002 bytes smaller)
$ time rustc bugowcy.rs
warning: constant `GRID_SIZE` is never used
--> bugowcy.rs:1:7
|
1 | const GRID_SIZE: usize = 100;
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: static `GRID_GILBERT` is never used
--> bugowcy.rs:2:8
|
2 | static GRID_GILBERT: [(u8,u8,u8); GRID_SIZE*GRID_SIZE*GRID_SIZE] = include!("100d.rs");
| ^^^^^^^^^^^^
warning: 2 warnings emitted
real 0m31.938s
user 0m0.000s
sys 0m0.031s
100s vs 100: ~3% faster
100d vs 100s: within variance I think
Measurements from Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
Meta
$ rustc --version --verbose
rustc 1.84.1 (e71f9a9a9 2025-01-27)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-pc-windows-gnu
release: 1.84.1
LLVM version: 19.1.5
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.