Browse Source

Revert "Revert "Add some (belated) memory watching""

This reverts commit eafe0fa644.

Conflicts:
	app.js
dev/git-series/gccdum
Matt Godbolt 8 years ago
parent
commit
d6bce41446
  1. 55
      app.js
  2. 2
      lib/compile.js
  3. 1
      package.json

55
app.js

@ -33,7 +33,16 @@ var nopt = require('nopt'),
path = require('path'),
fs = require('fs-extra'),
http = require('http'),
Promise = require('promise');
Promise = require('promise'),
memwatch = require('memwatch');
memwatch.on('leak', function (info) {
console.log("Memwatch leak: " + JSON.stringify(info));
});
memwatch.on('stats', function (stats) {
console.log("Memwatch stats: " + JSON.stringify(stats));
});
var opts = nopt({
'env': [String],
@ -186,29 +195,29 @@ function configuredCompilers() {
var port = parseInt(bits[1]);
console.log("Fetching compilers from remote source " + host + ":" + port);
return retryPromise(function () {
return new Promise(function (resolve, reject) {
http.get({
hostname: host,
port: port,
path: "/api/compilers"
}, function (res) {
var str = '';
res.on('data', function (chunk) {
str += chunk;
});
res.on('end', function () {
var compilers = JSON.parse(str).map(function (compiler) {
compiler.exe = null;
compiler.remote = "http://" + host + ":" + port;
return compiler;
return new Promise(function (resolve, reject) {
http.get({
hostname: host,
port: port,
path: "/api/compilers"
}, function (res) {
var str = '';
res.on('data', function (chunk) {
str += chunk;
});
res.on('end', function () {
var compilers = JSON.parse(str).map(function (compiler) {
compiler.exe = null;
compiler.remote = "http://" + host + ":" + port;
return compiler;
});
resolve(compilers);
});
resolve(compilers);
}).on('error', function (e) {
reject(e);
});
}).on('error', function (e) {
reject(e);
});
});
},
},
host + ":" + port,
props.get('gcc-explorer', 'proxyRetries', 20),
props.get('gcc-explorer', 'proxyRetryMs', 500));
@ -254,7 +263,7 @@ function getCompilerInfo(compilerInfo) {
});
}
if (options['-masm']) {
compilerInfo.intelAsm="-masm=intel";
compilerInfo.intelAsm = "-masm=intel";
}
resolve(compilerInfo);
});
@ -286,7 +295,7 @@ function findCompilers() {
function apiHandler(compilers) {
var reply = JSON.stringify(compilers);
return function apiHandler(req, res, next) {
var bits = req.url.split("/");
var bits = req.url.split("/eafe0fa644b616c7d265623b17ad69042f79b3e5");
if (bits.length !== 2 || req.method !== "GET") return next();
switch (bits[1]) {
default:

2
lib/compile.js

@ -46,7 +46,7 @@ function Compile(compilers) {
this.cache = LRU({
max: props.get('gcc-explorer', 'cacheMb') * 1024 * 1024,
length: function (n) {
return n.length;
return n.asm.length;
}
});
this.cacheHits = 0;

1
package.json

@ -23,6 +23,7 @@
"fs-extra": "0.8.x",
"http-proxy": "1.8.x",
"lru-cache": "2.5.x",
"memwatch": "0.2.x",
"morgan": "1.5.x",
"promise": "6.1.x",
"promise-queue": "2.1.x",

Loading…
Cancel
Save