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

fix(content): only collect required translations #8806

Merged
merged 2 commits into from
May 19, 2023

Conversation

yin1999
Copy link
Member

@yin1999 yin1999 commented May 9, 2023

Summary

Trying to fix and as a part of #8301

Gather all translation would slow down the static document build in translated-content. Only gather the translations of the incoming slug might be a better idea.

Problem

After we migrating to ESM, the PR-test ci in translated-content would spend more than 25 seconds to build a single document (as in most of PRs, the number of changed documents is only 1). The most of time during a build is spent on
gathering all translations (as metioned in #8301).

Solution

Try to gather the translations of a required slug only, this should save most of the time for build a single document.


Using a locale build of yari to check the build time.

Run yarn build files/en-us/learn/common_questions/web_mechanics/what_is_a_web_server/index.md
and node node_modules/@mdn/yari/build/cli.js files/zh-tw/learn/common_questions/web_mechanics/what_is_a_web_server/index.md to build document.

Screenshots

Before

~16 seconds are used to build a single document.

image

After

image

~1 seconds are used to build a single document.

run yarn start in content

image


Gather all translation would slow down the static document build in
translated-content. Only gather the translations of the incoming slug
might be a better idea.
@yin1999 yin1999 changed the title fix(content): only collect needed translations fix(content): only collect required translations May 9, 2023
Copy link
Member

@LeoMcA LeoMcA left a comment

Choose a reason for hiding this comment

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

Nice optimisation! Logic looks solid, just some syntax comments:

content/translations.ts Outdated Show resolved Hide resolved
content/translations.ts Outdated Show resolved Hide resolved
content/translations.ts Outdated Show resolved Hide resolved
content/translations.ts Outdated Show resolved Hide resolved
content/translations.ts Outdated Show resolved Hide resolved
@yin1999 yin1999 requested a review from LeoMcA May 19, 2023 11:26
@yin1999
Copy link
Member Author

yin1999 commented May 19, 2023

Thanks for the suggestions @LeoMcA, I've tested again for building the translated document:

image

Copy link
Member

@LeoMcA LeoMcA left a comment

Choose a reason for hiding this comment

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

Fantastic, thanks for this!

@LeoMcA LeoMcA merged commit 5ec562c into mdn:main May 19, 2023
@yin1999 yin1999 deleted the gather-translations branch May 19, 2023 11:54
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.

2 participants