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

feat: support JIT like compilation #1434

Merged
merged 34 commits into from
Jun 27, 2023
Merged

Conversation

kazupon
Copy link
Member

@kazupon kazupon commented Jun 19, 2023

Background

vue-i18n has had a message compiler since v9.
The message compiler compiles messages in I18n resources in formats such as json, yaml and js / ts into a javascript executable for AoT like. This allowed us to maximize performance in v9.

Issues and Limitations

However, the resulting problem is that it does not work in environments with CSP restrictions.

To make it work in such environments, it is possible to avoid this problem by compiling and bundling i18n resources in advance with bundlers such as unplugin-vue-i18n

And, it's difficult to deal with environments such as service workers.

In addition, it is difficult to import i18n resources dynamically from a DB or other source via the backend API.

related issues

nuxt i18n module v8 beta has currently some issues triggered by pre-compilation of the message compiler:

@kazupon kazupon marked this pull request as ready for review June 22, 2023 14:18
@kazupon
Copy link
Member Author

kazupon commented Jun 27, 2023

bench mark:

> node ./benchmark/index.mjs

compilation:

compile simple message x 312,721 ops/sec ±1.47% (96 runs sampled)
compile complex message x 49,949 ops/sec ±0.51% (95 runs sampled)

simple pattern on 1000 resources (AOT):

resolve time with core x 250,851 ops/sec ±0.69% (98 runs sampled)
resolve time on composition x 91,027 ops/sec ±0.68% (96 runs sampled)
resolve time on composition with compile cache x 222,005 ops/sec ±0.31% (100 runs sampled)

simple pattern on 1000 resources (JIT):

resolve time with core x 252,275 ops/sec ±0.19% (100 runs sampled)
resolve time on composition x 93,385 ops/sec ±0.64% (97 runs sampled)
resolve time on composition with compile cache x 221,485 ops/sec ±0.45% (100 runs sampled)

simple pattern on 1000 resources (JIT + AOT):

resolve time with core x 315,706 ops/sec ±0.36% (97 runs sampled)
resolve time on composition x 227,192 ops/sec ±0.57% (98 runs sampled)
resolve time on composition with compile cache x 228,938 ops/sec ±0.76% (96 runs sampled)

complex pattern on 1000 resources (AOT):

resolve time with core x 217,489 ops/sec ±0.90% (99 runs sampled)
resolve time on composition x 31,493 ops/sec ±0.72% (96 runs sampled)
resolve time on composition with compile cache x 192,985 ops/sec ±0.15% (98 runs sampled)

complex pattern on 1000 resources (JIT):

resolve time with core x 204,574 ops/sec ±0.26% (99 runs sampled)
resolve time on composition x 33,833 ops/sec ±0.82% (96 runs sampled)
resolve time on composition with compile cache x 180,907 ops/sec ±0.38% (100 runs sampled)

complex pattern on 1000 resources (JIT + AOT):

resolve time with core x 277,086 ops/sec ±0.20% (98 runs sampled)
resolve time on composition x 103,517 ops/sec ±0.82% (96 runs sampled)
resolve time on composition with compile cache x 104,429 ops/sec ±0.44% (100 runs sampled)

@kazupon kazupon merged commit a28060b into master Jun 27, 2023
@kazupon kazupon deleted the feature/jit-style-compilation branch June 27, 2023 11:13
@kazupon kazupon added the Type: Feature Includes new features label Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Includes new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant