Ogeon / palette

A Rust library for linear color calculations and conversion
Apache License 2.0
751 stars 60 forks source link

Reduce the minimum compile time a bit #286

Closed Ogeon closed 2 years ago

Ogeon commented 2 years ago

Reduces the minimum compile time a bit by reducing the feature set of syn, making more dependencies optional and changing to dependency resolver version 2. I got inspired by #285 to at least make the build time somewhat better. This reduces it by about 30% on my slow laptop (from ~15 seconds to ~10 seconds), but your mileage may vary and it also depends on what other dependencies are in the mix.

Breaking Change

Slow Laptop Benchmarks

Slow laptop type    Microsoft Surface Pro 7 i5
Slow OS setup       Ubuntu in WSL2 in Windows 11
Processor           Intel(R) Core(TM) i5-1035G4 CPU @ 1.10GHz   1.50 GHz
Installed RAM       8,00 GB (7,60 GB usable)
System type         64-bit operating system, x64-based processor

rustc 1.62.0 (a8314ef7d 2022-06-27)

Commands

Debug mode:

cargo clean
cargo check --timings --no-default-features --features=std -p palette

Release mode:

cargo clean
cargo check --timings --no-default-features --features=std -p palette --release

Before

Debug mode Release mode
before - debug before - release

After

Debug mode Release mode
after - debug after - release
github-actions[bot] commented 2 years ago

Benchmark for d5591c5

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Cie family/lab to lch | 3.1±0.23µs | 3.0±0.23µs | -3.23% | | Cie family/lab to xyz | 788.1±55.90ns | 799.6±49.45ns | +1.46% | | Cie family/lch to lab | 2.5±0.17µs | 2.5±0.16µs | 0.00% | | Cie family/linsrgb to xyz | 4.0±0.27µs | 3.9±0.30µs | -2.50% | | Cie family/linsrgb to xyz - wide::f32x8 | **789.6±52.35ns** | 1263.8±81.30ns | **+60.06%** | | Cie family/xyz to lab | 18.7±1.62µs | 19.8±1.41µs | +5.88% | | Cie family/xyz to yxy | 615.0±31.74ns | **578.1±39.15ns** | **-6.00%** | | Cie family/yxy to xyz | 603.3±37.38ns | 603.5±45.17ns | +0.03% | | Matrix functions/matrix_inverse | 11.1±0.88ns | 11.6±0.85ns | +4.50% | | Matrix functions/multiply_3x3 | 10.6±0.71ns | 10.7±0.47ns | +0.94% | | Matrix functions/multiply_rgb_to_xyz | 5.7±0.36ns | 5.9±0.39ns | +3.51% | | Matrix functions/multiply_xyz | 5.9±0.92ns | 5.9±0.35ns | 0.00% | | Matrix functions/multiply_xyz_to_rgb | 5.7±0.34ns | 5.5±0.36ns | -3.51% | | Matrix functions/rgb_to_xyz_matrix | 22.3±1.79ns | 23.1±1.35ns | +3.59% | | Rgb family/hsl to hsv | **668.9±52.27ns** | 731.6±34.56ns | **+9.37%** | | Rgb family/hsl to linear hsl | 14.4±1.02µs | 14.2±0.98µs | -1.39% | | Rgb family/hsl to rgb | 2.3±0.12µs | 2.4±0.17µs | +4.35% | | Rgb family/hsv to hsl | **1053.1±52.17ns** | 1113.8±68.67ns | **+5.76%** | | Rgb family/hsv to hwb | 222.8±17.22ns | **210.5±10.56ns** | **-5.52%** | | Rgb family/hsv to linear hsv | 12.5±0.87µs | 12.2±0.83µs | -2.40% | | Rgb family/hsv to rgb | 2.2±0.29µs | 2.3±0.16µs | +4.55% | | Rgb family/hwb to hsv | 554.1±29.91ns | 559.2±26.30ns | +0.92% | | Rgb family/hwb to linear hwb | 12.4±0.75µs | 12.8±0.93µs | +3.23% | | Rgb family/linear hsl to hsl | 12.3±0.70µs | 12.2±0.83µs | -0.81% | | Rgb family/linear hsv to hsv | 10.8±0.68µs | 11.3±0.87µs | +4.63% | | Rgb family/linear hwb to hwb | 11.7±0.71µs | 11.4±0.83µs | -2.56% | | Rgb family/linsrgb to rgb | 6.3±0.39µs | 6.1±0.36µs | -3.17% | | Rgb family/linsrgb to rgb - wide::f32x8 | 8.1±0.56µs | 8.4±0.38µs | +3.70% | | Rgb family/linsrgb_f32 to rgb_u8 | 943.5±55.75ns | 907.2±59.08ns | -3.85% | | Rgb family/linsrgb_f64 to rgb_u8 | **1090.2±66.88ns** | 1153.5±62.96ns | **+5.81%** | | Rgb family/rgb to hsl | 933.1±51.86ns | 918.3±70.38ns | -1.59% | | Rgb family/rgb to hsl - wide::f32x8 | 600.2±25.30ns | 596.6±43.03ns | -0.60% | | Rgb family/rgb to hsv | 599.5±39.07ns | 625.6±34.43ns | +4.35% | | Rgb family/rgb to hsv - wide::f32x8 | 562.7±31.15ns | 566.9±44.38ns | +0.75% | | Rgb family/rgb to linsrgb | 8.8±0.55µs | 8.8±0.86µs | 0.00% | | Rgb family/rgb to linsrgb - wide::f32x8 | 7.0±0.56µs | **6.1±0.43µs** | **-12.86%** | | Rgb family/rgb_u8 to linsrgb_f32 | 315.6±17.69ns | 322.3±28.50ns | +2.12% | | Rgb family/rgb_u8 to linsrgb_f64 | **302.2±20.93ns** | 334.8±17.51ns | **+10.79%** | | Rgb family/xyz to linsrgb | 7.6±0.47µs | 7.4±0.53µs | -2.63% | | Rgb family/xyz to linsrgb - wide::f32x8 | 1098.4±55.21ns | **1035.6±57.50ns** | **-5.72%** |
Ogeon commented 2 years ago

bors r+

bors[bot] commented 2 years ago

Build succeeded: