- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
使用 POSIX 异步 I/O 时,使用 O_DIRECT
和 AIO_RAW
有什么区别吗?或者我应该/我可以同时使用两者吗?我们正在开发 NoSQL 数据库服务器,并正在寻找使异步 I/O 在 POSIX 系统上更高效的方法。
open(2) :
O_DIRECT Try to minimize cache effects of the I/O to and from this file. In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user space buffers.
aiocb(5) :
You may set the AIO_RAW flag bit in the aio_flags structure member when the asynchronous I/O is being done to a raw device partition. When the AIO_RAW flag bit is set, asynchronous I/O might possibly be more efficient.
最佳答案
提问者从未具体说明他们支持哪些操作系统(一个链接指向 Linux 手册页,另一个链接指向 SCO 手册页),因此很难在没有推测的情况下回答这个问题。
在撰写本文时,Linux 不支持 AIO_RAW
,因为 glibc 的 struct aiocb
没有 aio_flags
成员(https://www.gnu.org/software/libc/manual/html_node/Asynchronous-I_002fO.html ) 并且内核 AIO(不是 POSIX)不支持 AIO_RAW
值。所以:
are there any differences between using O_DIRECT and AIO_RAW? Or should I/can I use both?
是的,因为并非所有支持 POSIX AIO 的操作系统(例如 Linux)都允许您设置 AIO_RAW
,而且肯定会有您不能同时使用两者的情况。此外,在某些操作系统(例如 Linux)上,O_DIRECT
可以用于文件系统内部和设备上的文件,而 AIO_RAW
仅适用于“原始设备”。从 dt 源代码来看,AIO_RAW
似乎只在 HP-UX 和 SCO Unix 上受支持,因此它在其他操作系统上的使用可能有限。
关于c++ - O_DIRECT 与 AIO_RAW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15998294/
我正在运行一个支持 O_DIRECT 的 IO 密集型进程。有没有办法判断进程运行时是否使用了 O_DIRECT? 我尝试了“iostat -x 1”,但不确定哪个字段对我有帮助。 谢谢。 最佳答案
如果我用 O_DIRECT 打开文件标志,这是否意味着每当对该文件的写入(阻塞模式)返回时,数据都在磁盘上? 最佳答案 (此答案适用于 Linux - 其他操作系统可能有不同的警告/语义) 让我们从子
Apple LLVM 版本 10.0.0 (clang-1000.10.44.4) 目标:x86_64-apple-darwin18.0.0 #include #include #include
你能告诉我下面的代码有什么问题吗?由于某种原因,编译器拒绝识别 O_DIRECT 标志。 #define _GNU_SOURCE #include #include #include #incl
董事会介绍: 我正在开发一 block 带有 ST40 芯片的电路板,主要用于捕获 DVB 流并将其显示在电视上。该板在 Linux 操作系统上运行。 问题描述: 我正在尝试使用 O_DIRECT 标
open(2) 的手册页仅建议 O_DIRECT 绕过页面缓存,但网络上的许多描述将其描述为导致用户缓冲区直接通过 DMA 访问驱动器。如果是这种情况,我想它也会绕过文件系统(例如 xfs、ext4
我正在用 C 为 Linux 2.6.X 内核编写自定义数据库引擎,我需要知道对于使用 O_DIRECT 标志打开的文件的 write() 系统调用的最小写入大小是多少?在文档中说,自 linux 2
我想知道进程是否使用 O_DIRECT 打开了任何文件,但我只能在进程启动后检查它(即 strace 不是一个选项)。我试着查看/proc/$pid/fd/看看是否有任何有用的东西,但没有。我的目标是
使用 POSIX 异步 I/O 时,使用 O_DIRECT 和 AIO_RAW 有什么区别吗?或者我应该/我可以同时使用两者吗?我们正在开发 NoSQL 数据库服务器,并正在寻找使异步 I/O 在 P
我正在为 Linux 开发一个数据库引擎,我对通过对内核的一次系统调用写入多个 block 的一致性有疑问。我用 O_DIRECT 打开设备。 设备以 block 为单位写入数据,具体取决于硬件,它可
我有一个 C++ 程序,它使用 POSIX API 编写一个用 O_DIRECT 打开的文件。同时,另一个线程正在通过不同的文件描述符从同一个文件中读回。我注意到偶尔从文件中读回的数据包含全零,而不是
有一句著名的 Linus 名言,说 O_DIRECT 是无用的,甚至是 hell 。 如果一个人对速度有超强的需求,那么在 Linux 中真的没有合理使用这个标志来处理常规文件的场景吗? 编辑:日志文
假设我有一个执行以下操作的简单程序: fdWrite = open("file", O_WRONLY); fdRead = open("file", O_RDONLY | O_DIRECT); wri
我们想尽最大努力避免断电时数据丢失。所以我决定使用 O_DIRECT 标志打开一个文件将数据写入磁盘。 O_DIRECT 是否意味着数据完全绕过操作系统缓存?如果请求成功返回应用程序,是否意味着数据一
我正在尝试编写一个需要非常快速地写入磁盘的应用程序。我已经达到写入磁盘的性能目标,这很棒。 但是,我注意到如此快速地写入磁盘会占用大量 CPU 时间:一个内核已用尽,另一个内核已达到 80%,另外两个
据我了解,当您映射文件时,您基本上是将该文件的页面缓存中的页面直接映射到您的进程中,而当您使用 O_DIRECT 时,您将绕过页面缓存。将两者一起使用是否有意义?如果我的理解是正确的,它甚至会如何工作
我正在四处寻找以解决我们的数据库速度问题。 当我尝试使用时: innodb_flush_method=O_DIRECT 在我的 my.ini 文件中,MySQL 服务无法启动。我在 Google 上找
以下代码在缓冲区在堆栈上时失败,但在堆上分配时成功。我使用 Raid 驱动器在 RHEL 5.3 上对其进行了测试。是否可以将 O_DIRECT 与堆栈缓冲区一起使用? #define _GNU_SO
在 Linux 上(Linux 3.16.0-38-generic#52~14.04.1-Ubuntu x86_64 GNU/Linux),当尝试使用 O_DIRECT 通过直接 io 写入文件时 f
我遇到了 LVM 和我正在处理的磁盘驱动程序的竞争条件。看起来 vgcreate 和 lvcreate 之类的东西在 O_DIRECT 模式下执行它们的 IO。我在使用 -vvv 运行这些命令时发现了
我是一名优秀的程序员,十分优秀!