-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Stop using process.umask() #252
Comments
|
Note: even though it's potentially slower, creating the file and then checking the mode is a more technically correct approach, as it is resilient against |
FWIW, I did some quick, completely unscientific benchmarks on Linux and changing create-close to create-fchmod-close slows it down by just under 15%: // As root, run `echo 3 > /proc/sys/vm/drop_caches` first
'use strict';
const { O_CREAT, O_WRONLY } = require('fs').constants;
const { openSync, closeSync, unlinkSync } = require('fs');
let { fchmodSync } = require('fs');
if (process.argv[2]) fchmodSync = () => {};
const N = 1e4;
const files = [];
for (let i = 0; i < N; i++) files.push('/tmp/xyzzy' + i);
const start = Date.now();
for (const file of files) {
const fd = openSync(file, O_CREAT|O_WRONLY);
fchmodSync(fd, 0o666);
closeSync(fd);
}
const end = Date.now();
console.log(start, end, end - start);
for (const file of files) unlinkSync(file); 15% sounds like a lot, however:
I assume cold caches are the common case for node-tar because you don't normally unpack the same tarball to the same location 10 times in a row. (Well, I don't, anyway.) |
If you really need to use process.umask() (without args), then you may use get-umask module. It suppresses those annoying warnings. And yeah, it's written by me. |
Suppress warnings by using |
nodejs/node#32321 (comment)
cc @bnoordhuis
The text was updated successfully, but these errors were encountered: