From a4389fb761b670c6424ccd9fdb71d89dd7a46038 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 23 Jun 2021 09:15:05 +0100 Subject: [PATCH 1/3] [misc] ContentCacheMetrics: log slow pdf caching performance --- services/clsi/app/js/ContentCacheMetrics.js | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/services/clsi/app/js/ContentCacheMetrics.js b/services/clsi/app/js/ContentCacheMetrics.js index f5f9188ddc..d2da9d8601 100644 --- a/services/clsi/app/js/ContentCacheMetrics.js +++ b/services/clsi/app/js/ContentCacheMetrics.js @@ -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? From 11a44ff07ce5b3b2cb053ac315b13d105a53d225 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 23 Jun 2021 11:27:19 +0100 Subject: [PATCH 2/3] [misc] ContentCacheMetrics: apply review feedback: ignore fast compiles Co-Authored-By: Brian Gough --- services/clsi/app/js/ContentCacheMetrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/clsi/app/js/ContentCacheMetrics.js b/services/clsi/app/js/ContentCacheMetrics.js index d2da9d8601..5c54ba0861 100644 --- a/services/clsi/app/js/ContentCacheMetrics.js +++ b/services/clsi/app/js/ContentCacheMetrics.js @@ -36,7 +36,7 @@ function emitPdfCachingStats(stats, timings) { ? timings.compileE2E / (timings.compileE2E - timings['compute-pdf-caching']) : 1 - if (fraction > 1.5) { + if (fraction > 1.5 && timings.compileE2E > 10 * 1000) { logger.warn( { stats, From 97693b49c2a6cffc2899def1568915eec02da279 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 23 Jun 2021 11:28:31 +0100 Subject: [PATCH 3/3] [ContentCacheMetrics] add new metric for absolute time spent in PDF.js --- services/clsi/app/js/ContentCacheMetrics.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/clsi/app/js/ContentCacheMetrics.js b/services/clsi/app/js/ContentCacheMetrics.js index 5c54ba0861..0078406926 100644 --- a/services/clsi/app/js/ContentCacheMetrics.js +++ b/services/clsi/app/js/ContentCacheMetrics.js @@ -30,6 +30,9 @@ function emitPdfStats(stats, timings) { function emitPdfCachingStats(stats, timings) { if (!stats['pdf-size']) return // double check + // How much extra time did we spent in PDF.js? + Metrics.timing('compute-pdf-caching', timings['compute-pdf-caching']) + // How large is the overhead of hashing up-front? const fraction = timings.compileE2E - timings['compute-pdf-caching'] !== 0