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

perf(fs/windows): stat - only open file once #27487

Merged

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Dec 29, 2024

Even debug is way faster:

> cat main.cts
for (let i = 0; i < 100_000; i++) {
  Deno.statSync("b.txt");
}
> Measure-Command { deno run -A main.cts } | Select-Object -Property TotalMilliseconds    
          2684.68
> Measure-Command { ../deno/target/debug/deno run -A main.cts } | Select-Object -Property TotalMilliseconds
           988.55

@@ -61,7 +61,7 @@ impl FileSystem for RealFs {
umask(Mode::from_bits_truncate(mask as mode_t))
} else {
// If no mask provided, we query the current. Requires two syscalls.
let prev = umask(Mode::from_bits_truncate(0o777));
let prev = umask(Mode::from_bits_truncate(0));
Copy link
Member Author

Choose a reason for hiding this comment

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

@dsherret dsherret changed the title fix(windows): stat - close file handle on error fix(windows): stat - close file handle on error and only open file once Dec 29, 2024

let result = get_dev(file_handle);
fsstat.dev = result?;
fsstat.dev = get_dev(file_handle)?;
Copy link
Member Author

Choose a reason for hiding this comment

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

We also previously weren't closing the file_handle on error here.

@dsherret dsherret changed the title fix(windows): stat - close file handle on error and only open file once perf(windows): stat - only open file once Dec 29, 2024
@dsherret dsherret changed the title perf(windows): stat - only open file once perf(fs/windows): stat - only open file once Dec 29, 2024
@dsherret dsherret requested a review from bartlomieju December 29, 2024 17:12
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, good catch

@dsherret dsherret merged commit 88bd5f0 into denoland:main Dec 31, 2024
17 checks passed
@dsherret dsherret deleted the fix_win_stat_close_file_handle_on_error branch December 31, 2024 16:29
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.

2 participants