mozilla / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
176 stars 278 forks source link

Remove unnecessary calls to the filesystem during initial load of brackets #338

Closed sedge closed 9 years ago

sedge commented 9 years ago

We've discovered that brackets tries reading from the filesystem to get internal resources during its initial load. The one example we know of for sure is during the loading of extensions when it attempts to read the package.json file of each extension.

Since our filesystem will soon live across an iframe and persist into indexeddb its important to remove any calls we know will fail to speed up the load time. There might be other places that brackets tries to read from disk vs. requiring from the server and those need to be found and addressed as well.

humphd commented 9 years ago

For a demo today, I made a thing that logs all the fs calls we do. Here's what happens right now when we start Bramble (oldest at the bottom, newer at the top):

fs.exists:       /ApplicationSupport/keymap.json
fs.stat:       /
fs.stat:       /.jscodehints
fs.readFile:       /index.html
fs.readFile:       /.brackets.json
fs.stat:       /.brackets.json
fs.readFile:       /.brackets.json
fs.stat:       /.brackets.json
fs.stat:       /script.js
fs.stat:       /script.js
fs.stat:       /script.js
fs.stat:       /style.css
fs.stat:       /index.html
fs.writeFile:       /script.js
fs.readdir:       /
fs.writeFile:       /ApplicationSupport/brackets.json
fs.stat:       /script.js
fs.exists:       /
fs.watch:       /
fs.readFile:       /.brackets.json
fs.stat:       /.brackets.json
fs.stat:       /ApplicationSupport/brackets.json
fs.stat:       /style.css
fs.stat:       /index.html
fs.writeFile:       /style.css
fs.writeFile:       /index.html
fs.stat:       /style.css
fs.stat:       /index.html
fs.readFile:       /src/extensions/default/brackets-paste-and-indent/requirejs-config.json
fs.stat:       /src/extensions/default/brackets-paste-and-indent/requirejs-config.json
fs.readFile:       /src/extensions/default/bramble/requirejs-config.json
fs.stat:       /src/extensions/default/bramble/requirejs-config.json
fs.readFile:       /src/extensions/default/UrlCodeHints/requirejs-config.json
fs.stat:       /src/extensions/default/UrlCodeHints/requirejs-config.json
fs.readFile:       /src/extensions/default/QuickView/requirejs-config.json
fs.stat:       /src/extensions/default/QuickView/requirejs-config.json
fs.readFile:       /src/extensions/default/QuickOpenJavaScript/requirejs-config.json
fs.stat:       /src/extensions/default/QuickOpenJavaScript/requirejs-config.json
fs.readFile:       /src/extensions/default/QuickOpenHTML/requirejs-config.json
fs.stat:       /src/extensions/default/QuickOpenHTML/requirejs-config.json
fs.readFile:       /src/extensions/default/QuickOpenCSS/requirejs-config.json
fs.stat:       /src/extensions/default/QuickOpenCSS/requirejs-config.json
fs.readFile:       /src/extensions/default/JavaScriptQuickEdit/requirejs-config.json
fs.stat:       /src/extensions/default/JavaScriptQuickEdit/requirejs-config.json
fs.readFile:       /src/extensions/default/InlineColorEditor/requirejs-config.json
fs.stat:       /src/extensions/default/InlineColorEditor/requirejs-config.json
fs.readFile:       /src/extensions/default/JavaScriptCodeHints/requirejs-config.json
fs.stat:       /src/extensions/default/JavaScriptCodeHints/requirejs-config.json
fs.readFile:       /src/extensions/default/HTMLCodeHints/requirejs-config.json
fs.stat:       /src/extensions/default/HTMLCodeHints/requirejs-config.json
fs.readFile:       /src/extensions/default/CSSCodeHints/requirejs-config.json
fs.stat:       /src/extensions/default/CSSCodeHints/requirejs-config.json
fs.writeFile:       /ApplicationSupport/state.json
fs.readFile:       /src/extensions/default/brackets-paste-and-indent/package.json
fs.stat:       /src/extensions/default/brackets-paste-and-indent/package.json
fs.readFile:       /src/extensions/default/bramble/package.json
fs.stat:       /src/extensions/default/bramble/package.json
fs.readFile:       /src/extensions/default/UrlCodeHints/package.json
fs.stat:       /src/extensions/default/UrlCodeHints/package.json
fs.readFile:       /src/extensions/default/QuickView/package.json
fs.stat:       /src/extensions/default/QuickView/package.json
fs.readFile:       /src/extensions/default/QuickOpenJavaScript/package.json
fs.stat:       /src/extensions/default/QuickOpenJavaScript/package.json
fs.readFile:       /src/extensions/default/QuickOpenHTML/package.json
fs.stat:       /src/extensions/default/QuickOpenHTML/package.json
fs.readFile:       /src/extensions/default/QuickOpenCSS/package.json
fs.stat:       /src/extensions/default/QuickOpenCSS/package.json
fs.readFile:       /src/extensions/default/JavaScriptQuickEdit/package.json
fs.stat:       /src/extensions/default/JavaScriptQuickEdit/package.json
fs.readFile:       /src/extensions/default/InlineColorEditor/package.json
fs.stat:       /src/extensions/default/InlineColorEditor/package.json
fs.readFile:       /src/extensions/default/JavaScriptCodeHints/package.json
fs.stat:       /src/extensions/default/JavaScriptCodeHints/package.json
fs.readFile:       /src/extensions/default/HTMLCodeHints/package.json
fs.stat:       /src/extensions/default/HTMLCodeHints/package.json
fs.readFile:       /src/extensions/default/CSSCodeHints/package.json
fs.stat:       /src/extensions/default/CSSCodeHints/package.json
fs.stat:       /ApplicationSupport/state.json
fs.readFile:       /ApplicationSupport/state.json
fs.stat:       /ApplicationSupport/state.json
fs.readFile:       /ApplicationSupport/brackets.json
fs.stat:       /ApplicationSupport/brackets.json

Removing all those readFile calls for extension package.json files is an obvious starting point.