DRAFT: profiling

This commit is contained in:
Dmitry Bushev 2024-04-24 13:39:38 +01:00
parent ba199d796d
commit f38c358441
No known key found for this signature in database
GPG Key ID: 87C16090D6910E91
6 changed files with 28 additions and 2 deletions

View File

@ -140,7 +140,7 @@ function gatewayServer(): Plugin {
buildEnd() {
if (ydocServer == null) return
ydocServer.kill(9)
ydocServer.kill('SIGTERM')
},
}
}

View File

@ -1184,7 +1184,10 @@ lazy val `ydoc-server` = project
shouldContainAll = true
)
},
modulePath += (`syntax-rust-definition` / Compile / productDirectories).value.head,
modulePath ++= Seq(
(`syntax-rust-definition` / Compile / productDirectories).value.head,
(`profiling-utils` / Compile / productDirectories).value.head
),
libraryDependencies ++= Seq(
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion,
"org.graalvm.polyglot" % "inspect" % graalMavenPackagesVersion % "runtime",
@ -1198,6 +1201,7 @@ lazy val `ydoc-server` = project
)
.dependsOn(`syntax-rust-definition`)
.dependsOn(`logging-service-logback`)
.dependsOn(`profiling-utils`)
lazy val `persistance` = (project in file("lib/java/persistance"))
.settings(

View File

@ -3,6 +3,7 @@ module org.enso.ydoc {
requires io.helidon.webclient.websocket;
requires io.helidon.webserver;
requires io.helidon.webserver.websocket;
requires org.enso.profiling;
requires org.enso.syntax;
requires org.graalvm.polyglot;
requires org.slf4j;

View File

@ -1,7 +1,10 @@
package org.enso.ydoc;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import org.enso.profiling.sampler.OutputStreamSampler;
import org.enso.ydoc.polyfill.ParserPolyfill;
import org.enso.ydoc.polyfill.web.WebEnvironment;
import org.graalvm.polyglot.Source;
@ -10,12 +13,25 @@ import org.graalvm.polyglot.io.IOAccess;
public class Main {
private static final String YDOC_SERVER_PATH = "/dist/assets/ydocServer.js";
private static final String SAMPLES_PATH = "/tmp/ydoc-server.out";
private Main() {}
public static void main(String[] args) throws Exception {
var ydoc = Main.class.getResource(YDOC_SERVER_PATH);
var contextBuilder = WebEnvironment.createContext().allowIO(IOAccess.ALL);
var sampler = OutputStreamSampler.ofFile(new File(SAMPLES_PATH));
sampler.start();
Runtime.getRuntime()
.addShutdownHook(
new Thread(
() -> {
try {
sampler.stop();
} catch (IOException e) {
throw new RuntimeException(e);
}
}));
try (var executor = Executors.newSingleThreadExecutor();
var parser = new ParserPolyfill()) {

View File

@ -249,6 +249,7 @@ public class WebSocketTest {
session.send(buffer, last);
}
@Override
public void onPing(WsSession session, BufferData buffer) {
session.pong(buffer);
}

View File

@ -0,0 +1,4 @@
module org.enso.profiling {
exports org.enso.profiling.sampler;
exports org.enso.profiling.events;
}