Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldHnS-0003Xj-NL for pgsql-general@arkaria.postgresql.org; Sun, 02 May 2021 19:30:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ldHnQ-0007Jm-5d for pgsql-general@arkaria.postgresql.org; Sun, 02 May 2021 19:30:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldHnP-0007Jf-Tu for pgsql-general@lists.postgresql.org; Sun, 02 May 2021 19:30:27 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldHnI-0003u6-NK for pgsql-general@lists.postgresql.org; Sun, 02 May 2021 19:30:27 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id BC7574A87; Sun, 2 May 2021 21:30:18 +0200 (CEST) Date: Sun, 2 May 2021 21:30:18 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL, Asynchronous I/O, Buffered I/O and why did fsync-gate not affect Oracle or MySQL? Message-ID: <20210502193018.GA6136@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MGYHOYXEY6WxJCY8" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --MGYHOYXEY6WxJCY8 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-05-02 14:46:41 +0100, P=F3l Ua Lao=EDnech=E1in wrote: > Now, I'm not quite sure that I completely comprehend matters: Is there > a difference between Asynchronous I/O and Buffered I/O? Yes. Buffered I/O means that there is a buffer (or maybe several layers of buffers) between the application and the device: A read request might return data which has been cached from a previous read request without touching the device. And a write request will return as soon as the data is written to the buffer (it will be written to the device at some later time). The opposite of buffered I/O is direct I/O, which always talks directly to the device and doesn't use any buffers. Asynchronous I/O refers to a different programming model: Any read or write request only initiates the data transfer and returns immediately. The application will later be notified when the request is finished. This is very different from the traditional (in Unix) synchronous programming model where a read would block until the data was actually available and a write would block until the data was safely transferred to the OS's buffer cache (and can be overwritten by the application). In theory all four combinations (buffered synchronous, buffered asynchronous, direct synchronous, direct asynchronous) are possible, but some OS's may not implement all of them. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --MGYHOYXEY6WxJCY8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmCO/cUACgkQ8g5IURL+ KF0wsw//eik8Um8R6KXfnX4zpofLsl8TDTJVNFARtf8YmnjYTFr7t+11WpZkusJ1 OFjK55Lh+tOqK//J+CkNvt4ZVI8htt7+2hKywRlJ2F4cr6eHZOLth9Mk09auCbEW YHM5SiY+jpacazG0uAPQCmhhG1B9OErdGukWjZbtTBPUxZsWb2RTLlajsaATXObc kAF6bB+8mT7bSpHhNoINXCXt3zxYvUgYrSwE+6aGBH4AiXWrZly9DxIWEGclBLQI syFH56GmmO95oK5JCyNZP9ZSxFESBS1mxu7ti6f1VVeRkNQGxpnNVdVu/JjEXmDR Z3zg0rYnBjghYn7h3xEmZHSmtQV7FkzOG0Zx/bGUoh+Gzfc4blaxaowBgW5wAl9V 4KTa6l/HMO7+wjixZr6BrdqbLbnSsAIDSFvkMg3+1YvHbh5TBOJOg8SiuWbTgXBK L7UzKLVzDIkhqm6PECkEQzZvSR/9pSXMVfQPeARLNFPBZB+g9X70S6jc/7vs0YhI xCNlCwSvRb9E+HYU3wTmf5wPI1IQN4i85ZCmoJ4deeZ1kzvjGZ5eqr6ViS9S2wFl KlmeUc28YJLnNpglkUd6gGfM7tA5asNxjw97MTsJcQuNvcKMFtDUkCmsupvZKDtr 0QJHijx8VnhB2lWd1O518vL2OexgOHh8mh1p2CHMRDFixm7OTlo= =299I -----END PGP SIGNATURE----- --MGYHOYXEY6WxJCY8--