GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: fix race condition on fs benchs by H4ad · Pull Request #50035 · nodejs/node

Conversation

@H4ad

@H4ad H4ad commented Oct 4, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Some of these benchmarks fails even on main versions of Node.js.

This issue is caused because afterRead is being called and is locking the temp file which makes the .on('exit') fails to clean the temp file.

If we wait all the concurrent timers to finish, the issue is solved.

First found this issue on: #49962

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with eyes emoji
All reactions
  • 👀 1 reaction
@nodejs-github-bot nodejs-github-bot added benchmark Issues and PRs related to Node.js benchmarks and benchmarking infrastructure. fs Issues and PRs related to file-system APIs and the fs module. labels Oct 4, 2023
@H4ad
H4ad force-pushed the fix/fs-benchmarks branch from c44de49 to bc9e25f Compare October 4, 2023 11:57
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 4, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54523/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 4, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54528/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@H4ad
benchmark: fix race condition on fs benchs
bc9e25f
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 4, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54539/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig
anonrig requested a review from joyeecheung October 4, 2023 19:23
@anonrig

anonrig commented Oct 4, 2023

Copy link
Copy Markdown
Member

@nodejs/fs @nodejs/performance @nodejs/platform-windows can you review?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anonrig
anonrig approved these changes Oct 4, 2023
View reviewed changes
@anonrig anonrig added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Oct 4, 2023
@github-actions github-actions Bot mentioned this pull request Oct 5, 2023
CI Reliability 2023-10-05 nodejs/reliability#684
Open
13 tasks
benjamingr
benjamingr requested changes Oct 5, 2023
View reviewed changes

@benjamingr benjamingr left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm -1 on an approach that uses setTimeout here, if we end up using setTimeout we should use platform dependent timeout probably.

In general code that does cleanup and may crash shouldn't clean up after itself but when starting which the code here already does - so I wonder if it isn't better to just remove the cleanup and rely on the test.

The benchmarks should likely use async/await instead of the callbackify-liike weirdness they do at the moment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@H4ad

H4ad commented Oct 5, 2023

Copy link
Copy Markdown
Member Author

What do you mean by platform dependent timeout?

async/away has some overhead and the idea of this benchmark is to test the performance of the callback version, so there is no reason to change this behavior.

Another approach for setTimeout could be setImediate, but I didn't test if could handle the race condition.

These changes are meant to fix the error that happens in these lines:

node/test/common/tmpdir.js

Lines 48 to 71 in 19b470f

function onexit(useSpawn) {
// Change directory to avoid possible EBUSY
if (isMainThread)
process.chdir(testRoot);
try {
rmSync(tmpPath, useSpawn);
} catch (e) {
console.error('Can\'t clean tmpdir:', tmpPath);
const files = fs.readdirSync(tmpPath);
console.error('Files blocking:', files);
if (files.some((f) => f.startsWith('.nfs'))) {
// Warn about NFS "silly rename"
console.error('Note: ".nfs*" might be files that were open and ' +
'unlinked but not closed.');
console.error('See http://nfs.sourceforge.net/#faq_d2 for details.');
}
console.error();
throw e;
}
}

Due to race condition, the file cannot be deleted because the readline still locking the file.

Maybe we could remove the tmpdir dependency and create and delete manually the temp folders, but I think we will have the same issue and the solution will be the same (setTimeout).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@benjamingr

benjamingr commented Oct 5, 2023

Copy link
Copy Markdown
Member

What do you mean by platform dependent timeout?

https://github.com/nodejs/node/tree/main/test/common#platformtimeoutms

async/away has some overhead and the idea of this benchmark is to test the performance of the callback version, so there is no reason to change this behavior.

I guarantee you it has less or as much overhead as the "create a promise then go through extra closure and function" version we currently use.

Another approach for setTimeout could be setImediate, but I didn't test if could handle the race condition.

We should never rely on timers for dealing with race conditions typically. The problem here is design, we should delete the file when the test starts and not when it ends..

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak

Uzlopak commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

@RafaelGSS

