Skip to content

Commit

Permalink
DRAFT: profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
4e6 committed Apr 29, 2024
1 parent ba199d7 commit f38c358
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/gui2/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function gatewayServer(): Plugin {
buildEnd() {
if (ydocServer == null) return

ydocServer.kill(9)
ydocServer.kill('SIGTERM')
},
}
}
Expand Down
6 changes: 5 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions lib/java/ydoc-server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down
16 changes: 16 additions & 0 deletions lib/java/ydoc-server/src/main/java/org/enso/ydoc/Main.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,12 +13,25 @@
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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public void onMessage(WsSession session, BufferData buffer, boolean last) {
session.send(buffer, last);
}

@Override
public void onPing(WsSession session, BufferData buffer) {
session.pong(buffer);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/scala/profiling-utils/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module org.enso.profiling {
exports org.enso.profiling.sampler;
exports org.enso.profiling.events;
}

0 comments on commit f38c358

Please sign in to comment.