From 32aa600bf4441c394e060178374ff33e9b40822f Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 02:22:17 -0600 Subject: [PATCH 1/8] More appropriately estimate the cache size --- lib/compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compile.js b/lib/compile.js index 5f10ff247..d51f740b9 100644 --- a/lib/compile.js +++ b/lib/compile.js @@ -68,7 +68,7 @@ function Compile(compilers) { this.cache = LRU({ max: gccProps('cacheMb') * 1024 * 1024, length: function (n) { - return n.asm.length; + return JSON.stringify(n).length; } }); this.cacheHits = 0; From b866d20b38aa34f1989863f48a8d4355b7a15d6b Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 02:22:37 -0600 Subject: [PATCH 2/8] Synchronously determine multiarch --- lib/compile.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/compile.js b/lib/compile.js index d51f740b9..fb9afd0b4 100644 --- a/lib/compile.js +++ b/lib/compile.js @@ -149,8 +149,8 @@ Compile.prototype.runCompiler = function (compiler, options) { }); child.on('exit', function (code) { clearTimeout(timeout); - // TODO: why is this apparently needed in the getMultiarch case? - // without it, I apparently get stdout/stderr callbacks *after* the exit + // Why is this apparently needed in some cases (e.g. when I used to use this to do getMultiarch)? + // Without it, I apparently get stdout/stderr callbacks *after* the exit... setTimeout(function () { resolve({code: code, stdout: stdout, stderr: stderr, okToCache: okToCache}); }, 0); @@ -160,21 +160,19 @@ Compile.prototype.runCompiler = function (compiler, options) { }; Compile.prototype.getMultiarch = function () { - // TODO; force caller to block until this is done... - return this.runCompiler("gcc", ["-print-multiarch"]) - .then(function (obj) { - if (obj.code === 0) { - var multi = obj.stdout.trim(); - console.log("Multiarch: " + obj.stdout.trim()); - process.env.LIBRARY_PATH = '/usr/lib/' + multi; - process.env.C_INCLUDE_PATH = '/usr/include/' + multi; - process.env.CPLUS_INCLUDE_PATH = '/usr/include/' + multi; - } else { - console.log("Unable to get multiarch: " + err); - } - }, function (err) { - console.log("Unable to get multiarch: " + err); - }); + try { + var multi = child_process.execSync("gcc -print-multiarch").toString().trim(); + if (multi) { + console.log("Multiarch: " + multi); + process.env.LIBRARY_PATH = '/usr/lib/' + multi; + process.env.C_INCLUDE_PATH = '/usr/include/' + multi; + process.env.CPLUS_INCLUDE_PATH = '/usr/include/' + multi; + } else { + console.log("No multiarch"); + } + } catch (err) { + console.log("Unable to get multiarch: " + err); + } }; Compile.prototype.objdump = function (outputFilename, result, maxSize, intelAsm) { From fe794092c6cd79ab63c82b5aa485be2109a66a06 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 02:24:41 -0600 Subject: [PATCH 3/8] mg local config changes --- etc/config/c++.lud-ldnmg01.properties | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/etc/config/c++.lud-ldnmg01.properties b/etc/config/c++.lud-ldnmg01.properties index 4b6cc4b98..c8ae79833 100644 --- a/etc/config/c++.lud-ldnmg01.properties +++ b/etc/config/c++.lud-ldnmg01.properties @@ -1,6 +1,6 @@ # Default settings for GCC Explorer. -defaultCompiler=g46 -compilers=g44:g45:g46:clang35:g51 +defaultCompiler=g52 +compilers=g44:g45:g46:clang35:g51:g52 compiler.g44.exe=/usr/bin/g++-4.4 compiler.g44.name=g++ 4.4 compiler.g44.alias=/usr/bin/g++-4.4 @@ -16,4 +16,6 @@ compiler.clang35.intelAsm=-mllvm --x86-asm-syntax=intel compiler.clang35.supportsBinary=false compiler.g51.exe=/home/mgodbolt/.fighome/runtime/gcc/5.1.0-1/bin/g++ compiler.g51.name=g++ 5.1 +compiler.g52.exe=/home/mgodbolt/.fighome/runtime/gcc/5.2.0-1/bin/g++ +compiler.g52.name=g++ 5.2 #compiler-wrapper=./c-preload/compiler-wrapper From 29c87d4f525dc3d683e5f1125555c529a7cc7f17 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 02:41:38 -0600 Subject: [PATCH 4/8] Better cache stats --- lib/compile.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/compile.js b/lib/compile.js index fb9afd0b4..e56051ffb 100644 --- a/lib/compile.js +++ b/lib/compile.js @@ -330,7 +330,9 @@ Compile.prototype.checkSource = function (source) { }; Compile.prototype.cacheStats = function () { - console.log("Cache stats: " + this.cacheHits + " hits, " + this.cacheMisses + " misses"); + var pc = (100 * this.cacheHits) / (this.cacheMisses + this.cacheMisses); + console.log("Cache stats: " + this.cacheHits + " hits, " + this.cacheMisses + " misses (" + pc.toString(2) + + "%), LRU has " + this.cache.itemCount + " item(s) totalling " + this.cache.length + " bytes"); }; function compileHandler(compilers) { From 05668f7f79451610be99498427848df3a5e0861c Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 02:50:34 -0600 Subject: [PATCH 5/8] Improve c++ example --- examples/c++/sum_over_array_opt.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/c++/sum_over_array_opt.cpp b/examples/c++/sum_over_array_opt.cpp index e831ef86f..ab351eb60 100644 --- a/examples/c++/sum_over_array_opt.cpp +++ b/examples/c++/sum_over_array_opt.cpp @@ -1,15 +1,18 @@ // Compile with -O3 -march=native to see autovectorization +// assumes input is aligned on 64-byte boundary and that +// length is a multiple of 64. int testFunction(int* input, int length) { - // Alignment hints supported on GCC 4.7+ and any compiler - // supporting the appropriate builtin (clang 3.6+). + // Alignment hints supported on GCC 4.7+ and any compiler + // supporting the appropriate builtin (clang 3.6+). #ifndef __has_builtin #define __has_builtin(x) 0 #endif #if __GNUC__ > 4 \ - || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \ - || __has_builtin(__builtin_assume_aligned) - input = static_cast(__builtin_assume_aligned(input, 16)); + || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \ + || __has_builtin(__builtin_assume_aligned) + input = static_cast(__builtin_assume_aligned(input, 64)); #endif + if (length & 63) __builtin_unreachable(); int sum = 0; for (int i = 0; i < length; ++i) { sum += input[i]; From cab75f7c7a52ecea0309ff8c2f677eb313360629 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 08:32:43 -0600 Subject: [PATCH 6/8] Kill memwatch --- app.js | 35 ----------------------------------- package.json | 1 - 2 files changed, 36 deletions(-) diff --git a/app.js b/app.js index dfd410548..1c62a88f5 100755 --- a/app.js +++ b/app.js @@ -63,40 +63,6 @@ function compilerProps(property, defaultValue) { require('./lib/compile').initialise(gccProps, compilerProps); var staticMaxAgeMs = gccProps('staticMaxAgeMs', 0); -function initializeMemwatch() { - var memwatch = require('memwatch-next'); - console.log("Initial GC"); - memwatch.gc(); - // Everything else happens a little later to let the initial GC finish. - setTimeout(function () { - var lastDiff = new memwatch.HeapDiff(); - 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 heapDiffEverySecs = gccProps('gcHeapDiffEverySecs', 0); - if (heapDiffEverySecs) { - console.log("Diffing heap every " + heapDiffEverySecs + "s"); - setInterval(function () { - var diff = lastDiff.end(); - lastDiff = new memwatch.HeapDiff(); - console.log("Memwatch diff from last stats: " + JSON.stringify(diff)); - }, 1000 * heapDiffEverySecs); - } - var gcIntervalSecs = gccProps("gcIntervalSecs", 0); - if (gcIntervalSecs) { - console.log("Forcing a GC every " + gcIntervalSecs + "s"); - setInterval(function () { - memwatch.gc(); - }, 1000 * gcIntervalSecs); - } - }, 1 * 1000); -} - function loadSources() { var sourcesDir = "lib/sources"; var sources = fs.readdirSync(sourcesDir) @@ -376,7 +342,6 @@ findCompilers().then(function (compilers) { console.log("======================================="); console.log("Listening on http://" + os.hostname() + ":" + port + "/"); console.log("======================================="); - initializeMemwatch(); webServer.listen(port); }).catch(function (err) { console.log("Error: " + err.stack); diff --git a/package.json b/package.json index 9a8465c6b..db48f1ee4 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "fs-extra": "0.26.x", "http-proxy": "1.12.x", "lru-cache": "2.7.x", - "memwatch-next": "0.2.x", "morgan": "1.6.x", "promise": "7.0.x", "promise-queue": "2.1.x", From 5f0ab8ee45f7bd92af27b0d54b406407d41388a5 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 10:33:27 -0600 Subject: [PATCH 7/8] GCC5.3.0 in amazon --- etc/config/c++.amazon.properties | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties index 310c12c06..c41a3d933 100644 --- a/etc/config/c++.amazon.properties +++ b/etc/config/c++.amazon.properties @@ -1,4 +1,4 @@ -compilers=gcc1204@20480:clang350:clang351:g482:g492:g510:g520:ppcg48:aarchg48:armhfg482:clang37x:clang36x +compilers=gcc1204@20480:clang350:clang351:g482:g492:g510:g520:g530:ppcg48:aarchg48:armhfg482:clang37x:clang36x ############################### # GCC for x86 compiler.g492.exe=/usr/bin/g++-4.9 @@ -7,6 +7,8 @@ compiler.g510.exe=/opt/gcc-5.1.0/bin/g++ compiler.g510.name=x86 gcc 5.1.0 compiler.g520.exe=/opt/gcc-5.2.0/bin/g++ compiler.g520.name=x86 gcc 5.2.0 +compiler.g530.exe=/opt/gcc-5.3.0/bin/g++ +compiler.g530.name=x86 gcc 5.3.0 compiler.g482.exe=/usr/bin/g++-4.8 compiler.g482.name=x86 gcc 4.8.2 compiler.clang350.exe=/usr/bin/clang++-3.5 @@ -38,4 +40,4 @@ compiler.aarchg48.name=ARM64 gcc 4.8 compiler.armhfg482.exe=/usr/bin/arm-linux-gnueabihf-g++ compiler.armhfg482.name=ARM gcc 4.8.2 compiler.armhfg482.supportsBinary=false -compiler.aarchg48.supportsBinary=false \ No newline at end of file +compiler.aarchg48.supportsBinary=false From a0ce94b58f2baf14f88534373f3c61c209637452 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 8 Dec 2015 10:37:26 -0600 Subject: [PATCH 8/8] Fix dumb percentage --- lib/compile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compile.js b/lib/compile.js index e56051ffb..8a35f8f57 100644 --- a/lib/compile.js +++ b/lib/compile.js @@ -330,8 +330,8 @@ Compile.prototype.checkSource = function (source) { }; Compile.prototype.cacheStats = function () { - var pc = (100 * this.cacheHits) / (this.cacheMisses + this.cacheMisses); - console.log("Cache stats: " + this.cacheHits + " hits, " + this.cacheMisses + " misses (" + pc.toString(2) + + var pc = (100 * this.cacheHits) / (this.cacheMisses + this.cacheHits); + console.log("Cache stats: " + this.cacheHits + " hits, " + this.cacheMisses + " misses (" + pc.toFixed(2) + "%), LRU has " + this.cache.itemCount + " item(s) totalling " + this.cache.length + " bytes"); };