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

github action to update benchmarks #106

Merged
merged 3 commits into from
Jan 20, 2020

Conversation

JamesKyburz
Copy link
Contributor

@JamesKyburz JamesKyburz commented Oct 6, 2019

  • Remove run directory (was added previously by mistake from benchmarks run)
  • Added run to gitignore
  • Fixed column error in markdown table generation (one too many --:)
  • Github Action to run benchmarks and update README.md
  • Allow benchmarks to work from CI without the need for interactive prompts

This PR is in response to #104

node-version: 10
- name: benchmarks
run: |
npm install
Copy link
Member

Choose a reason for hiding this comment

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

This is error prone and hard to manage. Put it in a separate file and let it be part of the linter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@StarpTech I have removed the inline node code to run the benchmarks, this required a fix to benchmark-bench.js to avoid the prompts.

Copy link
Member

Choose a reason for hiding this comment

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

My idea is to move the entire code in a file and just run e.g scripts/bench.js

@StarpTech
Copy link
Member

StarpTech commented Oct 6, 2019

For more realistic benchmark and better isolation I would run each benchmark in a separate ci job. You could generate that file very easily.

Each job runs in a fresh instance of the virtual environment specified by runs-on.

https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobs

@JamesKyburz
Copy link
Contributor Author

For more realistic benchmark and better isolation I would run each benchmark in a separate ci job. You could generate that file very easily.

Each job runs in a fresh instance of the virtual environment specified by runs-on.

https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobs

If the benchmarks were split into seperate jobs there would be no easy way to get the results of the entire run.

@StarpTech
Copy link
Member

If the benchmarks were split into seperate jobs there would be no easy way to get the results of the entire run.

That's possible but definitly out of scope here. I'm fine 👍

filter: Number
}
])
: (async () => {
Copy link
Member

Choose a reason for hiding this comment

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

async is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is was that or Promise.resolve. Do you want me to change the inline function to a resolved promise?

Copy link
Member

Choose a reason for hiding this comment

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

If async is an option would you mind to rewrite it to simply use async/await without ternarys?

@JamesKyburz JamesKyburz force-pushed the feature/github-action-benchmarks branch from 2f16052 to 330848b Compare October 8, 2019 05:58
@JamesKyburz
Copy link
Contributor Author

@StarpTech I replaced the inline async function with new Promise. I am not sure if this is better, however I feel changing to async/await should be another pull request.

node-version: 10
- name: benchmarks
run: |
npm install
Copy link
Member

Choose a reason for hiding this comment

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

My idea is to move the entire code in a file and just run e.g scripts/bench.js

@JamesKyburz
Copy link
Contributor Author

@StarpTech Splitting the inline script in benchmarks.yml to a seperate file breaks the secrets interpolation stuff (${{ secrets }})

also it won't help with linting as it is a mix of bash and inline node.

@StarpTech
Copy link
Member

@JamesKyburz I got it. That's my suggestion to the benchmark-bench.js https://gist.github.com/StarpTech/958edf3920e13b08671998bf18683114

@JamesKyburz JamesKyburz force-pushed the feature/github-action-benchmarks branch from 16d39be to 815a4a1 Compare October 14, 2019 06:02
@JamesKyburz
Copy link
Contributor Author

@StarpTech async/await is now used.

Copy link
Member

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

@JamesKyburz JamesKyburz force-pushed the feature/github-action-benchmarks branch from 815a4a1 to c28cca8 Compare October 29, 2019 13:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 12

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: 10
Copy link
Member

Choose a reason for hiding this comment

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

I would use the last LTS node

Suggested change
node-version: 10
node-version: 12

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I used 10 because it was the LTS version when the PR was submitted.

@JamesKyburz
Copy link
Contributor Author

updated to use node 12.

run: |
npm install
npm start y 100 10 40
npm start y 100 10 40
Copy link
Member

Choose a reason for hiding this comment

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

Why are there run twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry that was my interpretation of README.md two rounds; one to warm-up, one to measure ;)

I gather that I should only run them once, and this is taken care of by autocannon?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the PR to only run the benchmarks once.

.github/workflows/benchmarks.yml Outdated Show resolved Hide resolved
@JamesKyburz JamesKyburz force-pushed the feature/github-action-benchmarks branch from 79475c0 to 2713d58 Compare November 11, 2019 06:48
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@JamesKyburz
Copy link
Contributor Author

The secrets GITHUB_USERNAME and GITHUB_REPO_TOKEN need to be added before the git hub action will work. They give the action access to create the scheduled commit message.

Can we merge this?

@Eomm
Copy link
Member

Eomm commented Jan 3, 2020

I don't have powa here 😅

Kindly ping to @mcollina

@mcollina
Copy link
Member

mcollina commented Jan 5, 2020

Is GITHUB_TOKEN https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token provided by github action? I would prefer to have this not depending on a token provided by secrets.

I think GITHUB_USERNAME can be hardcoded, as the URL of this repo is fixed.

@JamesKyburz
Copy link
Contributor Author

@mcollina Yes that's the correct documentation link. The token has to be created & then added as a secret. The token value is needed to create the git commit message in the github action.

@jsumners
Copy link
Member

jsumners commented Jan 5, 2020

Is the GitHub Actions default runner environment consistent enough for this task? If we are going to automate benchmark running I would think it'd be desirable that the runner system be consistent between every run.

@JamesKyburz
Copy link
Contributor Author

@jsumners I am sure that it's a better solution than we currently have and should hopefully be consistent enough. The same virtual hardware is used each time.

@mcollina
Copy link
Member

mcollina commented Jan 6, 2020

The doc states (at the very beginning):

GitHub automatically creates a GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in a workflow run.

Why should this created manually?

The reason I’m asking is that setting this up will require create a dummy/bot user with write permission to this repo. If possible, I try to minimize yet another account to manage.

@JamesKyburz
Copy link
Contributor Author

JamesKyburz commented Jan 6, 2020

@mcollina I forgot that when I first tested this I read the documentation where it mentioned the github token had read only access in a forked repository (where I was testing from :))

Good news!

The default token works, I have just verified the change so we need no extra secrets, so ready for merge :)

@mcollina
Copy link
Member

mcollina commented Jan 6, 2020

@delvedor @jsumners any objections?

@jsumners
Copy link
Member

jsumners commented Jan 6, 2020

None.

@JamesKyburz
Copy link
Contributor Author

FYI I noticed that PR #108 has made similar changes to benchmark-bench.js to also allow it it work non interactively.

@mcollina mcollina merged commit 8a3b704 into fastify:master Jan 20, 2020
@mcollina
Copy link
Member

Landed, let's see how it goes.

@JamesKyburz
Copy link
Contributor Author

@mcollina nice!

@JamesKyburz
Copy link
Contributor Author

@mcollina The github action ran this morning and updated the readme :)

@mcollina
Copy link
Member

mcollina commented Feb 1, 2020 via email

@@ -56,4 +56,3 @@ yarn.lock
package-lock.json

# benchmark results
results
Copy link
Member

Choose a reason for hiding this comment

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

I notice this right now: why we removed from gitignore? I don't find an answer

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.

5 participants