Cant we have a after helper, like mocha/chai/tap has, in the benchmark framework and run it after the benchmark finished?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Oct 6, 2023
CI Reliability 2023-10-06 nodejs/reliability#685
Open
10 tasks
@benjamingr

benjamingr commented Oct 6, 2023

Copy link
Copy Markdown
Member

What if the user stops the benchmark in the middle (or similarly in CI?)?

What's the issue with only doing the cleanup before the test and not after?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@H4ad

H4ad commented Oct 6, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@benjamingr Doing it this way, it will clean up only during the start of the benchmark, and then the file will be there without being cleaned.

It may or may not be a problem, but if we went this way we would need to remove the reference to tempdir.refresh because they automatically install the process.on('exit') cleanup hook.

About stopping the CI in the middle, the file is cleaned because of process.on('exit') but this can lead to the same error, in this context, the error doesn't matter since we are canceling the execution.

But I will try to use platform-specific timeout and see how it behaves with async/await.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@benjamingr

benjamingr commented Oct 6, 2023

Copy link
Copy Markdown
Member

Doing it this way, it will clean up only during the start of the benchmark, and then the file will be there without being cleaned.

It may or may not be a problem

It's not (at least shouldn't be) it's a tmp dir, it's transient storage by design. It's "fine" to leave trash there.

But I will try to use platform-specific timeout and see how it behaves with async/await.

Sure but I would strongly prefer it that we don't use a timers based solution since that inherently depends on how slow the machine running the benchmark/test is which means harder-to-track-and-fix flakes.

RafaelGSS reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 7, 2023
CI Reliability 2023-10-07 nodejs/reliability#686
Open
CI Reliability 2023-10-08 nodejs/reliability#687
Open
@H4ad
H4ad requested a review from benjamingr October 8, 2023 16:35
@H4ad
fixup! benchmark: fix race condition on fs benchs
d900ac9
@H4ad
fixup! benchmark: fix race condition on fs benchs
07d29e0
@H4ad

H4ad commented Oct 10, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@benjamingr Just to summarize the changes, now I wait for all the concurrent timers to finish until really stop the benchmark, in this approach I don't relly on platform dependant timeouts.

benjamingr reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig anonrig added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Oct 10, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 10, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 10, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54659/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 10, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54685/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Oct 11, 2023
CI Reliability 2023-10-11 nodejs/reliability#690
Open
30 tasks
@nodejs-github-bot

nodejs-github-bot commented Oct 11, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54691/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Oct 11, 2023
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina

mcollina commented Oct 11, 2023

Copy link
Copy Markdown
Member

@benjamingr I see you asked for some changes here, are you still blocking this to land?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 12, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54730/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 14, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54785/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

This comment has been minimized.

Sign in to view
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 14, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 14, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 14, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54789/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 14, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/54792/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr approved these changes Oct 15, 2023
View reviewed changes
anonrig
anonrig approved these changes Oct 15, 2023
View reviewed changes
@anonrig anonrig added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 15, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 15, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 33c87ec into nodejs:main Oct 15, 2023
@nodejs-github-bot

nodejs-github-bot commented Oct 15, 2023

Copy link
Copy Markdown
Collaborator

Landed in 33c87ec

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RafaelGSS RafaelGSS mentioned this pull request Oct 15, 2023
2023-10-17, Version 21.0.0 (Current) #49870
Merged
targos pushed a commit that referenced this pull request Nov 11, 2023
@H4ad @targos
benchmark: fix race condition on fs benchs
73757a5
PR-URL: #50035
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@targos targos mentioned this pull request Nov 12, 2023
v20.10.0 release proposal #50682
Merged
@juanarbol juanarbol mentioned this pull request Dec 6, 2023
2023-12-06, N|Solid v5.0.1 Iron Release nodesource/nsolid#41
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@benjamingr benjamingr benjamingr approved these changes
@anonrig anonrig anonrig approved these changes
@joyeecheung joyeecheung Awaiting requested review from joyeecheung

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

benchmark Issues and PRs related to Node.js benchmarks and benchmarking infrastructure. fs Issues and PRs related to file-system APIs and the fs module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@H4ad @nodejs-github-bot @anonrig @benjamingr @Uzlopak @mcollina
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.