From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 260094C857 for <ffmpegdev@gitmailbox.com>; Wed, 9 Apr 2025 16:56:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F36EC68BF01; Wed, 9 Apr 2025 19:56:18 +0300 (EEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2FE5068BCE2 for <ffmpeg-devel@ffmpeg.org>; Wed, 9 Apr 2025 19:56:12 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6FFD542E79 for <ffmpeg-devel@ffmpeg.org>; Wed, 9 Apr 2025 16:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1744217771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2/MWgvukO4Z8AF1Cx1vaI3WF8jqacIcb9T71IACEFrc=; b=JL8HOXVp6YmljfBtvs19fFRYKlzvQwQHwzO8mCKZg6N/Qgp+Opmj+r8ZB8CwV0oCJ1uuwH bR3VsoJVYyqjuX0cCteghC8aI33xLeV/rgpXDoRvW1HDY6YRijc1pGdfIWOVz1SuCDDt21 3OOdn74c6lpuyWvlc4zN55CR70y3InAD4F+nVZUI6RBFIn6W+nFjh8d/93VeauYJwou6cC tGxS0xHO0JhYHUM9deWKreflQJnOOQrvJSerdPQIUUNKEMYfwumvEqj6v+MdNDSdr1odco NuisxuMNX1kKAjN7CKQvGNrxg7Wt7G6EJ+GvcQRkqsUMpzSHEMyaZTVcJcwXSw== Date: Wed, 9 Apr 2025 18:56:10 +0200 From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Message-ID: <20250409165610.GY4991@pb2> References: <20250408101959.GP4991@pb2> <378b18ff-4a2d-4852-8671-2330d2ba0f99@gmail.com> MIME-Version: 1.0 In-Reply-To: <378b18ff-4a2d-4852-8671-2330d2ba0f99@gmail.com> X-GND-State: clean X-GND-Score: -70 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvtdeiheegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdeftddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpeeigeektdejudffjefhteegjedtgeettefggedthfejgfevhfetgeekjedtvdfhveenucfkphepgedurdeiiedrieejrdduudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieejrdduudefpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [RFC] AVDictionary2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Content-Type: multipart/mixed; boundary="===============7629312441073573220==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250409165610.GY4991@pb2/> List-Archive: <https://master.gitmailbox.com/ffmpegdev/> List-Post: <mailto:ffmpegdev@gitmailbox.com> --===============7629312441073573220== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="x3Byf4CQYwAbVbzl" Content-Disposition: inline --x3Byf4CQYwAbVbzl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 08, 2025 at 08:00:20PM -0400, Leo Izen wrote: > On 4/8/25 06:19, Michael Niedermayer wrote: > > Hi all > >=20 > > As i have too many things to do already i did the most logic thing and > > started thinking about a new and unrelated idea. > >=20 > > This is a list of problems and ideas, that everyone is welcome to add t= o and > > comment on. > >=20 > > AVDictionary is just bad. > >=20 > > * its complicated internally with > > unneeded alternative (AV_DICT_DONT_STRDUP_VAL/KEY) these are rarely = used > > and probably not relevant for performance. > >=20 >=20 > As far as I'm aware the main purpose of AV_DICT_DONT_STRDUP is to transfer > ownership to the dictionary to save a call to malloc/free. If I construct= a > string e.g. with av_bprint API, and then I want to pass it as a value to = an > AVDictionary *, then without access to AV_DICT_DONT_STRDUP_VAL as an opti= on, > I will then have to free it. >=20 > Since your goal is to avoid malloc/free calls I feel like this is a > reasonable interface to continue to support. git grep av_dict_set | wc is 690 git grep AV_DICT_DONT_STRDUP | wc is 87 git grep AV_DICT_DONT_STRDUP libavutil/ tests doc | wc is 20 We thus have 67 cases using one of the AV_DICT_DONT_STRDUP and ~ 623 which do not and we need 2*623 mallocs and 623 + 67 reallocs ATM (not counting the ones outside av_dict_set()) teh proposed system would use 623 + 67 mallocs and 67 free and log2(623 + 67) realloc. (or less if one used a single array) It also could potentially avoid some of teh mallocs done outside that just get freed then inside now if you continue or not continue to support AV_DICT_DONT_STRDUP doesnt change anything. The 2 externally allocated strings are not in the right format and need to be freed. And even with freeing its fewer mallocs (as shown above) also the implied minimum allocation from AV_DICT_DONT_STRDUP is 2 per call, we only need 1 with no extra complexity. Just dont allocate 2 seperate arrays, use 1 as a bonus its also 1 pointer less and 1 free less thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is wrong. --x3Byf4CQYwAbVbzl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZ/ampwAKCRBhHseHBAsP q5EwAJ0apnGfp/aIFgVFcj9QVkeHasRnxACfRYkFkQluxGPVDu/FalKrsuSRIEU= =NhGi -----END PGP SIGNATURE----- --x3Byf4CQYwAbVbzl-- --===============7629312441073573220== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============7629312441073573220==--