Skip to content

Conversation

@sffc
Copy link
Member

@sffc sffc commented Dec 12, 2025

Depends on #7310

This should have been done after #5230 but got dropped.

@sffc
Copy link
Member Author

sffc commented Dec 12, 2025

Build time measurements of the icu_datetime crate with default features:

Before:

$ /usr/bin/time -f "%es, %M kB" cargo build --release
   Compiling icu_datetime v2.1.1
    Finished `release` profile [optimized] target(s) in 4.11s
4.17s, 632548 kB

$ /usr/bin/time -f "%e sec, %M kB" cargo build --release
   Compiling icu_datetime v2.1.1
    Finished `release` profile [optimized] target(s) in 4.01s
4.07 sec, 634132 kB

After:

$ /usr/bin/time -f "%e sec, %M kB" cargo build --release
   Compiling icu_datetime v2.1.1
    Finished `release` profile [optimized] target(s) in 3.27s
3.33 sec, 586932 kB

$ /usr/bin/time -f "%e sec, %M kB" cargo build --release
   Compiling icu_datetime v2.1.1
    Finished `release` profile [optimized] target(s) in 3.22s
3.28 sec, 587620 kB

@sffc
Copy link
Member Author

sffc commented Dec 12, 2025

Benchmark measurements:

Benchmarks that say "format only" are unchanged. Ones that say "construct and format" have a regression of somewhere between 1% and 9% depending on how my computer is feeling; the consensus seems to be somewhere around 5-6%. To reproduce, run: cargo bench --all-features construct_and_format

@sffc
Copy link
Member Author

sffc commented Dec 12, 2025

If I mark the ZeroFrom impl as inline, the results are still noisy but seem to go down to about 3-4% regression.

@sffc
Copy link
Member Author

sffc commented Dec 12, 2025

Finally, code size.

Before:

Details
-rwxr-xr-x 1 sffc primarygroup   52750 Dec 11 17:57 and_list.wasm
-rwxr-xr-x 1 sffc primarygroup   41593 Dec 11 17:57 casemapping.wasm
-rwxr-xr-x 1 sffc primarygroup  276517 Dec 11 17:57 chrome_transliterators.wasm
-rwxr-xr-x 1 sffc primarygroup 3409535 Dec 11 17:57 chrono_jiff.wasm
-rwxr-xr-x 1 sffc primarygroup   36041 Dec 11 17:57 code_line_diff.wasm
-rwxr-xr-x 1 sffc primarygroup   47052 Dec 11 17:57 date_try_from_fields.wasm
-rwxr-xr-x 1 sffc primarygroup    9306 Dec 11 17:57 derives.wasm
-rwxr-xr-x 1 sffc primarygroup   22222 Dec 11 17:57 elevator_floors.wasm
-rwxr-xr-x 1 sffc primarygroup     415 Dec 11 17:57 experimental_segmenter.wasm
-rwxr-xr-x 1 sffc primarygroup   14863 Dec 11 17:57 filter_langids.wasm
-rwxr-xr-x 1 sffc primarygroup   12318 Dec 11 17:57 first_weekday_for_region.wasm
-rwxr-xr-x 1 sffc primarygroup    1492 Dec 11 17:57 iso_date_manipulations.wasm
-rwxr-xr-x 1 sffc primarygroup   10836 Dec 11 17:57 language_names_hash_map.wasm
-rwxr-xr-x 1 sffc primarygroup   16187 Dec 11 17:57 language_names_lite_map.wasm
-rwxr-xr-x 1 sffc primarygroup   28387 Dec 11 17:57 litemap_bincode.wasm
-rwxr-xr-x 1 sffc primarygroup   16921 Dec 11 17:57 litemap_postcard.wasm
-rwxr-xr-x 1 sffc primarygroup  104287 Dec 11 17:57 make_var.wasm
-rwxr-xr-x 1 sffc primarygroup    8052 Dec 11 17:57 make.wasm
-rwxr-xr-x 1 sffc primarygroup    8994 Dec 11 17:57 permyriad.wasm
-rwxr-xr-x 1 sffc primarygroup   31682 Dec 11 17:57 syntatically_canonicalize_locales.wasm
-rwxr-xr-x 1 sffc primarygroup 2712024 Dec 11 17:57 timezone_picker.wasm
-rwxr-xr-x 1 sffc primarygroup  341108 Dec 11 17:57 tui.wasm
-rwxr-xr-x 1 sffc primarygroup    9156 Dec 11 17:57 unicode_bmp_blocks_selector.wasm
-rwxr-xr-x 1 sffc primarygroup   23988 Dec 11 17:57 unread_emails.wasm
-rwxr-xr-x 1 sffc primarygroup  306727 Dec 11 17:57 work_log.wasm
-rwxr-xr-x 1 sffc primarygroup   19494 Dec 11 17:57 writeable_message.wasm
-rwxr-xr-x 1 sffc primarygroup    3420 Dec 11 17:57 yoke_derive.wasm
-rwxr-xr-x 1 sffc primarygroup    3415 Dec 11 17:57 zf_derive.wasm
-rwxr-xr-x 1 sffc primarygroup     559 Dec 11 17:57 zv_serde.wasm

After:

Details
-rwxr-xr-x 1 sffc primarygroup   52750 Dec 11 17:58 and_list.wasm
-rwxr-xr-x 1 sffc primarygroup   41593 Dec 11 17:58 casemapping.wasm
-rwxr-xr-x 1 sffc primarygroup  276873 Dec 11 17:58 chrome_transliterators.wasm
-rwxr-xr-x 1 sffc primarygroup 3737310 Dec 11 17:58 chrono_jiff.wasm
-rwxr-xr-x 1 sffc primarygroup   36041 Dec 11 17:58 code_line_diff.wasm
-rwxr-xr-x 1 sffc primarygroup   47052 Dec 11 17:58 date_try_from_fields.wasm
-rwxr-xr-x 1 sffc primarygroup    9306 Dec 11 17:58 derives.wasm
-rwxr-xr-x 1 sffc primarygroup   22222 Dec 11 17:58 elevator_floors.wasm
-rwxr-xr-x 1 sffc primarygroup     415 Dec 11 17:58 experimental_segmenter.wasm
-rwxr-xr-x 1 sffc primarygroup   14863 Dec 11 17:58 filter_langids.wasm
-rwxr-xr-x 1 sffc primarygroup   12318 Dec 11 17:58 first_weekday_for_region.wasm
-rwxr-xr-x 1 sffc primarygroup    1492 Dec 11 17:58 iso_date_manipulations.wasm
-rwxr-xr-x 1 sffc primarygroup   10836 Dec 11 17:58 language_names_hash_map.wasm
-rwxr-xr-x 1 sffc primarygroup   16187 Dec 11 17:58 language_names_lite_map.wasm
-rwxr-xr-x 1 sffc primarygroup   28387 Dec 11 17:58 litemap_bincode.wasm
-rwxr-xr-x 1 sffc primarygroup   16921 Dec 11 17:58 litemap_postcard.wasm
-rwxr-xr-x 1 sffc primarygroup  104287 Dec 11 17:58 make_var.wasm
-rwxr-xr-x 1 sffc primarygroup    8052 Dec 11 17:58 make.wasm
-rwxr-xr-x 1 sffc primarygroup    8994 Dec 11 17:58 permyriad.wasm
-rwxr-xr-x 1 sffc primarygroup   31682 Dec 11 17:58 syntatically_canonicalize_locales.wasm
-rwxr-xr-x 1 sffc primarygroup 2712024 Dec 11 17:58 timezone_picker.wasm
-rwxr-xr-x 1 sffc primarygroup  335574 Dec 11 17:58 tui.wasm
-rwxr-xr-x 1 sffc primarygroup    9156 Dec 11 17:58 unicode_bmp_blocks_selector.wasm
-rwxr-xr-x 1 sffc primarygroup   23988 Dec 11 17:58 unread_emails.wasm
-rwxr-xr-x 1 sffc primarygroup  301186 Dec 11 17:58 work_log.wasm
-rwxr-xr-x 1 sffc primarygroup   19494 Dec 11 17:58 writeable_message.wasm
-rwxr-xr-x 1 sffc primarygroup    3420 Dec 11 17:58 yoke_derive.wasm
-rwxr-xr-x 1 sffc primarygroup    3415 Dec 11 17:58 zf_derive.wasm
-rwxr-xr-x 1 sffc primarygroup     559 Dec 11 17:58 zv_serde.wasm

Differences:

Example Before After
chrome_transliterators.wasm 276517 276873
chrono_jiff.wasm 3409535 3737310
tui.wasm 341108 335574
work_log.wasm 306727 301186

tui and work_log get smaller, but chrono_jiff, which is already big, gets bigger. 🤔

@sffc sffc marked this pull request as ready for review December 12, 2025 02:06
@sffc sffc requested review from a team, Manishearth and zbraniecki as code owners December 12, 2025 02:06
@sffc
Copy link
Member Author

sffc commented Dec 12, 2025

Things to highlight:

  1. The build time reduction is fairly substantial (about 20%), but only on the icu_datetime crate
  2. There might be a small (<5%) performance regression on some microbenchmarks
  3. Code size measurements give mixed signals
  4. The trait unfortunately wasn't implemented with EncodeAsVarULE in mind, so this is a breaking change in icu_provider in a trait that isn't used by anything except hello_world (which lives in that crate) and is only implemented by macros that are versioned along with the crate. Do we care? Please speak up.

@dpulls
Copy link

dpulls bot commented Dec 13, 2025

🎉 All dependencies have been resolved !

@sffc
Copy link
Member Author

sffc commented Dec 13, 2025

Please review the whole PR; the commits got messy due to merges, and there isn't that much code being changed.

@sffc
Copy link
Member Author

sffc commented Dec 13, 2025

@Manishearth Do you think the metrics posted above justify the change?

@Manishearth
Copy link
Member

Manishearth commented Dec 13, 2025

Yes! I think the performance slowdown is basically noise and the build time improvement is important for one of our larger baked data crates.

Edit: hadn't really realized the size of the codesize loss in the chrono test. ignore!

Copy link
Member

@robertbastian robertbastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numbers don't look very conclusive to me, I don't think build time is that important given that runtime performance will suffer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this change?

@Manishearth
Copy link
Member

Yeah, we looked closer at this and determined we shouldn't land this, but that this was a good proof of concept. It was important to learn that depending on the data architecture, data deduplication may suffer with this type of optimization (which explains the large chrono_jiff codesize)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants