Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7tsr-0003Sl-Hv for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Mar 2019 03:33:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h7tsq-0001mM-52 for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Mar 2019 03:33:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7tsp-0001mF-U7 for pgsql-hackers@lists.postgresql.org; Sun, 24 Mar 2019 03:33:15 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7tsi-00025K-F9 for pgsql-hackers@lists.postgresql.org; Sun, 24 Mar 2019 03:33:15 +0000 Received: by mail-wr1-x441.google.com with SMTP id g3so2891765wrx.9 for ; Sat, 23 Mar 2019 20:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pzi5KoIP50fKVg+UYGuOVqdNzMMneH8LZP211i5uy/Y=; b=zdfXUOIzDbrfn4KgWWAE75Bs3qGWvgE2WFMxJW/snB66K4uu4P+3JDPsKD0X+zqur4 y9ao5JPVPAdRVIX30IWkPNb5OMCjuMabyVTS7tTtQbmWDQfb/5SyG9C9ZI7bFUTB6dlQ yjWImqucy3RV7PILC1APVqeXiA1trKhnVeY+zQe8q/QFpxRXwOOaBD8kk7ii6ZDXkoFk BtfGTOTw9pMnhRCBqbhWONXt7wyUkVUctnG3rs5XCZZvPXXGm42+IcmLCXwGbfwH3w8m csfV8wC2iq5ZzKbfZmrRhRP0W6CrLBUgHDIGMOG8adYgNytOnB1eDtBcihsh093R4uC6 7Xsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pzi5KoIP50fKVg+UYGuOVqdNzMMneH8LZP211i5uy/Y=; b=IW+m+JuVv858nmPiZEZaigmaSBls9pDlK1JZXYaSl1UZvSllUMdRlqIjNuLkVEwhrf PuHyAjxBneu9iVIH8J+xdDU6ea+nNsn4nRZF+YPxltNGGukDlDOsf1SM8u/ANEryxZOC Jd/nhEaiv7ce92Kq2ypp2ivCjb5lkAGNMP5Aa7TiFDBXSkyjgtmKJ4v8NpcnpMIaPdg+ bNDv88/rtK9RMRnmQREp+3QulXDkt1VWurICJvgUpLYZfKc8XXaWwp+YytIVnvWhpgqX SgownfgS4jPR9m1xbv5s7NIQEqW6gtYWEhPCH8vgXd0ejxAqazPZO5BH+svbJwK1OYZk /MCg== X-Gm-Message-State: APjAAAXe31830GwbytBxN9anXEL9VydJJXLHISXni/goeeuHZ6ge6pbb RPdDenn9BcUChjde2PNKqVkjTw== X-Google-Smtp-Source: APXvYqzsdnLgeYLPaAgiylEiZC397wJFIiavDZHD0DCiKTtEKc93l6FSIULiLe/c1+Wngzh3Y2rZDg== X-Received: by 2002:a5d:6a89:: with SMTP id s9mr11915212wru.58.1553398387410; Sat, 23 Mar 2019 20:33:07 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id o63sm13292489wmo.46.2019.03.23.20.33.06 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sat, 23 Mar 2019 20:33:06 -0700 (PDT) Subject: Re: CPU costs of random_zipfian in pgbench To: Fabien COELHO , Tom Lane Cc: Georgios Kokolatos , PostgreSQL Developers , Fabien Coelho References: <155246731010.16480.15850913449923768119.pgcf@coridan.postgresql.org> <3703.1553360483@sss.pgh.pa.us> From: Tomas Vondra Message-ID: <010a884f-8ffc-4cb7-9773-fd05f32ef4cc@2ndquadrant.com> Date: Sun, 24 Mar 2019 04:33:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/23/19 6:44 PM, Fabien COELHO wrote: > > Hello Tom, > >> I started to look through this, and the more I looked the more unhappy >> I got that we're having this discussion at all.  The zipfian support >> in pgbench is seriously over-engineered and under-documented.  As an >> example, I was flabbergasted to find out that the end-of-run summary >> statistics now include this: >> >>    /* Report zipfian cache overflow */ >>    for (i = 0; i < nthreads; i++) >>    { >>        totalCacheOverflows += threads[i].zipf_cache.overflowCount; >>    } >>    if (totalCacheOverflows > 0) >>    { >>        printf("zipfian cache array overflowed %d time(s)\n", >> totalCacheOverflows); >>    } >> >> What is the point of that, and if there is a point, why is it nowhere >> mentioned in pgbench.sgml? > > Indeed, there should. > >> What would a user do with this information, and how would they know >> what to do? > > Sure, but it was unclear what to do. Extending the cache to avoid that > would look like over-engineering. > That seems like a rather strange argument. What exactly is so complex on resizing the cache to quality as over-engineering? If the choice is between reporting the failure to the user, and addressing the failure, surely the latter would be the default option? Particularly if the user can't really address the issue easily (recompiling psql is not very practical solution). >> I remain of the opinion that we ought to simply rip out support for >> zipfian with s < 1. > +1 to that > Some people really want zipfian because it reflects their data access > pattern, possibly with s < 1. > > We cannot helpt it: real life seems zipfianly distributed:-) > Sure. But that hardly means we ought to provide algorithms that we know are not suitable for benchmarking tools, which I'd argue is this case. Also, we have two algorithms for generating zipfian distributions. Why wouldn't it be sufficient to keep just one of them? >> It's not useful for benchmarking purposes to have a random-number >> function with such poor computational properties. > > This is mostly a startup cost, the generation cost when a bench is > running is reasonable. How to best implement the precomputation is an > open question. > ... which means it's not a startup cost. IMHO this simply shows pgbench does not have the necessary infrastructure to provide this feature. > As a reviewer I was not thrilled by the cache stuff, but I had no better > idea that would not fall under "over-over engineering" or the like. > > Maybe it could error out and say "recompile me", but then someone > would have said "that is unacceptable". > > Maybe it could auto extend the cache, but that is still more unnecessary > over-engineering, IMHO. > I'm puzzled. Why would that be over-engineering? > Maybe a there could be some mandatory declarations or partial eval that > could precompute the needed parameters out/before the bench is started, > with a clear message "precomputing stuff...", but that would be over > over over engineering again... and that would mean restricting > random_zipfian parameters to near-constants, which would require some > explaining, but maybe it is an option. I guess that in the paper > original context, the parameters (s & n) are known before the bench is > started, so that the needed value are computed offline once and for all. > >> I think leaving it in there is just a foot-gun: we'd be a lot better >> off throwing an error that tells people to use some other distribution. > > When s < 1, the startup cost is indeed a pain. However, it is a pain > prescribed by a Turing Award. > Then we shouldn't have it, probably. Or we should at least implement a proper startup phase, so that the costly precomputation is not included in the test interval. >> Or if we do leave it in there, we for sure have to have documentation >> that *actually* explains how to use it, which this patch still doesn't. > > I'm not sure what explaining there could be about how to use it: one > calls the function to obtain pseudo-random integers with the desired > distribution? > Well, I'd argue the current description "performance is poor" is not particularly clear. >> There's nothing suggesting that you'd better not use a large number of >> different (n,s) combinations. > > Indeed, there is no caveat about this point, as noted above. > > Please find an updated patch for the documentation, pointing out the > existence of the cache and an advice not to overdo it. > > It does not solve the underlying problem which raised your complaint, > but at least it is documented. > I think you forgot to attache the patch ... regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services