Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cW5oV-0001Xh-CH for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jan 2017 18:27:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cW5oU-00040C-Vf for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jan 2017 18:27:27 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cW5n3-0001Ck-ML for pgsql-hackers@postgresql.org; Tue, 24 Jan 2017 18:25:57 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cW5n0-00072T-Ju for pgsql-hackers@postgresql.org; Tue, 24 Jan 2017 18:25:57 +0000 Received: by mail-wm0-x242.google.com with SMTP id c85so36448787wmi.1 for ; Tue, 24 Jan 2017 10:25:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=KKMWVX1VVPOqCnUAJlfVujDMaVAflDYwbTv4vhCNaug=; b=LrknZyXgICoM4XCfNPZ9QMnO9qZWUAG/sMis35g05NSCDJIcsbPiev/lX6TIEbkvBz /BxqoU96raXXYgzoyqxpFN65g9ZmC2z29AxSelQBwEgqXBAChI+Nv7xIJr4S9jpitd16 47yQcC352r8E33SNIIAC7gIk2k+JnGTNkaGK65NgunZdM8oMVC5aXzthozuxL+pGc36Q vG65C0uQe4o81UCafE56VMqOBtxD4QanJoWpv/fw+8wzqKugM8Aq6qSaTPC90G2Z6pbS chJxgjkOuXOCW3wBdsBaqGwBE2NOjEbIX2SierhOQ5jqfYsx4O8j0mmdo+HgqFJTQfyF HY5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=KKMWVX1VVPOqCnUAJlfVujDMaVAflDYwbTv4vhCNaug=; b=OjF4KwyPOet4TfqQK31aE5/MJFF2oWtCWF0LsJaw8PN7I8jyBsMAEQ2WwYRgHYUWbf vP/TUSPTtQ9aiHoQXpLtNBzcbRacCrNifQrqY/DjRbhMmo9uMUTlrw69w7p1r/aOIHbP CcTLirNIWZBqHHUF/6KIfJxpiOaicQLD8hDG3aWmjuLqnJqUydkPMCFEab+vpYyE2+Tn rXsz++61940fRA6AUhAJUArN0/5DZ6d1k+/EnUur4Ayywrb4q6gzut9jsqqf9hPwtwJw /IKJDeLsXOBqRZ429+gaqPsnratFmdFYIaa+ZDpDUhp4BTh0SXBLPrIZLAZSPuOmmsP2 aayg== X-Gm-Message-State: AIkVDXJ5pOZ+ZKnf45VQ82DEeF3mcOeoxFuIPeGoX6wvHtm3mjJkorUHa/etVq3rrHggsQ== X-Received: by 10.223.154.132 with SMTP id a4mr29332438wrc.188.1485282353782; Tue, 24 Jan 2017 10:25:53 -0800 (PST) Received: from [192.168.1.211] (ppp-93-104-181-116.dynamic.mnet-online.de. [93.104.181.116]) by smtp.googlemail.com with ESMTPSA id t123sm3425679wmt.8.2017.01.24.10.25.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 10:25:53 -0800 (PST) Subject: Re: lseek/read/write overhead becomes visible at scale .. To: Andres Freund References: <20170124171841.2n2nzqkuetbivzta@alap3.anarazel.de> <20170124174158.nk6htg7jjmqia7hr@alap3.anarazel.de> <422b4e6c-b7f0-90e0-6f70-389b2d50a848@gmail.com> <20170124181121.pgk7kqfkq4dd3hpo@alap3.anarazel.de> Cc: pgsql-hackers@postgresql.org From: Tobias Oberstein Message-ID: Date: Tue, 24 Jan 2017 19:25:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170124181121.pgk7kqfkq4dd3hpo@alap3.anarazel.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi, >> pid | syscall | cnt | cnt_per_sec >> -----+---------------------------------------+---------+------------- >> | syscalls:sys_enter_lseek | 4091584 | 136386 >> | syscalls:sys_enter_newfstat | 2054988 | 68500 >> | syscalls:sys_enter_read | 767990 | 25600 >> | syscalls:sys_enter_close | 503803 | 16793 >> | syscalls:sys_enter_newstat | 434080 | 14469 >> | syscalls:sys_enter_open | 380382 | 12679 >> >> Note: there isn't a lot of load currently (this is from production). > > That doesn't really mean that much - sure it shows that lseek is > frequent, but it doesn't tell you how much impact this has to the Above is on a mostly idle system ("idle" for our loads) .. when things get hot, lseek calls can reach into the millions/sec. Doing 5 million syscalls per sec comes with overhead no matter how lightweight the syscall is, doesn't it? Using pread instead of lseek+read halfes the syscalls. I really don't understand what you are fighting here .. > overall workload. For that'd you'd need a generic (i.e. not syscall > tracepoint, but cpu cycle) perf profile, and look in the call graph (via > perf report --children) how much of that is below the lseek syscall. I see. I might find time to extend our helper function f_perf_syscalls. >>>>> I'm much less against this change than Tom, but doing artificial syscall >>>>> microbenchmark seems unlikely to make a big case for using it in >>>> >>>> This isn't a syscall benchmark, but FIO. >>> >>> There's not really a difference between those, when you use fio to >>> benchmark seek vs pseek. >> >> Sorry, I don't understand what you are talking about. > > Fio as you appear to have used is a microbenchmark benchmarking > individual syscalls. I am benchmarking IOPS, and while doing so, it becomes apparent that at these scales it does matter _how_ IO is done. The most efficient way is libaio. I get 9.7 million/sec IOPS with low CPU load. Using any synchronous IO engine is slower and produces higher load. I do understand that switching to libaio isn't going to fly for PG (completely different approach). But doing pread instead of lseek+read seems simple enough. But then, I don't know about the PG codebase .. Among the synchronous methods of doing IO, psync is much better than sync. pvsync, pvsync2 and pvsync2 + hipri (busy polling, no interrupts) are better, but the gain is smaller, and all of them are inferior to libaio. >>> Glad to hear it. >> >> With 3TB RAM, huge pages is absolutely essential (otherwise, the system bogs >> down in TLB etc overhead). > > I was one of the people working on adding hugepage support to pg, that's > why I was glad ;) Ahh;) Sorry, wasn't aware. This is really invaluable. Thanks for that! Cheers, /Tobias -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers