feat(lab5): time pipeline stages and centralize variant constants

This commit is contained in:
Mikhail Verkovykh
2026-11-20 19:05:27 +03:00
parent 1ce93185af
commit d0f533b371
5 changed files with 121 additions and 36 deletions
+12 -2
View File
@@ -124,7 +124,6 @@ func (w *Worker) Handle(ctx context.Context, message model.Job) error {
return w.handleFailure(ctx, claim, err, log)
}
log.Info("attachment ready")
if w.cfg.CrashAfterEffect {
// Deterministic fault injection for the "written but not acked" window.
// The unacked delivery is redelivered after the connection dies.
@@ -191,7 +190,7 @@ func (w *Worker) process(ctx context.Context, claim store.ClaimResult, log *slog
return &pipeline.Failure{Permanent: true, Code: "staging_corrupt", Err: errors.New("staged checksum mismatch")}
}
encoded, err := w.pipeline.Process(ctx, file)
encoded, stats, err := w.pipeline.Process(ctx, file)
if err != nil {
return err
}
@@ -229,6 +228,17 @@ func (w *Worker) process(ctx context.Context, claim store.ClaimResult, log *slog
return nil
}
// The timing line is the experiment's source for compression overhead. It
// is emitted only after the ready snapshot commits, so a redelivered job
// cannot produce two successful samples.
log.Info("attachment ready",
"decode_us", stats.Decode.Microseconds(),
"scale_us", stats.Scale.Microseconds(),
"jpeg_encode_us", stats.JPEGEncode.Microseconds(),
"webp_encode_us", stats.WebPEncode.Microseconds(),
"pipeline_us", stats.Total().Microseconds(),
)
// Staging is removed only after ready commits. A crash before this delete
// leaves an object the reconciler will clean after retention.
if err = w.objects.Delete(ctx, att.StagingKey); err != nil && !errors.Is(err, objectstore.ErrNotFound) {