Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add size-optimized FFI functions for Locale and DataProvider #962

Merged
merged 17 commits into from
Aug 18, 2021

Conversation

sffc
Copy link
Member

@sffc sffc commented Aug 18, 2021

This PR copies the fixeddecimal example to use small-code functions.

optim5.elf is 56 KB after this change (60 KB if I keep the additional coverage tests).

@sffc sffc requested a review from Manishearth August 18, 2021 00:36
@coveralls
Copy link

coveralls commented Aug 18, 2021

Pull Request Test Coverage Report for Build f4c807cf2c1cd4b83f44009de1a393a49a5e16ea-PR-962

  • 65 of 87 (74.71%) changed or added relevant lines in 6 files are covered.
  • 10 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 75.031%

Changes Missing Coverage Covered Lines Changed/Added Lines %
utils/writeable/src/impls.rs 58 60 96.67%
ffi/capi/src/locale.rs 0 6 0.0%
ffi/capi/src/provider.rs 0 6 0.0%
ffi/capi/src/decimal.rs 0 8 0.0%
Files with Coverage Reduction New Missed Lines %
provider/blob/src/static_data_provider.rs 10 37.5%
Totals Coverage Status
Change from base Build 245eb95ee01b2cabdea611a2f1b8436b4ad7890b: -0.06%
Covered Lines: 9679
Relevant Lines: 12900

💛 - Coveralls

Manishearth
Manishearth previously approved these changes Aug 18, 2021
ICU4XLocale* locale = ICU4XLocale_create("bn", 2);
ICU4XCreateDataProviderResult result = ICU4XDataProvider_create_static();
ICU4XLocale* locale = ICU4XLocale_create_bn();
ICU4XCreateFixedDecimalFormatDataProviderResult result = ICU4XFixedDecimalFormatDataProvider_create_static();
Copy link
Member

Choose a reason for hiding this comment

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

thought: Given these changes should we split this example into an entirely separate one? That way we can have a "normal" FDF example as a real example, and then the size optimized one can be as weird as it likes

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • .github/workflows/build-test.yml is now changed in the branch
  • Cargo.lock is different
  • ffi/capi/Cargo.toml is different
  • ffi/capi/examples/fixeddecimal/test.c is different
  • ffi/capi/include/ICU4XCreateFixedDecimalFormatDataProviderResult.h is no longer changed in the branch
  • ffi/capi/include/ICU4XCreateStaticDataProviderResult.h is now changed in the branch
  • ffi/capi/include/ICU4XFixedDecimalFormat.h is different
  • ffi/capi/include/ICU4XFixedDecimalFormatDataProvider.h is no longer changed in the branch
  • ffi/capi/include/ICU4XStaticDataProvider.h is now changed in the branch
  • ffi/capi/src/decimal.rs is different
  • ffi/capi/src/fixed_decimal.rs is now changed in the branch
  • ffi/capi/src/locale_canonicalizer.rs is now changed in the branch
  • ffi/capi/src/locale.rs is different
  • ffi/capi/src/pluralrules.rs is now changed in the branch
  • ffi/capi/src/provider.rs is now changed in the branch
  • ffi/cpp/docs/source/decimal_ffi.rst is now changed in the branch
  • ffi/cpp/docs/source/locale_ffi.rst is now changed in the branch
  • ffi/cpp/docs/source/provider_ffi.rst is now changed in the branch
  • ffi/cpp/include/ICU4XCreateFixedDecimalFormatDataProviderResult.hpp is no longer changed in the branch
  • ffi/cpp/include/ICU4XCreateStaticDataProviderResult.h is now changed in the branch
  • ffi/cpp/include/ICU4XCreateStaticDataProviderResult.hpp is now changed in the branch
  • ffi/cpp/include/ICU4XFixedDecimalFormat.h is different
  • ffi/cpp/include/ICU4XFixedDecimalFormat.hpp is different
  • ffi/cpp/include/ICU4XFixedDecimalFormatDataProvider.hpp is no longer changed in the branch
  • ffi/cpp/include/ICU4XLocale.hpp is different
  • ffi/cpp/include/ICU4XStaticDataProvider.h is now changed in the branch
  • ffi/cpp/include/ICU4XStaticDataProvider.hpp is now changed in the branch
  • ffi/wasm/docs/decimal_ffi.rst is now changed in the branch
  • ffi/wasm/docs/locale_ffi.rst is now changed in the branch
  • ffi/wasm/docs/provider_ffi.rst is now changed in the branch
  • ffi/wasm/lib/api.mjs is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • .github/workflows/build-test.yml is no longer changed in the branch
  • ffi/capi/src/fixed_decimal.rs is no longer changed in the branch
  • ffi/capi/src/locale_canonicalizer.rs is no longer changed in the branch
  • ffi/capi/src/pluralrules.rs is no longer changed in the branch

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@codecov-commenter
Copy link

