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

refactor(compiler): use native BigInt when calculating i18n digests #48321

Closed
wants to merge 1 commit into from

Conversation

clydin
Copy link
Member

@clydin clydin commented Dec 2, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

To further modernize and improve the performance of the i18n digest generation, The 64-bit aspects of the process now use the native BigInt instead of a custom JavaScript implementation. This removes the need for the big_integer helper code and associated tests as the code was not used anywhere else in the framework. Only the BigInt constructor, BigInt.asUintN function, and .toString function are currently used. BigInt literals can unfortunately not yet be used due to the bazel test devmode setup which compiles the TypeScript code at an EcmaScript level that does not yet support the literals.

This change plus the recent DataView refactoring results in a ~15% performance improvement for digest calculation.

Browser support information (@angular/compiler should only be present in an application if using JIT mode):

Node.js 10.4.0 and higher also provide support (Angular officially supports ^14.20.0 || ^16.13.0 || ^18.10.0).

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@clydin clydin added target: minor This PR is targeted for the next minor release area: compiler Issues related to `ngc`, Angular's template compiler labels Dec 2, 2022
@ngbot ngbot bot added this to the Backlog milestone Dec 2, 2022
@clydin clydin requested a review from JoostK December 2, 2022 15:43
@clydin clydin marked this pull request as ready for review December 2, 2022 15:43
@clydin clydin added action: review The PR is still awaiting reviews from at least one requested reviewer state: blocked and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Dec 2, 2022
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

Nice cleanup!

packages/compiler/src/i18n/digest.ts Show resolved Hide resolved
@clydin clydin force-pushed the i18n/digest-bigint branch 2 times, most recently from aeb4ea1 to 36c110d Compare December 7, 2022 00:44
To further modernize and improve the performance of the i18n digest generation,
The 64-bit aspects of the process now use the native `BigInt` instead of a
custom JavaScript implementation. This removes the need for the big_integer
helper code and associated tests as the code was not used anywhere else in the
framework. Only the `BigInt` constructor, `BigInt.asUintN` function, and
`.toString` function are currently used. `BigInt` literals can unfortunately
not yet be used due to the bazel test devmode setup which compiles the TypeScript
code at an EcmaScript level that does not yet support the literals.

Browser support information:
- BigInt constructor: https://caniuse.com/mdn-javascript_builtins_bigint_bigint
- BigInt asUintN: https://caniuse.com/mdn-javascript_builtins_bigint_asuintn
- BigInt toString: https://caniuse.com/mdn-javascript_builtins_bigint_tostring
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@clydin this change looks great 👍

@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Sep 7, 2023
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 0f10d75.

@clydin clydin deleted the i18n/digest-bigint branch September 8, 2023 22:23
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 9, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
…ngular#48321)

To further modernize and improve the performance of the i18n digest generation,
The 64-bit aspects of the process now use the native `BigInt` instead of a
custom JavaScript implementation. This removes the need for the big_integer
helper code and associated tests as the code was not used anywhere else in the
framework. Only the `BigInt` constructor, `BigInt.asUintN` function, and
`.toString` function are currently used. `BigInt` literals can unfortunately
not yet be used due to the bazel test devmode setup which compiles the TypeScript
code at an EcmaScript level that does not yet support the literals.

Browser support information:
- BigInt constructor: https://caniuse.com/mdn-javascript_builtins_bigint_bigint
- BigInt asUintN: https://caniuse.com/mdn-javascript_builtins_bigint_asuintn
- BigInt toString: https://caniuse.com/mdn-javascript_builtins_bigint_tostring

PR Close angular#48321
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants