denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
96.97k stars 5.35k forks source link

reduce readFileSync syscall count #23887

Open littledivy opened 5 months ago

littledivy commented 5 months ago

https://x.com/justjs14/status/1791963104881844360

image

Repro: https://gist.github.com/billywhizz/1d6fee4d3aea1030324a7a93de444d31

sigmaSd commented 5 months ago

Its probably due to permissions check, I think in the case of read when comparing paths deno need to canonicalize and normalize the paths, to know its allowed or not

Maybe absolute flags (as in --allow-read instead of --allow-read=path, etc) should not suffer the sandbox performance hit, since they can work in theory with just an extra boolean check and more importantly with no extra syscalls

littledivy commented 5 months ago

It's a regression from #23208

This getcwd code path should never reach with --allow-all and generic --allow-read https://github.com/denoland/deno/blob/fabd9a214b278bb119818187de66121c5f91b751/ext/fs/std_fs.rs#L904-L905