[clsi] prepare for clsi-cache survey (#29274)

* [clsi] add stats and timings to compile response from clsi-cache

* [clsi] set downloadedFromCache when previously downloaded for synctex

Assumption: every compile will emit an output.log. When the output.log
is missing, but the output.synctex.gz exists, it must have been
downloaded from the cache.
GitOrigin-RevId: 41ea34880931e3c43dda3bc9eb26c0d02054894d
This commit is contained in:
Jakob Ackermann
2025-10-22 14:53:26 +02:00
committed by Copybot
parent a0ad073785
commit 02391c6c51
5 changed files with 31 additions and 1 deletions

View File

@@ -42,6 +42,8 @@ function getShard(projectId) {
* @param {string} editorId * @param {string} editorId
* @param {[{path: string}]} outputFiles * @param {[{path: string}]} outputFiles
* @param {string} compileGroup * @param {string} compileGroup
* @param {Record<string, number>} stats
* @param {Record<string, number>} timings
* @param {Record<string, any>} options * @param {Record<string, any>} options
* @return {string | undefined} * @return {string | undefined}
*/ */
@@ -52,6 +54,8 @@ function notifyCLSICacheAboutBuild({
editorId, editorId,
outputFiles, outputFiles,
compileGroup, compileGroup,
stats,
timings,
options, options,
}) { }) {
if (!Settings.apis.clsiCache.enabled) return undefined if (!Settings.apis.clsiCache.enabled) return undefined
@@ -72,6 +76,8 @@ function notifyCLSICacheAboutBuild({
downloadHost: Settings.apis.clsi.downloadHost, downloadHost: Settings.apis.clsi.downloadHost,
clsiServerId: Settings.apis.clsi.clsiServerId, clsiServerId: Settings.apis.clsi.clsiServerId,
compileGroup, compileGroup,
stats,
timings,
options, options,
}) })
) )

View File

@@ -125,6 +125,8 @@ function compile(req, res, next) {
editorId: request.editorId, editorId: request.editorId,
outputFiles, outputFiles,
compileGroup: request.compileGroup, compileGroup: request.compileGroup,
stats,
timings,
options: { options: {
compiler: request.compiler, compiler: request.compiler,
draft: request.draft, draft: request.draft,

View File

@@ -561,6 +561,13 @@ async function _runSynctex(projectId, userId, command, opts) {
let downloadedFromCache = false let downloadedFromCache = false
try { try {
await _checkFileExists(directory, 'output.synctex.gz') await _checkFileExists(directory, 'output.synctex.gz')
if (compileFromClsiCache) {
try {
await _checkFileExists(directory, 'output.log')
} catch (err) {
if (err instanceof Errors.NotFoundError) downloadedFromCache = true
}
}
} catch (err) { } catch (err) {
if ( if (
err instanceof Errors.NotFoundError && err instanceof Errors.NotFoundError &&

View File

@@ -123,6 +123,8 @@ async function getLatestBuildFromCache(req, res) {
clsiServerId, clsiServerId,
clsiCacheShard, clsiCacheShard,
options, options,
stats,
timings,
} = await ClsiCacheManager.getLatestCompileResult(projectId, userId) } = await ClsiCacheManager.getLatestCompileResult(projectId, userId)
let { pdfCachingMinChunkSize, pdfDownloadDomain } = let { pdfCachingMinChunkSize, pdfDownloadDomain } =
@@ -138,6 +140,8 @@ async function getLatestBuildFromCache(req, res) {
pdfDownloadDomain, pdfDownloadDomain,
pdfCachingMinChunkSize, pdfCachingMinChunkSize,
options, options,
stats,
timings,
}) })
} catch (err) { } catch (err) {
if (err instanceof NotFoundError) { if (err instanceof NotFoundError) {

View File

@@ -107,7 +107,16 @@ async function tryGetLatestCompileResult(projectId, userId, signal) {
const [, editorId, buildId] = metaLocation.match( const [, editorId, buildId] = metaLocation.match(
/\/build\/([a-f0-9-]+?)-([a-f0-9]+-[a-f0-9]+)\// /\/build\/([a-f0-9-]+?)-([a-f0-9]+-[a-f0-9]+)\//
) )
const { ranges, contentId, clsiServerId, compileGroup, size, options } = meta const {
ranges,
contentId,
clsiServerId,
compileGroup,
size,
options,
stats,
timings,
} = meta
let baseURL = `/project/${projectId}` let baseURL = `/project/${projectId}`
if (userId) { if (userId) {
@@ -150,6 +159,8 @@ async function tryGetLatestCompileResult(projectId, userId, signal) {
clsiServerId, clsiServerId,
clsiCacheShard, clsiCacheShard,
options, options,
stats,
timings,
} }
} }