Skip to content

Commit 2cb0031

Browse files
committed
deploy with perf logging
1 parent 906fad3 commit 2cb0031

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

server/server.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,19 @@ func newS3FS(version string) *s3FS {
133133

134134
// getFromCache retrieves an entry from cache or fetches from S3
135135
func getFromCache(ctx context.Context, version, path string) *CacheEntry {
136+
start := time.Now()
137+
defer func() {
138+
if duration := time.Since(start); duration > 10*time.Millisecond {
139+
log.Printf("[PERF] getFromCache slow: %v for path=%s", duration, path)
140+
}
141+
}()
142+
136143
// Normalize version - ensure it ends with exactly one slash
137144
if !strings.HasSuffix(version, "/") {
138145
version = version + "/"
139146
}
140147
cacheKey := fmt.Sprintf("%s%s", version, strings.TrimPrefix(path, "/"))
141148

142-
// Log S3 access for debugging
143-
// log.Printf("[getFromCache] S3 lookup: bucket=%s, key=%s, version=%s, path=%s", s3Bucket, cacheKey, version, path)
144-
145149
// Check cache first
146150
cacheMutex.RLock()
147151
if cached, ok := cache.Get(cacheKey); ok {
@@ -173,6 +177,9 @@ func getFromCache(ctx context.Context, version, path string) *CacheEntry {
173177
Key: aws.String(cacheKey),
174178
})
175179
s3FetchDuration.Observe(time.Since(s3FetchStart).Seconds())
180+
if duration := time.Since(s3FetchStart); duration > 10*time.Millisecond {
181+
log.Printf("[PERF] S3 GetObject: %v for key=%s", duration, cacheKey)
182+
}
176183

177184
if err == nil {
178185
defer result.Body.Close()
@@ -212,6 +219,9 @@ func getFromCache(ctx context.Context, version, path string) *CacheEntry {
212219
Delimiter: aws.String("/"),
213220
})
214221
s3ListDuration.Observe(time.Since(s3ListStart).Seconds())
222+
if duration := time.Since(s3ListStart); duration > 10*time.Millisecond {
223+
log.Printf("[PERF] S3 ListObjectsV2: %v for prefix=%s", duration, prefix)
224+
}
215225

216226
if err != nil {
217227
s3ListErrors.Inc()
@@ -692,7 +702,9 @@ func typecheckTypeScript(code string, version string) TypecheckResponse {
692702
// Track typecheck duration
693703
typecheckStart := time.Now()
694704
defer func() {
695-
typecheckDuration.Observe(time.Since(typecheckStart).Seconds())
705+
duration := time.Since(typecheckStart)
706+
typecheckDuration.Observe(duration.Seconds())
707+
log.Printf("[PERF] typecheckTypeScript total: %v", duration)
696708
}()
697709

698710
// Create S3-backed filesystem for this version
@@ -783,7 +795,9 @@ func buildTypeScript(code string, version string) BuildResponse {
783795
// Track compile duration
784796
compileStart := time.Now()
785797
defer func() {
786-
compileDuration.Observe(time.Since(compileStart).Seconds())
798+
duration := time.Since(compileStart)
799+
compileDuration.Observe(duration.Seconds())
800+
log.Printf("[PERF] buildTypeScript total: %v", duration)
787801
}()
788802

789803
// Create S3-backed filesystem for this version

0 commit comments

Comments
 (0)