From 2da803b9db41a1f2d69994444056a57c2b40ec48 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Tue, 17 Nov 2015 11:40:34 +0000 Subject: [PATCH 1/6] Serve unpacked content over 3 ports --- plugins/c9.static/unpacked_helper.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/plugins/c9.static/unpacked_helper.js b/plugins/c9.static/unpacked_helper.js index 15a3fe9a..ff09c60f 100644 --- a/plugins/c9.static/unpacked_helper.js +++ b/plugins/c9.static/unpacked_helper.js @@ -1,3 +1,9 @@ +/** + * unpacked_helper speeds up the unpacked version of Cloud9 + * by using more parallel connections and avoiding + * subsubdomains on dogfooding (e.g., ide.dev-lennartcl.c9.io, where + * Chrome doesn't support any caching). + */ "use strict"; plugin.consumes = [ @@ -18,20 +24,10 @@ function plugin(options, imports, register) { assert(ideBaseUrl, "ideBaseUrl must be set"); var balancers = [ - baseUrl + "/uph", + baseUrl + "/_unp", + baseUrl + ":8081/_unp", + baseUrl + ":8082/_unp", ]; - /* UNDONE: for now we put all static content on one domain - because of reports of CORS errors - if (!options.avoidSubdomains) - balancers.push( - ideBaseUrl - // We could include others but dogfooding URLs like - // vfs.newclient-lennartcl.c9.io don't have a cert, so - // let's not - // apiBaseUrl + "/uph", - // vfsBaseUrl + "/uph" - ); - */ connectStatic.getRequireJsConfig().baseUrlLoadBalancers = balancers; assert(connectStatic.getRequireJsConfig().baseUrlLoadBalancers); From 3042e61641de8f1625a5d49f20bf346062b5dd79 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Tue, 17 Nov 2015 11:58:26 +0000 Subject: [PATCH 2/6] Speed up ide loading, deferring profile loading for now --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index f5537a91..5616c5ac 100755 --- a/server.js +++ b/server.js @@ -29,7 +29,12 @@ var shortcuts = { "s": ["standalone", "-s", "standalone"] }; shortcuts.odev = shortcuts.onlinedev; // For backwards compatibility, if you see this in 2016 remove this line -var delayLoadConfigs = ["preview", "user-content", "api", "oldclient", "apps-proxy", "worker"]; +var delayLoadConfigs = [ + // Services that are usually not immediately needed + "preview", "user-content", "api", "apps-proxy", "worker", + // Services that are very slow to load, blocking others + "profile", +]; module.exports = main; From 4fdaccd3c81f53f5c2588c5f174d33ce5b90d6a6 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Tue, 17 Nov 2015 12:00:39 +0000 Subject: [PATCH 3/6] Fix worker CORS errors with unpacked helper --- configs/client-default.js | 4 +--- node_modules/ace/lib/ace/worker/worker_client.js | 4 ++-- .../architect-build/build_support/mini_require.js | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/configs/client-default.js b/configs/client-default.js index 943872fc..dfb24ecd 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -303,9 +303,7 @@ module.exports = function(options) { { packagePath: "plugins/c9.ide.language/language", workspaceDir: workspaceDir, - staticPrefix: hosted && !options.packed - ? options.ideBaseUrl + "/uph" + staticPrefix - : staticPrefix, + staticPrefix: staticPrefix, workerPrefix: options.CORSWorkerPrefix // "/static/standalone/worker" }, "plugins/c9.ide.language/keyhandler", diff --git a/node_modules/ace/lib/ace/worker/worker_client.js b/node_modules/ace/lib/ace/worker/worker_client.js index ba4f20a0..baf3dc9d 100644 --- a/node_modules/ace/lib/ace/worker/worker_client.js +++ b/node_modules/ace/lib/ace/worker/worker_client.js @@ -49,11 +49,11 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) { workerUrl = workerUrl || config.moduleUrl(mod, "worker"); } else { var normalizePath = this.$normalizePath; - workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_")); + workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_", true)); var tlns = {}; topLevelNamespaces.forEach(function(ns) { - tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, "")); + tlns[ns] = normalizePath(require.toUrl(ns, null, "_", true).replace(/(\.js)?(\?.*)?$/, "")); }); } diff --git a/node_modules/architect-build/build_support/mini_require.js b/node_modules/architect-build/build_support/mini_require.js index 45407316..e6a45e90 100644 --- a/node_modules/architect-build/build_support/mini_require.js +++ b/node_modules/architect-build/build_support/mini_require.js @@ -152,8 +152,8 @@ var activateModule = function(name) { var req = function(path, callback) { return _require(name, path, callback); }; - req.toUrl = function(namePlusExt) { - return require.toUrl(normalizeName(name, namePlusExt)); + req.toUrl = function(namePlusExt, _1, _2, skipBalancers) { + return require.toUrl(normalizeName(name, namePlusExt), null, null, skipBalancers); }; req.config = require.config; @@ -315,7 +315,7 @@ function undefAll(module, hash) { require.MODULE_LOAD_URL = MODULE_LOAD_URL; -require.toUrl = function(moduleName, ext, skipExt) { +require.toUrl = function(moduleName, ext, skipExt, skipBalancers) { var absRe = /^([\w\+\.\-]+:|\/)/; var index = moduleName.indexOf("!"); if (index !== -1 || !ext || /^\/|\.js$/.test(moduleName)) @@ -347,7 +347,7 @@ require.toUrl = function(moduleName, ext, skipExt) { if (!absRe.test(url)) { url = (config.baseUrl || require.MODULE_LOAD_URL + "/") + url; } - if (url[0] === "/" && config.baseUrlLoadBalancers) { + if (url[0] === "/" && config.baseUrlLoadBalancers && !skipBalancers) { var n = Math.abs(hashCode(url)) % config.baseUrlLoadBalancers.length; url = config.baseUrlLoadBalancers[n] + url; } From 6b858b7b95effd9b3ddf3f046e39ca9db0e3f0ae Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Tue, 17 Nov 2015 12:52:35 +0000 Subject: [PATCH 4/6] Remove obsolete onlinedev_helper.js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 145d0b5a..57e7b8c1 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,6 @@ "c9.ide.threewaymerge": "#229382aa0b", "c9.ide.undo": "#b028bcb4d5", "c9.ide.upload": "#0bd010d3dc", - "c9.ide.welcome": "#08bca785f5" + "c9.ide.welcome": "#7a09ccd7b2" } } \ No newline at end of file From 4d53f45d8fbd9fd08da04aa3a8583936f05bcd18 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 18 Nov 2015 08:29:11 +0000 Subject: [PATCH 5/6] More ports! --- plugins/c9.static/unpacked_helper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/c9.static/unpacked_helper.js b/plugins/c9.static/unpacked_helper.js index ff09c60f..c5bb48ef 100644 --- a/plugins/c9.static/unpacked_helper.js +++ b/plugins/c9.static/unpacked_helper.js @@ -25,6 +25,7 @@ function plugin(options, imports, register) { var balancers = [ baseUrl + "/_unp", + baseUrl + ":8080/_unp", baseUrl + ":8081/_unp", baseUrl + ":8082/_unp", ]; From e0f8ab24d5eb5f0b0e15ebb7874359b2b3f4b3b2 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 18 Nov 2015 11:38:09 +0100 Subject: [PATCH 6/6] Add comment --- node_modules/ace/lib/ace/worker/worker_client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/node_modules/ace/lib/ace/worker/worker_client.js b/node_modules/ace/lib/ace/worker/worker_client.js index baf3dc9d..b69071fb 100644 --- a/node_modules/ace/lib/ace/worker/worker_client.js +++ b/node_modules/ace/lib/ace/worker/worker_client.js @@ -48,12 +48,13 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) { if (config.get("packaged") || !require.toUrl) { workerUrl = workerUrl || config.moduleUrl(mod, "worker"); } else { + var skipBalancers = true; // load all scripts from one domain, workers don't support CORS headers var normalizePath = this.$normalizePath; - workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_", true)); + workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_", skipBalancers)); var tlns = {}; topLevelNamespaces.forEach(function(ns) { - tlns[ns] = normalizePath(require.toUrl(ns, null, "_", true).replace(/(\.js)?(\?.*)?$/, "")); + tlns[ns] = normalizePath(require.toUrl(ns, null, "_", skipBalancers).replace(/(\.js)?(\?.*)?$/, "")); }); }