Skip to content

Commit

Permalink
[GR-54113] Improve diagnostics and robustness around unknown requests…
Browse files Browse the repository at this point in the history
… to CompilerDaemon.

PullRequest: mx/1798
  • Loading branch information
dougxc committed May 21, 2024
2 parents 9bf0341 + f13e394 commit f2d92b8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 3 additions & 1 deletion ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ local common_json = import "../common.json";
} + {
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: parse_labsjdk_version(self), jdk_name:: "jdk-latest"}
for name in ["oraclejdk-latest"] + variants("labsjdk-ce-latest") + variants("labsjdk-ee-latest")
} + {
'graalvm-ee-21': jdk_base + common_json.jdks["graalvm-ee-21"] + { jdk_version:: 21 },
},
# We do not want to expose galahad-jdk
assert std.assertEqual([x for x in std.objectFields(common_json.jdks) if x != "galahad-jdk"], std.objectFields(jdks_data)),
Expand Down Expand Up @@ -329,7 +331,7 @@ local common_json = import "../common.json";
},
opt_post_merge: {
targets+: ["opt-post-merge"],
tags+: []
tags+: {opt_post_merge +: []},
},
daily: {
targets+: ["daily"],
Expand Down
17 changes: 9 additions & 8 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
],

"mx_version": "7.22.7",
"mx_version": "7.25.0",

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
Expand Down Expand Up @@ -43,14 +43,15 @@
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
"graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+21", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+21-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+21-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+21-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+21-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+21-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+21-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+22", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+22-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+22-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+22-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+22-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+22-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+22-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.time.Instant;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
Expand All @@ -45,7 +46,7 @@ public abstract class CompilerDaemon {
/**
* The deamon will shut down after receiving this many requests with an unrecognized header.
*/
static final int MAX_UNRECOGNIZED_REQUESTS = 5;
static final int MAX_UNRECOGNIZED_REQUESTS = 1000;

protected void logf(String format, Object... args) {
if (verbose) {
Expand Down Expand Up @@ -127,15 +128,18 @@ public Connection(Socket connectionSocket, Compiler compiler) {
this.compiler = compiler;
}

@Override
public void run() {
try {
BufferedReader input = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream(), "UTF-8"));
OutputStreamWriter output = new OutputStreamWriter(connectionSocket.getOutputStream(), "UTF-8");

try {
String request = input.readLine();
String requestOrigin = connectionSocket.getInetAddress().getHostAddress();
String prefix = String.format("[%s:%s] ", Instant.now(), requestOrigin);
if (request == null || request.equals(REQUEST_HEADER_SHUTDOWN)) {
logf("Shutting down%n");
logf("%sShutting down%n", prefix);
running = false;
while (threadPool.getActiveCount() > 1) {
threadPool.awaitTermination(50, TimeUnit.MILLISECONDS);
Expand All @@ -146,21 +150,21 @@ public void run() {
} else if (request.startsWith(REQUEST_HEADER_COMPILE)) {
String commandLine = request.substring(REQUEST_HEADER_COMPILE.length());
String[] args = commandLine.split("\u0000");
logf("Compiling %s%n", String.join(" ", args));
logf("%sCompiling %s%n", prefix, String.join(" ", args));

int result = compiler.compile(args);
if (result != 0 && args.length != 0 && args[0].startsWith("GET / HTTP")) {
// GR-52712
System.err.printf("Failing compilation received on %s%n", connectionSocket);
System.err.printf("%sFailing compilation received on %s%n", prefix, connectionSocket);
}
logf("Result = %d%n", result);
logf("%sResult = %d%n", prefix, result);

output.write(result + "\n");
} else {
System.err.printf("Unrecognized request (len=%d): \"%s\"%n", request.length(), request);
System.err.printf("%sUnrecognized request (len=%d): \"%s\"%n", prefix, request.length(), request);
int unrecognizedRequestCount = unrecognizedRequests.incrementAndGet();
if (unrecognizedRequestCount > MAX_UNRECOGNIZED_REQUESTS) {
System.err.printf("Shutting down after receiving %d unrecognized requests%n", unrecognizedRequestCount);
System.err.printf("%sShutting down after receiving %d unrecognized requests%n", prefix, unrecognizedRequestCount);
System.exit(0);
}
output.write("-1\n");
Expand Down
2 changes: 1 addition & 1 deletion src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18173,7 +18173,7 @@ def alarm_handler(signum, frame):
_CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache'))

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("7.25.3") # GR-704 Remove --vm and --vmbuild flags
version = VersionSpec("7.25.4") # GR-54113

_mx_start_datetime = datetime.utcnow()

Expand Down

0 comments on commit f2d92b8

Please sign in to comment.