- Notifications
You must be signed in to change notification settings - Fork96
feat: only save files if they are unchanged#417
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Hey, code looks good; my only concern is performance. Has any testing been done on this? |
kentcdodds commentedNov 30, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just did some testing here: constfs=require("fs-extra");asyncfunctiononeFile(){console.time("one file");awaitfs.readFile("./files/01.css");console.timeEnd("one file");}asyncfunctionhundredFiles(){console.time("100 files");for(leti=0;i<100;i++){awaitfs.readFile(`./files/01 copy${i}.css`);}console.timeEnd("100 files");}oneFile();hundredFiles(); Those css files areeach 111kb of this copy/pasted over and over: body {color: red;} My output (on my fast machine) is:
It's pretty darn fast. Feel free to watch for yourself (I'm live streaming right now):https://www.youtube.com/watch?v=KPKBUBchCVo So I think this is fine. Though if you'd like to add an opt-out option then I could do that. But I kinda think that should be some added complexity that we should add only if necessary since this doesn't seem to be much of a problem. |
Ping? 😅 |
Hey, sorry for the slowness here; didn't want to merge until I had spare time to publish a new version. |
No worries. I know life is busy 😅 Thanks for merging and releasing this! |
chillitom commentedDec 11, 2021
could comparing files sizes first and only reading/comparing if different give a small perf improvement? |
I expect it could, but it's it really worth the added complexity? For most cases it doesn't even take a full millisecond to just read and compare. It probably wouldn't make much of a difference... |
Closes#320
This also solves a significant annoyance for anyone using postcss with an app that rebuilds on file change:remix-run/remix#714