lkml.org 
[lkml]   [2012]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectHow to do buffered File IO event-based programs?
Hi,

I am writing a daemon that mostly reads and writes over network connections,
and uses a single threaded event-loop based design using epoll.

Now the daemon occasionally needs to read and write to disk, because it
gets data that is too big to keep in memory. The corresponding request
gets slowed down of course, that is ok. What I would like to avoid
however, is slowing down other client connections to the same
daemon.

As I understand it, just adding the disk-io filedescriptor to the epoll
does not work because it always is ready for reading and writing.

I could use aio, but that is cumbersome as it sets serious alingment
restrictions on the buffers that get written/get read into. Also that
way, the data will circumvent the buffer cache which is not what
I want, to the contrary: data written to a file is very likely to be
read again soon, so if there happens to be enogh free RAM available,
I would like to use it.

I could use a second worker process connected to the other via
a pipe or a unix domain socket. That does work but adds another
userspace-kernel copy plus context switch to each read and write.
This is probably irrelevant in the presence of actual disk io,
and will be the route to go in the absence of other ideas.

Do I ask something unreasonable, is my design flawed anyway, or
is there a concept/unofficial kernel patch flowing around that I
missed?

--

Mit freundlichen Grüßen / with kind regards

Nils Rennebarth, Software Developer

--
Funkwerk IP-Appliances GmbH
Mönchhaldenstraße 28
D-70191 Stuttgart

Tel: +49 711 900300 - 0
Fax: +49 711 900300 - 90

E-Mail: Nils.Rennebarth@funkwerk-ec.com

Location: GmbH Nuernberg, Local Court Nuernberg, HRB 25481
Managing Directors: Torsten Urban
--------------------------------
The information contained in this e-mail has been carefully researched,
but the possibility of it being inapplicable in individual cases cannot
be ruled out. We therefore regret that we cannot accept responsibility
or liability of any kind whatsoever for the correctness of the
information given. Please notify us if you discover that information is
inapplicable.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-04-10 11:53    [W:0.026 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site