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

test(NODE-6756): add tags to benchmarks #751

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

test(NODE-6756): add tags to benchmarks #751

wants to merge 15 commits into from

Conversation

W-A-James
Copy link
Contributor

@W-A-James W-A-James commented Feb 14, 2025

Description

What is changing?

  • Update lockfile to use new bson-bench version
  • Add tags to granular benchmarks via getTypeTestTags and getMixedTestTags helper
  • Add tags to spec benchmarks
  • Add tags to custom benchmarks
  • Add script to run baseline benchmark to package.json
  • Update custom benchmark runner to support cpu baseline benchmark
  • Update readme to reflect changes in custom benchmark runner
Is there new documentation needed for these changes?

What is the motivation for this change?

Release Highlight

Fill in title or leave empty for no highlight

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@W-A-James W-A-James changed the title test(NODE-6756): update bsonBench to add tags test(NODE-6756): add tags to benchmarks Feb 14, 2025
@W-A-James W-A-James marked this pull request as ready for review February 27, 2025 23:29
@W-A-James W-A-James requested a review from a team as a code owner February 27, 2025 23:29
@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Feb 28, 2025
@nbbeeken nbbeeken self-assigned this Feb 28, 2025
@@ -28,9 +32,9 @@ The JSON emitted at the end of the benchmarks must follow our performance tracki
The JSON must be an array of "`Test`"s:

```ts
type Metric = { name: string, value: number }
type Metric = { name: string, value: number, metadata: { improvement_diraction: 'up' | 'down' } }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
type Metric = { name: string, value: number, metadata: { improvement_diraction: 'up' | 'down' } }
type Metric = { name: string, value: number, metadata: { improvement_direction: 'up' | 'down' } }

.run()
.then(() => {
return readFile(join(__dirname, '..', '..', 'etc', 'cpuBaseline.json'), 'utf8');
}, console.error)
Copy link
Contributor

Choose a reason for hiding this comment

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

The console.error's are risky no? don't we want to crash?

return readFile(join(__dirname, '..', '..', 'etc', 'cpuBaseline.json'), 'utf8');
}, console.error)
.then(cpuBaseline => {
if (!cpuBaseline) throw new Error('could not find cpu baseline');
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah related to the other comment, if we just let the error throw then we'll know why it's missing maybe? (probably file not found, but who knows!)

const rv = { ...result };
rv.metrics = rv.metrics.filter(metric => metric.type === 'MEAN');
return rv;
});

const metadata: Metadata = { improvement_direction: 'up' };
// calculte BSONBench composite score
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// calculte BSONBench composite score
// calculate BSONBench composite score

suite
.run()
.then(() => {
return readFile(join(__dirname, '..', '..', 'etc', 'cpuBaseline.json'), 'utf8');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this into the block below, make it an async () => function and await this? then stack traces are a bit nicer, nothing wrong with an async function chained to a promise.

@@ -28,6 +28,9 @@ const DOCUMENT_ROOT = path.resolve(`${__dirname}/../documents`);
.run()
.catch(() => null);

// Check for benchmark results
const cpuBaselineData = require(`${__dirname}${path.sep}cpuBaseline.json`);
Copy link
Contributor

Choose a reason for hiding this comment

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

require is already script relative, so "./cpuBaseline.json" should be all that you need

But also, if you have the path module, might as well use path.join() there may be additional rules to "joining" that that methods handles that are more than putting the .sep in place.

if (++completedSuites >= collectedSuites.length) {
let cpuBaselineResults;
try {
cpuBaselineResults = JSON.parse(fs.readFileSync(`${__dirname}/../etc/cpuBaseline.json`));
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional, should be able to use await import here to get the same convenience require provides in the other benchmark. This works so no worries if you want to stay the course.

@nbbeeken
Copy link
Contributor

The granular benchmarks timed out after 15min, it says the base commit takes 5min which I find a bit surprising, did we accidentally change iterations here? and should we do it intentionally later for a larger sample size? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants