Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: gatsby@2.24.41
Choose a base ref
...
head repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: gatsby@2.24.42
Choose a head ref
  • 5 commits
  • 33 files changed
  • 4 contributors

Commits on Aug 11, 2020

  1. feat(gatsby-cli): Allow setting the server status port (#25862)

    * feat: Allow choosing the status port via CLI option or ENV var
    
    * docs: Add note to `gatsby-cli` README for `--status-port`
    
    * fix: Don't spam browser console with errors if websockets disconnect
    
    * chore: Emphasize this is an internal feature
    
    * chore: Resolve PR review change requests
    polarathene authored Aug 11, 2020
    Copy the full SHA
    67615bf View commit details
  2. benchmarks(mdx): add new baseline mdx benchmark (#26265)

    * benchmarks(mdx): add new baseline mdx benchmark
    
    * mdx2 -> mdx-without-images
    pvdz authored Aug 11, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    930bb25 View commit details
  3. Copy the full SHA
    87babc9 View commit details
  4. fix(gatsby-plugin-page-creator): juggle reporter dont depend on cli (#…

    …26357)
    
    * fix(gatsby-plugin-page-creator): juggle reporter rather than depend on cli
    
    * Add missing reporter type
    pvdz authored Aug 11, 2020
    Copy the full SHA
    2cef73b View commit details
  5. chore(release): Publish

     - gatsby-admin@0.1.131
     - gatsby-plugin-page-creator@2.3.22
     - gatsby@2.24.42
    pvdz committed Aug 11, 2020
    Copy the full SHA
    cadb2b5 View commit details
Showing with 502 additions and 21 deletions.
  1. +2 −0 benchmarks/mdx-without-images/.gitattributes
  2. +6 −0 benchmarks/mdx-without-images/.gitignore
  3. +7 −0 benchmarks/mdx-without-images/.prettierrc.js
  4. +21 −0 benchmarks/mdx-without-images/LICENSE
  5. +31 −0 benchmarks/mdx-without-images/README.md
  6. +1 −0 benchmarks/mdx-without-images/gatsby-browser.js
  7. +24 −0 benchmarks/mdx-without-images/gatsby-config.js
  8. +69 −0 benchmarks/mdx-without-images/gatsby-node.js
  9. +43 −0 benchmarks/mdx-without-images/gen.js
  10. +40 −0 benchmarks/mdx-without-images/package.json
  11. +12 −0 benchmarks/mdx-without-images/src/components/layout_1.js
  12. +12 −0 benchmarks/mdx-without-images/src/components/layout_2.js
  13. +40 −0 benchmarks/mdx-without-images/src/pages/#index.js#
  14. +40 −0 benchmarks/mdx-without-images/src/pages/index.js
  15. +34 −0 benchmarks/mdx-without-images/src/templates/article.js
  16. BIN benchmarks/mdx-without-images/static/favicon.ico
  17. +4 −0 benchmarks/mdx-without-images/styles.css
  18. +4 −0 packages/gatsby-admin/CHANGELOG.md
  19. +2 −2 packages/gatsby-admin/package.json
  20. +6 −0 packages/gatsby-plugin-page-creator/CHANGELOG.md
  21. +1 −1 packages/gatsby-plugin-page-creator/package.json
  22. +2 −2 packages/gatsby-plugin-page-creator/src/__tests__/is-valid-collection-path-implementation.ts
  23. +10 −2 packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts
  24. +32 −7 packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts
  25. +9 −2 packages/gatsby-plugin-page-creator/src/gatsby-node.ts
  26. +5 −2 packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts
  27. +10 −0 packages/gatsby/CHANGELOG.md
  28. +9 −0 packages/gatsby/cache-dir/app.js
  29. +8 −0 packages/gatsby/cache-dir/socketIo.js
  30. +2 −2 packages/gatsby/package.json
  31. +8 −1 packages/gatsby/src/commands/develop.ts
  32. +1 −0 packages/gatsby/src/utils/develop-proxy.ts
  33. +7 −0 packages/gatsby/src/utils/restarting-screen.ts
2 changes: 2 additions & 0 deletions benchmarks/mdx-without-images/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
6 changes: 6 additions & 0 deletions benchmarks/mdx-without-images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
.cache/
public/
.env
generated_articles
.DS_Store
7 changes: 7 additions & 0 deletions benchmarks/mdx-without-images/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
endOfLine: "lf",
semi: false,
singleQuote: false,
tabWidth: 2,
trailingComma: "es5",
}
21 changes: 21 additions & 0 deletions benchmarks/mdx-without-images/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Peter van der Zee

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions benchmarks/mdx-without-images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# MDX Benchmark

This is a baseline benchmark for tracking MDX performance.

The site can generate an arbitrary amount of super simple pages. Each page has a small header, imports a file, and has two small paragraphs of random text. No images, because we want to benchmark MDX.

This uses the local file system plugin, though we might switch to sourcing from csv since that has a more efficient internal representation (fewer `File` nodes).

## Install

Run `yarn` or `npm install`

## Usage

You can start a benchmark run like this:

```shell
CI=1 N=1000 M=2 yarn bench
```

- `CI=1`: this enables the fastest reporter, with simplest output, that we have
- `N=1000`: instructs the run to build a site of 1000 pages
- `M=2`: instructs nodejs to use up to 2gb of memory for its long term storage
- Deletes generates files from previous run
- Generates `N` pages with pseudo-random content
- Runs `gatsby clean`
- Runs `gatsby build`

The default `yarn bench` will build 512 pages with 1gb memory.

There is also `yarn bench:inspect` for debugging with the Chrome devtools.
1 change: 1 addition & 0 deletions benchmarks/mdx-without-images/gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./styles.css"
24 changes: 24 additions & 0 deletions benchmarks/mdx-without-images/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
siteMetadata: {
siteTitle: `Gatsby MDX Benchmark`,
},
plugins: [
// Skip the plugin if NBR is set
...process.env.NBR ? [] : [`gatsby-plugin-benchmark-reporting`],
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/pages/`,
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "articles",
path: `${__dirname}/generated_articles/`,
},
},
`gatsby-plugin-mdx`,
],
}
69 changes: 69 additions & 0 deletions benchmarks/mdx-without-images/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const path = require("path")
const { createFilePath } = require("gatsby-source-filesystem")

exports.onCreateNode = (args) => {
const { node, actions, getNode, ...rest } = args;
const { createNodeField } = actions

if (node.internal.type === "Mdx") {
const value = createFilePath({ node, getNode })

createNodeField({
name: "path",
node,
value,
})
}
}


exports.createPages = async ({ graphql, actions, reporter }) => {
const progress = reporter.createProgress(`(userland gatsby-node) createPages`)
console.time("(userland gatsby-node) total exports.createPages")
progress.setStatus("initial graphl query")

const { createPage } = actions

console.time("(userland gatsby-node) initial graphql query")
const result = await graphql(`
query {
allMdx {
edges {
node {
id
fields {
path
}
}
}
}
}
`)
console.timeEnd("(userland gatsby-node) initial graphql query")

if (result.errors) {
reporter.panicOnBuild('🚨 ERROR: Loading "createPages" query')
}

console.time("(userland gatsby-node) created pages")

const posts = result.data.allMdx.edges

progress.start()
progress.total = posts.length
progress.setStatus("Calling createPage for all pages")

posts.forEach(({ node }) => {
createPage({
path: node.fields.path,
component: path.resolve(`./src/templates/article.js`),
context: { id: node.id },
})
progress.tick(1)
})

console.timeEnd("(userland gatsby-node) created pages")
console.timeEnd("(userland gatsby-node) total exports.createPages")

progress.done()
}
43 changes: 43 additions & 0 deletions benchmarks/mdx-without-images/gen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const fs = require('fs');
const path = require('path')
const faker = require(`faker`)

const N = parseInt(process.env.N, 10) || 100;

let n = 0;
function createArticle(n, sentence, slug) {
return `---
articleNumber: ${n}
title: "${sentence.replace(/"/g, '\\"')}"
path: '${slug}'
date: ${faker.date.recent(1000).toISOString().slice(0, 10)}
---
import { Link } from "gatsby"
export const author = "Fred Flintstone"
export default props => <main {...props} />
<Link to="/">Go Home</Link>
${faker.lorem.paragraphs(2)}
`;
}

console.log('Start of gen')

if (fs.existsSync('./generated_articles')) {
TODO // count existing folders. If they are less than given number, just amend to them. Otherwise abort and require a rimraf
} else {
fs.mkdirSync('./generated_articles', {recursive: true});
}

console.log('Now generating ' + N + ' articles');
for (let i=0; i<N; ++i) {
const sentence = faker.lorem.sentence();
const slug = faker.helpers.slugify(sentence).toLowerCase();
fs.writeFileSync(path.join('./generated_articles', slug + '.mdx'), createArticle(i, sentence, slug))
}
console.log('Finished generating ' + N + ' articles');
console.log('End of gen')

40 changes: 40 additions & 0 deletions benchmarks/mdx-without-images/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "mdx2",
"private": true,
"description": "Benchmark site for testing baseline mdx perf",
"author": "Peter van der Zee <pvdz@github>",
"version": "0.1.0",
"license": "MIT",
"scripts": {
"bench": "rm -rf generated_articles; gatsby clean; N=${N:-512} node gen.js; NBR=1 node --max_old_space_size=${M:-2}000 node_modules/.bin/gatsby build",
"bench:inspect": "rm -rf generated_articles; gatsby clean; N=${N:-512} node gen.js; NBR=1 node --inspect --max_old_space_size=${M:-2}000 node_modules/.bin/gatsby build",
"build": "gatsby build",
"clean": "gatsby clean",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\""
},
"dependencies": {
"@mdx-js/mdx": "1.6.6",
"@mdx-js/react": "1.6.6",
"faker": "^4.1.0",
"front-matter": "4.0.2",
"gatsby": "2.24.2",
"gatsby-plugin-benchmark-reporting": "*",
"gatsby-plugin-mdx": "1.2.25",
"gatsby-plugin-page-creator": "2.3.10",
"gatsby-source-filesystem": "2.3.18",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"remark-react": "^7.0.1"
},
"devDependencies": {
"prettier": "2.0.4"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby/tree/master/benchmarks/mdx2"
},
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
}
}
12 changes: 12 additions & 0 deletions benchmarks/mdx-without-images/src/components/layout_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react"

const Layout = ({ children }) => (
<>
<header>
<h1>Header A</h1>
</header>
<main>{children}</main>
</>
)

export default Layout
12 changes: 12 additions & 0 deletions benchmarks/mdx-without-images/src/components/layout_2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react"

const Layout = ({ children }) => (
<>
<header>
<h1>Header B</h1>
</header>
<main>{children}</main>
</>
)

export default Layout
40 changes: 40 additions & 0 deletions benchmarks/mdx-without-images/src/pages/#index.js#
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout_1"

const Index = ({ data }) => {
return (
<Layout>
{data.site.siteMetadata.siteTitle}
<ul>
{ data?.articles?.nodes.map((article) => (
<li key={article.fields.path}>
<Link to={article.fields.path}>{article.frontmatter.title}</Link>
</li>
))}
</ul>
</Layout>
)
}

export default Index

export const query = graphql`
{
site {
siteMetadata {
siteTitle
}
}
articles: allMdx(limit: 100) {
nodes {
frontmatter {
title
}
fields {
path
}
}
}
}
`
40 changes: 40 additions & 0 deletions benchmarks/mdx-without-images/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout_1"

const Index = ({ data }) => {
return (
<Layout>
{data.site.siteMetadata.siteTitle}
<ul>
{data?.articles?.nodes.map((article) => (
<li key={article.fields.path}>
<Link to={article.fields.path}>{article.frontmatter.title}</Link>
</li>
))}
</ul>
</Layout>
)
}

export default Index

export const query = graphql`
{
site {
siteMetadata {
siteTitle
}
}
articles: allMdx(limit: 100) {
nodes {
frontmatter {
title
}
fields {
path
}
}
}
}
`
34 changes: 34 additions & 0 deletions benchmarks/mdx-without-images/src/templates/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react"
import { graphql, Link } from "gatsby"
import Layout from "../components/layout_1"
import { MDXRenderer } from "gatsby-plugin-mdx"

const Article = ({ data }) => {
const { body } = data.mdx
const { mdx } = data

return (
<Layout>
<Link to="/">Go back to index page</Link>
<div>
<h1>{mdx.frontmatter.title}</h1>
<div>
<MDXRenderer>{body}</MDXRenderer>
</div>
</div>
</Layout>
)
}

export const query = graphql`
query MdxQuery($id: String!) {
mdx(id: { eq: $id }) {
body
frontmatter {
title
}
}
}
`

export default Article
Binary file added benchmarks/mdx-without-images/static/favicon.ico
Binary file not shown.
Loading