mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 04:50:49 +00:00
[misc] ContentCacheMetrics: log slow pdf caching performance
This commit is contained in:
parent
f32f5e58a8
commit
a4389fb761
1 changed files with 26 additions and 0 deletions
|
@ -1,4 +1,20 @@
|
|||
const logger = require('logger-sharelatex')
|
||||
const Metrics = require('./Metrics')
|
||||
const os = require('os')
|
||||
|
||||
let CACHED_LOAD = {
|
||||
expires: -1,
|
||||
load: [0, 0, 0]
|
||||
}
|
||||
function getSystemLoad() {
|
||||
if (CACHED_LOAD.expires < Date.now()) {
|
||||
CACHED_LOAD = {
|
||||
expires: Date.now() + 10 * 1000,
|
||||
load: os.loadavg()
|
||||
}
|
||||
}
|
||||
return CACHED_LOAD.load
|
||||
}
|
||||
|
||||
const ONE_MB = 1024 * 1024
|
||||
|
||||
|
@ -20,6 +36,16 @@ function emitPdfCachingStats(stats, timings) {
|
|||
? timings.compileE2E /
|
||||
(timings.compileE2E - timings['compute-pdf-caching'])
|
||||
: 1
|
||||
if (fraction > 1.5) {
|
||||
logger.warn(
|
||||
{
|
||||
stats,
|
||||
timings,
|
||||
load: getSystemLoad()
|
||||
},
|
||||
'slow pdf caching'
|
||||
)
|
||||
}
|
||||
Metrics.summary('overhead-compute-pdf-ranges', fraction * 100 - 100)
|
||||
|
||||
// How does the hashing scale to pdf size in MB?
|
||||
|
|
Loading…
Reference in a new issue