File tree Expand file tree Collapse file tree 4 files changed +22
-12
lines changed
packages/labextension/src Expand file tree Collapse file tree 4 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,9 @@ causes "lag"/pauses in the UI. To workaround this you can disable Prometheus met
105
105
106
106
## Resources Displayed
107
107
108
- Currently the server extension only reports memory usage (just RSS) and CPU usage. Other metrics will be
109
- added in the future as needed.
108
+ Currently the server extension only reports memory usage and CPU usage. Other metrics will be added in the future as needed.
109
+
110
+ Memory usage will show the PSS whenever possible (Linux only feature), and default to RSS otherwise.
110
111
111
112
The notebook extension currently doesn't show CPU usage, only memory usage.
112
113
Original file line number Diff line number Diff line change @@ -42,24 +42,30 @@ async def get(self):
42
42
43
43
# Get memory information
44
44
rss = 0
45
+ pss = None
45
46
for p in all_processes :
46
47
try :
47
- rss += p .memory_info ().rss
48
+ info = p .memory_full_info ()
49
+ if hasattr (info , "pss" ):
50
+ pss = (pss or 0 ) + info .pss
51
+ rss += info .rss
48
52
except (psutil .NoSuchProcess , psutil .AccessDenied ) as e :
49
53
pass
50
54
51
55
if callable (config .mem_limit ):
52
- mem_limit = config .mem_limit (rss = rss )
56
+ mem_limit = config .mem_limit (rss = rss , pss = pss )
53
57
else : # mem_limit is an Int
54
58
mem_limit = config .mem_limit
55
59
56
- limits = {"memory" : {"rss" : mem_limit }}
60
+ limits = {"memory" : {"rss" : mem_limit , "pss" : mem_limit }}
57
61
if config .mem_limit and config .mem_warning_threshold != 0 :
58
62
limits ["memory" ]["warn" ] = (mem_limit - rss ) < (
59
63
mem_limit * config .mem_warning_threshold
60
64
)
61
65
62
66
metrics = {"rss" : rss , "limits" : limits }
67
+ if pss is not None :
68
+ metrics ["pss" ] = pss
63
69
64
70
# Optionally get CPU information
65
71
if config .track_cpu_percent :
Original file line number Diff line number Diff line change @@ -53,14 +53,16 @@ define([
53
53
$ . getJSON ( {
54
54
url : utils . get_body_data ( 'baseUrl' ) + 'api/metrics/v1' ,
55
55
success : function ( data ) {
56
- totalMemoryUsage = humanFileSize ( data [ 'rss' ] ) ;
56
+ value = data [ 'pss' ] || data [ 'rss' ] ;
57
+ totalMemoryUsage = humanFileSize ( value ) ;
57
58
58
59
var limits = data [ 'limits' ] ;
59
60
var display = totalMemoryUsage ;
60
61
61
62
if ( limits [ 'memory' ] ) {
62
- if ( limits [ 'memory' ] [ 'rss' ] ) {
63
- maxMemoryUsage = humanFileSize ( limits [ 'memory' ] [ 'rss' ] ) ;
63
+ limit = limits [ 'memory' ] [ 'pss' ] ?? limits [ 'memory' ] [ 'rss' ] ;
64
+ if ( limit ) {
65
+ maxMemoryUsage = humanFileSize ( limit ) ;
64
66
display += " / " + maxMemoryUsage
65
67
}
66
68
if ( limits [ 'memory' ] [ 'warn' ] ) {
Original file line number Diff line number Diff line change @@ -180,10 +180,9 @@ export namespace MemoryUsage {
180
180
this . _units = 'B' ;
181
181
this . _warn = false ;
182
182
} else {
183
- const numBytes = value . rss ;
184
- const memoryLimit = value . limits . memory
185
- ? value . limits . memory . rss
186
- : null ;
183
+ const numBytes = value . pss ?? value . rss ;
184
+ const memoryLimits = value . limits . memory ;
185
+ const memoryLimit = memoryLimits ?. pss ?? memoryLimits ?. rss ?? null ;
187
186
const [ currentMemory , units ] = convertToLargestUnit ( numBytes ) ;
188
187
const usageWarning = value . limits . memory
189
188
? value . limits . memory . warn
@@ -260,9 +259,11 @@ namespace Private {
260
259
*/
261
260
export interface IMetricRequestResult {
262
261
rss : number ;
262
+ pss ?: number ;
263
263
limits : {
264
264
memory ?: {
265
265
rss : number ;
266
+ pss ?: number ;
266
267
warn : boolean ;
267
268
} ;
268
269
} ;
You can’t perform that action at this time.
0 commit comments