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 optimizations - part 1 #15873

Merged
merged 24 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
some more stuff
  • Loading branch information
littledivy committed Sep 12, 2022
commit 3b293434234425235e64f676fac3071094e03f04
84 changes: 33 additions & 51 deletions runtime/js/30_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,34 @@
path,
options = {},
) {
ops.op_remove_sync({
path: pathFromURL(path),
recursive: !!options.recursive,
});
ops.op_remove_sync(
pathFromURL(path),
!!options.recursive,
);
}

async function remove(
path,
options = {},
) {
await core.opAsync("op_remove_async", {
path: pathFromURL(path),
recursive: !!options.recursive,
});
await core.opAsync("op_remove_async",
pathFromURL(path),
!!options.recursive,
);
}

function renameSync(oldpath, newpath) {
ops.op_rename_sync({
oldpath: pathFromURL(oldpath),
newpath: pathFromURL(newpath),
});
ops.op_rename_sync(
pathFromURL(oldpath),
pathFromURL(newpath),
);
}

async function rename(oldpath, newpath) {
await core.opAsync("op_rename_async", {
oldpath: pathFromURL(oldpath),
newpath: pathFromURL(newpath),
});
await core.opAsync("op_rename_async",
pathFromURL(oldpath),
pathFromURL(newpath),
);
}

const infoBuf = new Uint32Array(24);
Expand Down Expand Up @@ -298,9 +298,7 @@
}

function ftruncateSync(rid, len) {
if (!ops.op_ftruncate_sync.fast(rid, coerceLen(len))) {

}
ops.op_ftruncate_sync(rid, coerceLen(len));
}

async function ftruncate(rid, len) {
Expand All @@ -320,11 +318,11 @@
}

function linkSync(oldpath, newpath) {
ops.op_link_sync({ oldpath, newpath });
ops.op_link_sync(oldpath, newpath);
}

async function link(oldpath, newpath) {
await core.opAsync("op_link_async", { oldpath, newpath });
await core.opAsync("op_link_async", oldpath, newpath);
}

function toUnixTimeFromEpoch(value) {
Expand Down Expand Up @@ -353,71 +351,55 @@
atime,
mtime,
) {
ops.op_futime_sync({
rid,
atime: toUnixTimeFromEpoch(atime),
mtime: toUnixTimeFromEpoch(mtime),
});
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
ops.op_futime_sync(rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec);
}

async function futime(
rid,
atime,
mtime,
) {
await core.opAsync("op_futime_async", {
rid,
atime: toUnixTimeFromEpoch(atime),
mtime: toUnixTimeFromEpoch(mtime),
});
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
await core.opAsync("op_futime_async", rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec);
}

function utimeSync(
path,
atime,
mtime,
) {
ops.op_utime_sync({
path: pathFromURL(path),
atime: toUnixTimeFromEpoch(atime),
mtime: toUnixTimeFromEpoch(mtime),
});
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
ops.op_utime_sync(pathFromURL(path), atimeSec, atimeNsec, mtimeSec, mtimeNsec);
}

async function utime(
path,
atime,
mtime,
) {
await core.opAsync("op_utime_async", {
path: pathFromURL(path),
atime: toUnixTimeFromEpoch(atime),
mtime: toUnixTimeFromEpoch(mtime),
});
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
await core.opAsync("op_utime_async", pathFromURL(path), atimeSec, atimeNsec, mtimeSec, mtimeNsec);
}

function symlinkSync(
oldpath,
newpath,
options,
) {
ops.op_symlink_sync({
oldpath: pathFromURL(oldpath),
newpath: pathFromURL(newpath),
options,
});
ops.op_symlink_sync(pathFromURL(oldpath), pathFromURL(newpath), options?.type);
}

async function symlink(
oldpath,
newpath,
options,
) {
await core.opAsync("op_symlink_async", {
oldpath: pathFromURL(oldpath),
newpath: pathFromURL(newpath),
options,
});
await core.opAsync("op_symlink_async", pathFromURL(oldpath), pathFromURL(newpath), options?.type);
}

function fdatasyncSync(rid) {
Expand Down
Loading