codecov-commenter commented Aug 18, 2021

Codecov Report

Merging #962 (6fea805) into main (245eb95) will decrease coverage by 0.06%.
The diff coverage is 74.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #962      +/-   ##
==========================================
- Coverage   75.05%   74.99%   -0.07%     
==========================================
  Files         215      216       +1     
  Lines       12652    12732      +80     
==========================================
+ Hits         9496     9548      +52     
- Misses       3156     3184      +28     
Impacted Files Coverage Δ
ffi/capi/src/decimal.rs 0.00% <0.00%> (ø)
ffi/capi/src/locale.rs 0.00% <0.00%> (ø)
ffi/capi/src/provider.rs 0.00% <0.00%> (ø)
utils/writeable/src/lib.rs 90.00% <ø> (ø)
utils/writeable/src/impls.rs 96.66% <96.66%> (ø)
provider/blob/src/path_util.rs 100.00% <100.00%> (ø)
provider/core/src/resource.rs 82.77% <100.00%> (+0.74%) ⬆️
provider/blob/src/static_data_provider.rs 37.50% <0.00%> (-17.05%) ⬇️
utils/fixed_decimal/src/decimal.rs 94.69% <0.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 245eb95...6fea805. Read the comment docs.

@sffc sffc requested a review from Manishearth August 18, 2021 06:57
@sffc sffc marked this pull request as ready for review August 18, 2021 06:57
@sffc sffc requested a review from a team as a code owner August 18, 2021 06:57
@sffc sffc changed the title Low-hanging fruit for code size improvements Add size-optimized FFI functions for Locale and DataProvider Aug 18, 2021
@sffc
Copy link
Member Author

sffc commented Aug 18, 2021

The CI error is

  = note: /usr/bin/ld: error: LLVM gold plugin has failed to create LTO module: Invalid record
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I cannot reproduce this locally on the specified toolchain version (nightly-2021-02-28), although I can reproduce it on other toolchain versions like nightly-2021-08-18.

I suspect the issue is most likely a different version of lld on CI than I have on my local computer. According to rust-lang/rust#60059 (comment), it is necessary to use a specific version of lld found in Rust's fork of LLVM.

Should I:

  1. Keep trying to get a build running in CI
  2. Remove the CI for now and work on it in a follow-up

Manishearth
Manishearth previously approved these changes Aug 18, 2021
@Manishearth
Copy link
Member

  = note: /usr/bin/ld: error: LLVM gold plugin has failed to create LTO module: Invalid record
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

in test-capi-tiny

@sffc
Copy link
Member Author

sffc commented Aug 18, 2021

  = note: /usr/bin/ld: error: LLVM gold plugin has failed to create LTO module: Invalid record
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

in test-capi-tiny

Thoughts on the question I posed in my previous post?

@Manishearth
Copy link
Member

I'd remove the CI for now and document the specific steps.

@sffc sffc merged commit d320b04 into unicode-org:main Aug 18, 2021
@sffc sffc deleted the codesize2 branch August 18, 2021 18:35
@sffc sffc linked an issue Aug 18, 2021 that may be closed by this pull request
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.

Determine low-hanging fruit in FixedDecimalFormat FFI example
4 participants