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(gatsby-plugin-mdx): generate mdx once when multiple mdx fields requested #32462

Merged
merged 1 commit into from Jul 23, 2021

Conversation

vladar
Copy link
Contributor

@vladar vladar commented Jul 21, 2021

Description

This PR is a performance improvement for one specific usage scenario of the MDX plugin. It addresses inefficiency in the plugin when multiple GraphQL fields are requested that require MDX processing. An example query that is affected:

{
    mdx {
      mdxAST
      body
    }
}

In this case, the plugin starts two MDX processing tasks concurrently as shown on this chart:

image

This PR accounts for such a scenario and only processes MDX once. For MDX-heavy sites using this pattern, e.g. https://github.com/newrelic/docs-website

This translates to the following difference in query running time:

Before this PR:

success run page queries - 2776.543s - 8324/8324 3.00/s

After this PR:

success run page queries - 1919.154s - 8324/8324 4.34/s

(image processing also affects those numbers, on a machine with more CPU cores or in Gatsby Cloud where image processing is additionally optimized it can yield even bigger difference)

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 21, 2021
@vladar vladar added topic: remark/mdx Related to Markdown, remark & MDX ecosystem topic: performance Related to runtime & build performance and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jul 21, 2021
pieh
pieh approved these changes Jul 23, 2021
@LekoArts LekoArts merged commit 0f8d747 into master Jul 23, 2021
34 checks passed
@LekoArts LekoArts deleted the vladar/no-unnecessary-mdx-gen branch Jul 23, 2021
@vladar vladar added this to To cherry-pick in V3 Release Hotfixes via automation Jul 23, 2021
LekoArts pushed a commit that referenced this issue Jul 26, 2021
@LekoArts LekoArts moved this from To cherry-pick to Backport PR opened in V3 Release Hotfixes Jul 26, 2021
LekoArts pushed a commit that referenced this issue Jul 26, 2021
…quested (#32462) (#32506)

(cherry picked from commit 0f8d747)

Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
@LekoArts LekoArts moved this from Backport PR opened to Backported in V3 Release Hotfixes Jul 26, 2021
@LekoArts LekoArts moved this from Backported to Published in V3 Release Hotfixes Jul 26, 2021
@LekoArts
Copy link
Contributor

LekoArts commented Jul 26, 2021

Published in gatsby-plugin-mdx@2.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: performance Related to runtime & build performance topic: remark/mdx Related to Markdown, remark & MDX ecosystem
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants