Просмотр исходного кода

[clsi] reduce write traffic to clsi-cache from free users (#32958)

GitOrigin-RevId: c01cc21c3c82f361c7d82843e65bb087b21434ed
Jakob Ackermann 5 месяцев назад
Родитель
Сommit
926d6bccd7
2 измененных файлов с 31 добавлено и 20 удалено
  1. 30 20
      services/clsi/app/js/CLSICacheHandler.js
  2. 1 0
      services/clsi/app/js/CompileController.js

+ 30 - 20
services/clsi/app/js/CLSICacheHandler.js

@@ -115,6 +115,7 @@ function closeCircuitBreaker(url) {
  * @param {Record<string, number>} opts.stats
  * @param {Record<string, number>} opts.timings
  * @param {Record<string, any>} opts.options
+ * @param {{path:string,method:string}} opts.metricsOpts
  * @return {string | undefined}
  */
 function notifyCLSICacheAboutBuild({
@@ -127,6 +128,7 @@ function notifyCLSICacheAboutBuild({
   stats,
   timings,
   options,
+  metricsOpts,
 }) {
   if (!Settings.apis.clsiCache.enabled) return undefined
   if (!OBJECT_ID_REGEX.test(projectId)) return undefined
@@ -192,26 +194,34 @@ function notifyCLSICacheAboutBuild({
       })
   }
 
-  // PDF preview
-  enqueue(
-    outputFiles
-      .filter(
-        f =>
-          f.path === 'output.pdf' ||
-          f.path === 'output.log' ||
-          f.path === 'output.synctex.gz'
-      )
-      .concat(
-        outputFiles.filter(f => f.path.endsWith('.blg')).slice(0, MAX_BLG_FILES)
-      )
-      .map(f => {
-        const lean = { path: f.path }
-        if (f.path === 'output.pdf') {
-          Object.assign(lean, _.pick(f, 'path', 'size', 'contentId', 'ranges'))
-        }
-        return lean
-      })
-  )
+  const isUserCompile = !metricsOpts.path
+  if (!(isUserCompile && compileGroup === 'standard')) {
+    // PDF preview, skip for free compiles
+    enqueue(
+      outputFiles
+        .filter(
+          f =>
+            f.path === 'output.pdf' ||
+            f.path === 'output.log' ||
+            f.path === 'output.synctex.gz'
+        )
+        .concat(
+          outputFiles
+            .filter(f => f.path.endsWith('.blg'))
+            .slice(0, MAX_BLG_FILES)
+        )
+        .map(f => {
+          const lean = { path: f.path }
+          if (f.path === 'output.pdf') {
+            Object.assign(
+              lean,
+              _.pick(f, 'path', 'size', 'contentId', 'ranges')
+            )
+          }
+          return lean
+        })
+    )
+  }
 
   // Compile Cache
   buildTarball({ projectId, userId, buildId, outputFiles })

+ 1 - 0
services/clsi/app/js/CompileController.js

@@ -143,6 +143,7 @@ function compile(req, res, next) {
                   rootResourcePath: request.rootResourcePath,
                   stopOnFirstError: request.stopOnFirstError,
                 },
+                metricsOpts: request.metricsOpts,
               })
             }