系统调用的开销 [英] Syscall overhead

查看:387
本文介绍了系统调用的开销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是多大(约)的I / O系统调用在Linux上从开销ç节目,我的意思是多么糟糕例如运行许多小读/写读操作比较/写上大的缓冲区(在常规文件上或者网络套接字)?应用强烈多线程的。

How big is (approximately) an I/O syscall overhead on Linux from C program, I mean how bad is running e.g. many small read / write operations compared with read / write on large buffers (on regular files or network sockets)? App is strongly multithreaded.

推荐答案

系统调用至少需要1-2微秒上最现代化的机器的只是为了系统调用的开销的,和更多的时间,如果他们做任何事情复杂,可以阻止或睡眠。期望至少20微秒和高达毫秒的IO的顺序。有一个微小的函数调用或宏从一个用户空间的缓冲区,这很可能纳秒(也许200 ns开启糟糕的一天)的问题,完成读取一个字节进行比较。

Syscalls take at least 1-2 microseconds on most modern machines just for the syscall overhead, and much more time if they're doing anything complex that could block or sleep. Expect at least 20 microseconds and up to the order of milliseconds for IO. Compare this with a tiny function call or macro that reads a byte from a userspace buffer, which is likely to complete in a matter of nanoseconds (maybe 200 ns on a bad day).

这篇关于系统调用的开销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