@@ -133,15 +133,19 @@ func newS3FS(version string) *s3FS {
133
133
134
134
// getFromCache retrieves an entry from cache or fetches from S3
135
135
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
+
136
143
// Normalize version - ensure it ends with exactly one slash
137
144
if ! strings .HasSuffix (version , "/" ) {
138
145
version = version + "/"
139
146
}
140
147
cacheKey := fmt .Sprintf ("%s%s" , version , strings .TrimPrefix (path , "/" ))
141
148
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
-
145
149
// Check cache first
146
150
cacheMutex .RLock ()
147
151
if cached , ok := cache .Get (cacheKey ); ok {
@@ -173,6 +177,9 @@ func getFromCache(ctx context.Context, version, path string) *CacheEntry {
173
177
Key : aws .String (cacheKey ),
174
178
})
175
179
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
+ }
176
183
177
184
if err == nil {
178
185
defer result .Body .Close ()
@@ -212,6 +219,9 @@ func getFromCache(ctx context.Context, version, path string) *CacheEntry {
212
219
Delimiter : aws .String ("/" ),
213
220
})
214
221
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
+ }
215
225
216
226
if err != nil {
217
227
s3ListErrors .Inc ()
@@ -692,7 +702,9 @@ func typecheckTypeScript(code string, version string) TypecheckResponse {
692
702
// Track typecheck duration
693
703
typecheckStart := time .Now ()
694
704
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 )
696
708
}()
697
709
698
710
// Create S3-backed filesystem for this version
@@ -783,7 +795,9 @@ func buildTypeScript(code string, version string) BuildResponse {
783
795
// Track compile duration
784
796
compileStart := time .Now ()
785
797
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 )
787
801
}()
788
802
789
803
// Create S3-backed filesystem for this version
0 commit comments