Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UKDhN-0004Tw-Iq for pgsql-performance@arkaria.postgresql.org; Mon, 25 Mar 2013 20:08:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UKDhM-0004rU-Ub for pgsql-performance@arkaria.postgresql.org; Mon, 25 Mar 2013 20:08:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UKDhL-0004rO-JB for pgsql-performance@postgresql.org; Mon, 25 Mar 2013 20:08:51 +0000 Received: from mail-ea0-x22f.google.com ([2a00:1450:4013:c01::22f]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UKDh8-0000Xc-VH for pgsql-performance@postgresql.org; Mon, 25 Mar 2013 20:08:50 +0000 Received: by mail-ea0-f175.google.com with SMTP id o10so2505899eaj.6 for ; Mon, 25 Mar 2013 13:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:content-type:content-transfer-encoding:subject :message-id:date:to:mime-version:x-mailer; bh=3BHMTcycat6neuf9bU0Y6qB+DVxZUlvSceVRK7przYU=; b=VgwYYDdZJNtRxWVh150/u4HUSaVVctPmoLBd2a6CX9pxA1OMWJqHLqYYb7u7+q8u/3 vUBQXSE1Z+6I5jx8n9cReiKw+Khtngt2LpVnlGa0vZz7NWM7Wg+ow7sTfKXK0a4Szj4x dr1gaHkJyTSZXJCPfOvk7rCiJzoa9hz2qtrnDhkTNQT2abiNd3l1/d8Fnsv4suipYQSp 0lxOdEPSton8erj4BicP78tlNxAv9oFPMyMtb+fAofL8c7wOgR3Sb7yfyZ+YA0kcZ3om 5g9k1ZtmpJeS4q3nbGTRYocPrVY32sBaS62PHdq+Mlz1KKR7qd0ZXuC+rPW2KmoW3Esk mczw== X-Received: by 10.14.210.132 with SMTP id u4mr37188398eeo.19.1364242117662; Mon, 25 Mar 2013 13:08:37 -0700 (PDT) Received: from [10.0.6.11] (cpc9-bele8-2-0-cust225.2-1.cable.virginmedia.com. [86.12.10.226]) by mx.google.com with ESMTPS id ca4sm21090138eeb.15.2013.03.25.13.08.35 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:36 -0700 (PDT) From: Greg Jaskiewicz Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Proof of concept: Evolving postgresql.conf using genetic algorithm Message-Id: <5624E065-0C4B-4971-AD4E-4ECBF9B313E6@gmail.com> Date: Mon, 25 Mar 2013 20:08:39 +0000 To: pgsql-performance@postgresql.org Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) X-Mailer: Apple Mail (2.1503) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org (following the interest from -hackers, I'm posting this here).=20 Hi folks,=20 I've always been fascinated with genetic algorithms. Having had a chance to= implement it once before, to solve real life issue - I knew they can be br= illiant at searching for right solutions in multi dimensional space. Thinking about just the postgresql.conf and number of possible options ther= e to satisfy performance needs - I thought, this does sound like a good exa= mple of problem that can be solved using genetic algorithm.=20 So I sat down after work for few days, and came up with a simple proof of c= oncept. It generates random population of postgresql configuration files, and runs = simple pgbench test on each one of them. It takes the average TPS for 3 con= secutive runs as the score that then is applied to each 'guy'.=20 Then I run a typical - I suppose - cross over operation and slight mutation= of each new chromosome - to come up with new population, and so on and so = forth.=20 Running this for 2 days - I came up to conclusion that it does indeed seem = to work, although default pgbench 'test cases' are not really stressing the= database enough for it to generate diverse enough populations each time.= =20 Also, ideally this sort of thing should be run on two or more different hos= ts. One (master) that just generates new configurations, saves, restores, m= anages the whole operation - and 'slave' host(s) that run the actual tests. One benefit of that would be the fact that genetic algorithms are highly pa= rallelizable.=20 I did reboot my machines after tests couple times, to test configuration fi= les and to see if the results were in fact repeatable (as much as they can = be) - and I have to say, to my surprise - they were. I.e. the configuration= files with poor results were still obviously slower then the best ones. I did include my sample results for everyone to see, including nice spreads= heet with graphs (everyone loves graphs) showing the scores across all popu= lations. The tests were ran on my mac laptops (don=92t have access to bunch of serve= rs that I can test things like that on for couple days, sorry). The project, including readme file is available to look at: https://github.= com/waniek/genpostgresql.conf Things I know so far: * I probably need to take into account more configuration options; * pgbench with its default test case is not the right characterization suit= e for this exercise, I need something more life like. I suppose we all have= some sort of a characterization suite that could be used here; * Code needs a lot work on it, if this was to be used professionally; * Just restarting postgresql with different configuration file doesn't real= ly constitute fully proper way to test new configuration files, but it seem= to work; I don't expect much out of this - after all this is just a proof of concept= . But if there are people out there thinking this can be in any way useful = - please give us a shout.=20 Also, if you know something more about genetic algorithms then I do - and c= an suggest improvement - let me know. Lastly, I'm looking for some more sophisticated pgbench test cases that I c= ould throw in at it. I think in general pgbench as a project could use some= more sophisticated benchmarks that should be included with the project, fo= r everyone to see. Perhaps even to run some automated regression tests agai= nst git head.=20 --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance