Skip to content

Commit

Permalink
Update instructions for importing call tree reports into Neo4J
Browse files Browse the repository at this point in the history
Starting with GraalVM for JDK 24 a different set of csv files is being
created (see oracle/graal#8774).
  • Loading branch information
zakkak committed Jul 16, 2024
1 parent 75b4ed4 commit d5650fb
Showing 1 changed file with 45 additions and 32 deletions.
77 changes: 45 additions & 32 deletions docs/src/main/asciidoc/native-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ First, start a Neo4j instance:

[source,bash]
----
export NEO_PASS=...
export NEO_PASS=mypassword
docker run \
--detach \
--rm \
Expand Down Expand Up @@ -1160,59 +1160,72 @@ Copy and paste the contents of the script into a file called `import.cypher`.

[WARNING]
====
Mandrel 22.0.0 contains a bug where the symbolic links used by the import cypher file are not correctly set when generating reports within a container
(for more details see link:https://github.com/oracle/graal/issues/4355[here]).
This can be worked around by copying the following script into a file and executing it:
Starting with GraalVM for JDK 24 a set of different files is being generated. So the following cypher script needs to be used instead:

Check warning on line 1163 in docs/src/main/asciidoc/native-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.CaseSensitiveTerms] Use 'OpenJDK' rather than 'JDK'. Raw Output: {"message": "[Quarkus.CaseSensitiveTerms] Use 'OpenJDK' rather than 'JDK'.", "location": {"path": "docs/src/main/asciidoc/native-reference.adoc", "range": {"start": {"line": 1163, "column": 27}}}, "severity": "INFO"}

Check warning on line 1163 in docs/src/main/asciidoc/native-reference.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'needs to'. Raw Output: {"message": "[Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'needs to'.", "location": {"path": "docs/src/main/asciidoc/native-reference.adoc", "range": {"start": {"line": 1163, "column": 110}}}, "severity": "INFO"}
[source,bash]
[source,cypher]
----
set -e
project="debugging-native"
pushd target/*-native-image-source-jar/reports
rm -f call_tree_vm.csv
ln -s call_tree_vm_${project}-* call_tree_vm.csv
rm -f call_tree_direct_edges.csv
ln -s call_tree_direct_edges_${project}-* call_tree_direct_edges.csv
rm -f call_tree_entry_points.csv
ln -s call_tree_entry_points_${project}-* call_tree_entry_points.csv
rm -f call_tree_methods.csv
ln -s call_tree_methods_${project}-* call_tree_methods.csv
CREATE CONSTRAINT unique_method_id FOR (m:Method) REQUIRE m.methodId IS UNIQUE;
CREATE CONSTRAINT unique_invoke_id FOR (i:Invoke) REQUIRE i.id IS UNIQUE;
rm -f call_tree_virtual_edges.csv
ln -s call_tree_virtual_edges_${project}-* call_tree_virtual_edges.csv
LOAD CSV WITH HEADERS FROM 'file:///reports/call_tree_methods.csv' AS row
CREATE (m:Method {
methodId: toInteger(row.Id),
name: row.Name,
type: row.Type,
parameters: row.Parameters,
return: row.Return,
display: row.Display,
flags: row.Flags,
isEntryPoint: toBoolean(row.IsEntrypoint)})
RETURN count(m);
rm -f call_tree_virtual_methods.csv
ln -s call_tree_virtual_methods_${project}-* call_tree_virtual_methods.csv
LOAD CSV WITH HEADERS FROM 'file:///reports/call_tree_invokes.csv' AS row
CREATE (i:Invoke {
id: toInteger(row.Id),
methodId: toInteger(row.MethodId),
bytecodeIndexes: row.BytecodeIndexes,
targetId: toInteger(row.TargetId),
isDirect: toBoolean(row.IsDirect)
})
RETURN count(i);
MATCH (i:Invoke {isDirect: true})
MATCH (caller:Method {methodId: i.methodId})
MATCH (callee:Method {methodId: i.targetId})
CREATE (caller)-[:DIRECT {bci: i.BytecodeIndexes}]->(callee)
RETURN count(*);
rm -f call_tree_override_by_edges.csv
ln -s call_tree_override_by_edges_${project}-* call_tree_override_by_edges.csv
MATCH (i:Invoke {isDirect: false})
MATCH (caller:Method {methodId: i.methodId})
MATCH (callee:Method {methodId: i.targetId})
CREATE (caller)-[:VIRTUAL {bci: i.BytecodeIndexes}]->(callee)
RETURN count(*);
popd
LOAD CSV WITH HEADERS FROM 'file:///reports/call_tree_targets.csv' AS row
MATCH (i:Invoke {id: toInteger(row.InvokeId)})
MATCH (callee:Method {methodId: toInteger(row.TargetId)})
MATCH (caller:Method {methodId: i.methodId})
CREATE (caller)-[:OVERRIDEN_BY]->(callee)
RETURN count(*);
----
====

Next, copy the import cypher script and CSV files into Neo4j's import folder:
Next, copy the CSV files into Neo4j's import folder:

[source,bash]
----
docker cp \
target/*-native-image-source-jar/reports \
testneo4j:/var/lib/neo4j/import
docker cp import.cypher testneo4j:/var/lib/neo4j
docker exec -i testneo4j chown -R neo4j:neo4j import/reports
----

After copying all the files, invoke the import script:

[source,bash]
----
docker exec testneo4j bin/cypher-shell -u neo4j -p ${NEO_PASS} -f import.cypher
cat import.cypher | docker exec -i testneo4j bin/cypher-shell -u neo4j -p ${NEO_PASS}
----

Once the import completes (shouldn't take more than a couple of minutes), go to the link:http://localhost:7474[Neo4j browser],
Expand Down

0 comments on commit d5650fb

Please sign in to comment.