From owner-freebsd-current@freebsd.org Thu Nov 24 13:15:25 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5786C51FAB; Thu, 24 Nov 2016 13:15:25 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0D4DF157; Thu, 24 Nov 2016 13:15:25 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id D521E1FE024; Thu, 24 Nov 2016 14:15:22 +0100 (CET) Subject: Re: Optimising generated rules for SAT solving (5/12 are duplicates) To: Vsevolod Stakhov , Ed Schouten References: <20150414200459.GE39658@ivaldir.etoilebsd.net> <20150421103454.GR1394@zxy.spb.ru> <5593D0AE.2010205@selasky.org> <416359ce-1dcd-1160-5c56-f120a0f6358f@selasky.org> <20160627115533.gqvdsmtzwnvrrfuo@ivaldir.etoilebsd.net> <0671148b-d7cd-f8ad-906d-a0baa1b98cf5@selasky.org> <9b0469bb-ab2b-4992-1d40-de748163f2c8@selasky.org> <8c5cb2ea-54ab-c91b-5859-b6a73a2a7005@highsecure.ru> Cc: Baptiste Daroussin , Slawa Olhovchenkov , ports@freebsd.org, FreeBSD Current From: Hans Petter Selasky Message-ID: <6a81db90-40fa-ec5f-9402-333091c333f2@selasky.org> Date: Thu, 24 Nov 2016 14:15:06 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <8c5cb2ea-54ab-c91b-5859-b6a73a2a7005@highsecure.ru> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2016 13:15:25 -0000 On 11/24/16 14:11, Vsevolod Stakhov wrote: > On 24/11/2016 13:05, Hans Petter Selasky wrote: >> On 11/24/16 13:13, Vsevolod Stakhov wrote: >>> On 23/11/2016 16:27, Ed Schouten wrote: >>>> Hi Hans, >>>> >>>> 2016-11-23 15:27 GMT+01:00 Hans Petter Selasky : >>>>> I've made a patch to hopefully optimise SAT solving in our pkg utility. >>>> >>>> Nice! Do you by any chance have any numbers that show the performance >>>> improvements made by this change? Assuming that the SAT solver of >>>> pkg(1) uses an algorithm similar to DPLL[1], a change like this would >>>> affect performance linearly. My guess is therefore that the running >>>> time is reduced by approximately 5/12. Is this correct? >>> >>> There won't be any improvement if you just remove duplicates from SAT >>> formula. This situation is handled by picosat internally and even for >>> naive DPLL there is no significant influence of duplicate KNF clauses: >>> once you've assumed all vars in some clause, you automatically resolve >>> all duplicates. >>> >>> Is there any real improvement of SAT solver speed with this patch? From >>> my experiences, SAT solving is negligible in terms of CPU time comparing >>> to other tasks performed by pkg. >> >> Hi, >> >> I added some code to measure the time for SAT solving. During my test >> run I'm seeing values in the range 8-10ms for both versions, so I >> consider that neglible. However, the unpatched version wants to >> reinstall 185 packages while the non-patched version wants to reinstall >> 1 package. That has a huge time influential. I'm not that familar with >> PKG that I can draw any conclusions from this. >> >> # Test1: >> echo "n" | /xxx/pkg/src/pkg-static upgrade --no-repo-update > b.txt >> >> # Test2: >> echo "n" | env PKG_NO_SORT=YES /xxx/pkg/src/pkg-static upgrade >> --no-repo-update > a.txt >> > > Then I don't understand how your patch should affect the solving > procedure. If pkg tries to reinstall something without *reason* it is a > good sign of bug in pkg itself and/or your database/repo and not in SAT > solver. > > I'll try to review your issue but I'll likely need your local packages > database for this test. > Hi, Maybe it is a bug somewhere. I noticed some rules repeating the same variable two times for example. Send me the list of files you need off-list. Thank you! --HPS