Skip to content

Commit 4d3090a

Browse files
Documentation
1 parent f5de17d commit 4d3090a

File tree

4 files changed

+117
-8
lines changed

4 files changed

+117
-8
lines changed

doc/modules/ROOT/pages/common-usage/monitoring-system.adoc

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,112 @@ Here we can note that there is only one GDS procedure currently running, namely
104104
We also see that it may use up to an estimated `234 kB` of memory.
105105
Note that it may not currently be using that much memory and so it may require more memory later in its execution, thus possible lowering our current `freeHeap`.
106106
Apparently it wants to use up to `16` CPU cores, leaving us with a total of `84` currently available cores in the system not requested by any GDS procedures.
107+
108+
[[Memory-reporting-procedures]]
109+
== Memory reporting procedures
110+
111+
To facilitate memory management, the Neo4j GDS Library offers two memory reporting procedures, alongside the aforementioned monitoring capabilities.
112+
113+
[detailed-memory-listing]
114+
=== Detailed memory listing
115+
116+
Through the `gds.listMemory` procedure, a user can obtain a combined list of their projected graphs and running tasks alongside their memory footprint.
117+
118+
For graphs, the size of the in-memory graph is returned, whereas for algorithms the memory estimation i.e., the maximum memory needs that this task is expected to require over the course of its execution.
119+
120+
This procedure can help a user realize which of his operations might be memory demanding and plan accordingly (e.g., drop a graph, or termination a transaction).
121+
122+
A user can access only his own graphs or tasks, but an admin can obtain information for all users.
123+
124+
[[syntax]]
125+
==== Syntax
126+
.List the graphs and tasks of a user along with their memory footprint.
127+
[source, cypher, role=noplay]
128+
----
129+
CALL gds.listMemory()
130+
YIELD
131+
user: String,
132+
name: String,
133+
entity: String
134+
memoryInBytes: Integer
135+
----
136+
137+
.Results
138+
[opts="header",cols="1,1,6"]
139+
|===
140+
| Name | Type | Description
141+
| user | String | The username
142+
| name | String | The name of the graph or running task.
143+
| entity | String | If the reporting entity is a task, this corresponds to its job id. Otherwise, it is set to "graph".
144+
| memoryInBytes | Integer | The occupying memory
145+
for a graph or the estimation of a task.
146+
|===
147+
148+
=== Example
149+
150+
.List running tasks and graphs for Bob.
151+
[source, cypher, role=noplay]
152+
----
153+
CALL gds.listMemory()
154+
YIELD
155+
user, name, entity, memoryInBytes
156+
----
157+
158+
.Results
159+
[opts="header",cols='2,2,2,2']
160+
|===
161+
| user | name | entity | memoryInBytes |
162+
"Bob" | "my-graph" | "graph" | 20 |
163+
"Bob" | "Node2Vec" | 111-222-333 | 234
164+
|===
165+
166+
As we can see, Bob has projected a graph named 'my-graph' occupying 200 bytes memory, and is currently running Node2Vec which has a memory footprint of 234 bytes.
167+
168+
[memory-summary]
169+
=== Memory Summary
170+
171+
The `gds.listMemory.summary` procedure provides an overview of the total graph memory, and the total memory requirements of running tasks for a given users.
172+
173+
174+
A user can access only his own graphs or tasks, but an admin can obtain information for all users.
175+
176+
[[syntax]]
177+
==== Syntax
178+
.List the graphs and tasks of a user along with their memory footprint.
179+
[source, cypher, role=noplay]
180+
----
181+
CALL gds.listMemory.summary()
182+
YIELD
183+
user: String,
184+
totalGraphsMemory : Intger,
185+
totalTasksMemory : Integer
186+
----
187+
188+
.Results
189+
[opts="header",cols="1,1,6"]
190+
|===
191+
| Name | Type | Description
192+
| user | String | The username.
193+
|totalGraphsMemory | Integer| The total requirement for that user's graphs.
194+
| totalTasksMemory | Integer | The total requirements of that user's tasks.
195+
|===
196+
197+
=== Example
198+
199+
.List running tasks and graphs for Bob.
200+
[source, cypher, role=noplay]
201+
----
202+
CALL gds.listMemory.summary()
203+
YIELD
204+
user, totalGraphsMemory, totalTasksMemory
205+
----
206+
207+
.Results
208+
[opts="header",cols='2,2,2']
209+
|===
210+
| user | totalGraphsMemory | totalTasksMemory |
211+
"Bob" | 20 | 234
212+
|===
213+
214+
215+

proc/misc/src/integrationTest/java/org/neo4j/gds/MemoryProcTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void shouldReturnEmptySummary() {
5353
"CALL gds.listMemory.summary",
5454
resultRow -> {
5555
assertThat(resultRow.getString("user")).isEqualTo("alice");
56-
assertThat(resultRow.getNumber("totalGraphMemory")).asInstanceOf(LONG).isEqualTo(0);
56+
assertThat(resultRow.getNumber("totalGraphsMemory")).asInstanceOf(LONG).isEqualTo(0);
5757
assertThat(resultRow.getNumber("totalTasksMemory")).asInstanceOf(LONG).isEqualTo(0);
5858
});
5959
assertThat(rowCount).isEqualTo(1L);
@@ -97,7 +97,7 @@ void shouldSummarizeAccordingly() {
9797
"CALL gds.listMemory.summary",
9898
resultRow -> {
9999
assertThat(resultRow.getString("user")).isEqualTo("bob");
100-
assertThat(resultRow.getNumber("totalGraphMemory")).asInstanceOf(LONG).isEqualTo(0);
100+
assertThat(resultRow.getNumber("totalGraphsMemory")).asInstanceOf(LONG).isEqualTo(0);
101101
assertThat(resultRow.getNumber("totalTasksMemory")).asInstanceOf(LONG).isEqualTo(0);
102102
});
103103

@@ -131,7 +131,7 @@ void canSummarizeRunningTask() {
131131
"CALL gds.listMemory.summary",
132132
resultRow -> {
133133
assertThat(resultRow.getString("user")).isEqualTo("alice");
134-
assertThat(resultRow.getNumber("totalGraphMemory")).asInstanceOf(LONG).isEqualTo(0);
134+
assertThat(resultRow.getNumber("totalGraphsMemory")).asInstanceOf(LONG).isEqualTo(0);
135135
assertThat(resultRow.getNumber("totalTasksMemory")).asInstanceOf(LONG).isGreaterThan(0);
136136
});
137137
assertThat(rowCountAlice).isEqualTo(1L);
@@ -140,7 +140,7 @@ void canSummarizeRunningTask() {
140140
"CALL gds.listMemory.summary",
141141
resultRow -> {
142142
assertThat(resultRow.getString("user")).isEqualTo("bob");
143-
assertThat(resultRow.getNumber("totalGraphMemory")).asInstanceOf(LONG).isEqualTo(0);
143+
assertThat(resultRow.getNumber("totalGraphsMemory")).asInstanceOf(LONG).isEqualTo(0);
144144
assertThat(resultRow.getNumber("totalTasksMemory")).asInstanceOf(LONG).isEqualTo(0);
145145
});
146146

progress-tracking/src/main/java/org/neo4j/gds/mem/UserMemorySummary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
*/
2020
package org.neo4j.gds.mem;
2121

22-
public record UserMemorySummary(String user, long totalGraphMemory, long totalTasksMemory) {}
22+
public record UserMemorySummary(String user, long totalGraphsMemory, long totalTasksMemory) {}
2323

progress-tracking/src/test/java/org/neo4j/gds/mem/MemoryTrackerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ void shouldReturnMemoryForUser(){
114114
memoryTracker.onGraphStoreAdded(new GraphStoreAddedEvent("alice","neo4j","graph1",11));
115115

116116
var aliceMemory = memoryTracker.memorySummary("alice");
117-
assertThat(aliceMemory.totalGraphMemory()).isEqualTo(11L);
117+
assertThat(aliceMemory.totalGraphsMemory()).isEqualTo(11L);
118118
assertThat(aliceMemory.totalTasksMemory()).isEqualTo(12L);
119119

120120
var bobMemory = memoryTracker.memorySummary("bob");
121-
assertThat(bobMemory.totalGraphMemory()).isEqualTo(0L);
121+
assertThat(bobMemory.totalGraphsMemory()).isEqualTo(0L);
122122
assertThat(bobMemory.totalTasksMemory()).isEqualTo(5L);
123123

124124
}
@@ -133,7 +133,7 @@ void shouldReturnMemoryForAll(){
133133

134134
var list = memoryTracker.memorySummary().toList();
135135

136-
assertThat(list.stream()).map(UserMemorySummary::totalGraphMemory).containsExactlyInAnyOrder(11L,0L);
136+
assertThat(list.stream()).map(UserMemorySummary::totalGraphsMemory).containsExactlyInAnyOrder(11L,0L);
137137
assertThat(list.stream()).map(UserMemorySummary::totalTasksMemory).containsExactlyInAnyOrder(12L,5L);
138138

139139
}

0 commit comments

Comments
 (0)