From patchwork Sun Mar 14 04:54:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andriy Gelman X-Patchwork-Id: 26391 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 396D7443740 for ; Sun, 14 Mar 2021 07:01:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1067668AD1C; Sun, 14 Mar 2021 07:01:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 72B9668799C for ; Sun, 14 Mar 2021 07:01:05 +0200 (EET) Received: by mail-qk1-f177.google.com with SMTP id f124so28632390qkj.5 for ; Sat, 13 Mar 2021 21:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xGari35dxmtiNRNZjHB6j6k2htzuhiIrIALloRolxno=; b=TG1Yvqkgk3oO2idd8SfW/8TfTcZZNShpN9YTbejJPAG9DloMynqaQmftmfCZwda9im 3Qu/khA4E080jv+PeOBNVMFthYy71rraUmvdGI8VZiBywl+Ld6lEncGyu0YhgEbaHgy7 gBw5Hpnk0DY9ER4cpNsevp5+8etKiVzqPrJ8piCjVnjVdZ3tDTb0dZB/8Vl5mTBebR75 9aEoa49VABR77x70997amQvveBGxtua2cI9Hgu0N7qUaQqlC+DeV0yEriLFsc1WAK4cn bihkrHkTLUTTP5/e9MzVAifoKHAMTgzE2/0oRBEVZRvx6s2SV25sFHBxuCfc73Ip3hyc V/rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xGari35dxmtiNRNZjHB6j6k2htzuhiIrIALloRolxno=; b=WUJa8ZDgSzTCK6Nal8tHdBL0HMuyhXzAgTFbmoq3S2kUUHJee9I8WgFojzs+Jg+4X+ /9X1FtDSa6qDyGUU55TLwwBMazBV4GLK02Vc482TvgQwZls6y42P694fAqRZ3atkrPKP RIAdVD8c416G/wkjluO0EmxTEju3d5kVQiJlrTTyWWtk7zL4zzLNkfvyz4m4PV8O6s/j YzIarq9zgNX1SFfs96VBno8VXTrCZp63yRD0iVVOAYBl1/2pk5W7Enh3APPQfX0ZRn14 7Yo8Xr/Y/kEZG6+MJmq28YLmg99sjTtGHLJwLH3xflE9cnkbt1eSZmskc/yF32ZV5c8K HFlA== X-Gm-Message-State: AOAM531mRu+MY6dcTRGgAcTh2Xtf5YK+Yc5+qDAYlrXhCK1mWGm2LM2B PqKCX6Zasi0XDBv7dBJMUSmRD1W6gcs= X-Google-Smtp-Source: ABdhPJxoJRRs5z1vwYBdcN92Ny65b+B69nNr33XsKhjVkgPtB70T3bkGJJWQmMBrRCorJsnXsB4ROg== X-Received: by 2002:a37:396:: with SMTP id 144mr19216792qkd.412.1615697688156; Sat, 13 Mar 2021 20:54:48 -0800 (PST) Received: from localhost.localdomain (c-73-149-98-40.hsd1.ma.comcast.net. [73.149.98.40]) by smtp.gmail.com with ESMTPSA id l4sm7439046qte.64.2021.03.13.20.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 20:54:47 -0800 (PST) From: Andriy Gelman X-Google-Original-From: Andriy Gelman To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Mar 2021 23:54:32 -0500 Message-Id: <20210314045432.214832-1-andriy.gelman@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/aviobuf: don't reduce short seek threshold X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andriy Gelman Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Andriy Gelman Commit 8c8e5d5286bf598a89ef9993a2cf6ea409d03a32 added a way to reduce seek time by waiting for the windowed tcp packets instead of creating a new socket connection. It implemented this by overwriting s->short_seek_threshold in the avio_seek(). However, s->short_seek_threshold could already be set and be higher than the threshold set by the protocol (i.e. s->short_seek_threshold is set in ff_configure_buffers_for_index()). This new feature was only enabled for tls connections in 70d8077b795766e2486e6ec8110f22a97362d6d7. As in Ticket #9148 it reduced performance because instead of waiting to refill the AVIOContext buffers with an existing connections, a new HTTP request was often made instead. Fixes Ticket #9148. Signed-off-by: Andriy Gelman --- libavformat/aviobuf.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 78cc60b2ae..518cb11129 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -283,13 +283,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) if (offset < 0) return AVERROR(EINVAL); - if (s->short_seek_get) { - short_seek = s->short_seek_get(s->opaque); - /* fallback to default short seek */ - if (short_seek <= 0) - short_seek = s->short_seek_threshold; - } else - short_seek = s->short_seek_threshold; + short_seek = s->short_seek_threshold; + if (s->short_seek_get) + short_seek = FFMAX(s->short_seek_get(s->opaque), short_seek); offset1 = offset - pos; // "offset1" is the relative offset from the beginning of s->buffer s->buf_ptr_max = FFMAX(s->buf_ptr_max, s->buf_ptr);