I think we can drop this one. I thought I'd post it to the list either
way

Spotify comments
----------------
To be able to detect severely fragmented MP4 files, and trigger special
handling for them (reducing Photon chunk concurrency). For these files,
the default handling causes so much I/O from all the Photon workers
that they would overload the Colada proxy-cache they read from.

Possible other solutions:
    • Add additional I/O stats in ffmpeg somehow?

/Tomas
From 78d7684754c6ba8c35c3f36e3513838c91709876 Mon Sep 17 00:00:00 2001
From: John Talling <tall...@spotify.com>
Date: Thu, 5 Jan 2023 13:33:15 +0100
Subject: [PATCH 10/15] Add statistic for number of avio_seek() calls done

This is done in order to be able to identify files that take a lot of
seeking to open (notably: fragmented MP4 files without sidx boxes).

While the thing we'd optimally like to measure is the number of seeks
performed on the underlying HTTP connection, this count varies depending
on TCP window size, can behave differently in docker vs. natively etc.
So we use the number of avio_seek() calls (including indirect ones from
avio_skip() etc.) as a proxy for the number of HTTP seeks. The number of
calls is consistent regardless of network condition and is still useful
to detect problematic files in practice.

See also: https://jira.spotify.net/browse/GOL-1210
---
 libavformat/avio.h    |  7 +++++++
 libavformat/aviobuf.c | 11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index ebf611187d..83cfee4f66 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -304,6 +304,13 @@ typedef struct AVIOContext {
      * Read-only statistic of bytes written for this AVIOContext.
      */
     int64_t bytes_written;
+
+    /**
+     * Read-only statistic of calls to avio_seek() for this AVIOContext.
+     * (Note: depending on buffer sizes and short-seek avoidance, this may
+     * or may not seek in the underlying I/O object.)
+     */
+    int64_t avio_seek_count;
 } AVIOContext;
 
 /**
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 6a74c1ce68..c64079e1f0 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -228,7 +228,7 @@ void avio_flush(AVIOContext *s)
         avio_seek(s, seekback, SEEK_CUR);
 }
 
-int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
+static int64_t avio_seek_internal(AVIOContext *s, int64_t offset, int whence)
 {
     FFIOContext *const ctx = ffiocontext(s);
     int64_t offset1;
@@ -295,7 +295,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
         s->pos = pos;
         s->eof_reached = 0;
         fill_buffer(s);
-        return avio_seek(s, offset, SEEK_SET | force);
+        return avio_seek_internal(s, offset, SEEK_SET | force);
     } else {
         int64_t res;
         if (s->write_flag) {
@@ -315,6 +315,13 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
     return offset;
 }
 
+int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) {
+  if (s) {
+    s->avio_seek_count++;
+  }
+  return avio_seek_internal(s, offset, whence);
+}
+
 int64_t avio_skip(AVIOContext *s, int64_t offset)
 {
     return avio_seek(s, offset, SEEK_CUR);
-- 
2.39.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to