From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 746B93858C2D for ; Mon, 20 Nov 2023 16:30:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 746B93858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 746B93858C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700497836; cv=none; b=ssaG8YEwVbIPxvE6c/N02XikAaaCZjqvTVqiy5CoFiUJ/ugnuA1K1xWA60cilCoaHbsTQI4J2RY1ifUOsNKb9kNSl65zHZTrZEbMTsHo0k2o6AjAi3Oyzs+6htbeAAt3dqUT1ZmV1LmvoZV8tB3/pbTQKkf022M60Vx6X1FzJkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700497836; c=relaxed/simple; bh=9xbBxZW4m/chh2mgcXSRyzLLyy8eeLMk8MC7ENftEHs=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=C2kd13uYQvXi1oLLw/VAHYY0Mx3TuYgv764/Ugno8ucvUkgiI2umu1PupT7BtOxi+uqN3CwQNXCHKmtWfSQEd4GkWY7C9bZ9PMFZYSNbW/706F+t1rK9043/m+l+o7MEfEumlNKpf2A2DUGrMtQ8eGa28d55vl4es3uIbN260l4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.10.3.121] (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTPS id BB49D40737CD; Mon, 20 Nov 2023 16:30:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru BB49D40737CD Date: Mon, 20 Nov 2023 19:30:33 +0300 (MSK) From: Alexander Monakov To: Maxim Kuvyrkov cc: GCC Patches , Bernd Schmidt , Vladimir Makarov , Jeff Law Subject: Re: [PATCH 1/1] sched-deps.cc (find_modifiable_mems): Avoid exponential behavior In-Reply-To: Message-ID: References: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> <20231120120649.672893-2-maxim.kuvyrkov@linaro.org> <8587bddb-e348-a637-2fe2-8318bb09b3be@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 20 Nov 2023, Maxim Kuvyrkov wrote: > > On Nov 20, 2023, at 17:52, Alexander Monakov wrote: > > > > > > On Mon, 20 Nov 2023, Maxim Kuvyrkov wrote: > > > >> This patch avoids sched-deps.cc:find_inc() creating exponential number > >> of dependencies, which become memory and compilation time hogs. > >> Consider example (simplified from PR96388) ... > >> === > >> sp=sp-4 // sp_insnA > >> mem_insnA1[sp+A1] > >> ... > >> mem_insnAN[sp+AN] > >> sp=sp-4 // sp_insnB > >> mem_insnB1[sp+B1] > >> ... > >> mem_insnBM[sp+BM] > >> === > >> ... in this example find_modifiable_mems() will arrange for mem_insnA* > >> to be able to pass sp_insnA, and, while doing this, will create > >> dependencies between all mem_insnA*s and sp_insnB -- because sp_insnB > >> is a consumer of sp_insnA. After this sp_insnB will have N new > >> backward dependencies. > >> Then find_modifiable_mems() gets to mem_insnB*s and starts to create > >> N new dependencies for _every_ mem_insnB*. This gets us N*M new > >> dependencies. > > [For avoidance of doubt, below discussion is about the general implementation > of find_modifiable_mems() and not about the patch.] I was saying the commit message is hard to read (unless it's just me). > > It's a bit hard to read this without knowing which value of 'backwards' > > is assumed. > > > > Say 'backwards' is true and we are inspecting producer sp_insnB of mem_insnB1. > > This is a true dependency. We know we can break it by adjusting B1 by -4, but > > we need to be careful not to move such modified mem_insnB1 above sp_insnA, so > > we need to iterate over *incoming true dependencies* of sp_insnB and add them. > > > > But the code seems to be iterating over *all incoming dependencies*, so it > > will e.g. take anti-dependency mem_insnA1 -> sp_insnB and create a true > > dependency mem_insnA1 -> mem_insnB1'. This seems utterly inefficient, if my > > understanding is correct. > > Yeap, your understanding is correct. However, this is what > find_modifiable_mems() has to do to avoid complicated analysis of second-level > dependencies. What is the reason it cannot simply skip anti-dependencies in the 'if (backwards)' loop, and true dependencies in the 'else' loop? Alexander