Theory and Practice

There is a saying commonly attributed to Einstein:

In theory, theory and practice are the same. In practice, they are not.

As an example, see Linus Torvalds’ contempt with O_DIRECT:

A thread on the lkml began with a query about using O_DIRECT when opening a file. An early white paper written by Andrea Arcangeli [interview] to describe the O_DIRECT patch before it was merged into the 2.4 kernel explains, “with O_DIRECT the kernel will do DMA directly from/to the physical memory pointed [to] by the userspace buffer passed as [a] parameter to the read/write syscalls. So there will be no CPU and memory bandwidth spent in the copies between userspace memory and kernel cache, and there will be no CPU time spent in kernel in the management of the cache (like cache lookups, per-page locks etc..).” Linux creator Linus Torvalds was quick to reply that despite all the claims there is no good reason for mounting files with O_DIRECT, suggesting that interfaces like madvise() and posix_fadvise() should be used instead, “there really is no valid reason for EVER using O_DIRECT. You need a buffer whatever IO you do, and it might as well be the page cache. There are better ways to control the page cache than play games and think that a page cache isn’t necessary.

Linus went on to explain, “the only reason O_DIRECT exists is because database people are too used to it, because other OS’s haven’t had enough taste to tell them to do it right, so they’ve historically hacked their OS to get out of the way. As a result, our madvise and/or posix_fadvise interfaces may not be all that strong, because people sadly don’t use them that much. It’s a sad example of a totally broken interface (O_DIRECT) resulting in better interfaces not getting used, and then not getting as much development effort put into them.

Applications like MySQL, Drupal etc have design decisions that might not align with Torvalds, but that is the essence of a Linux kernel – an interface to the metal (the hardware) and also to high-level apps (software).

No disrespect for the man, but it will get you thinking, even Torvalds  is humbled in the grand scheme of things. Humbled but not belittled…


One Comment Add yours

  1. google says:

    I liked your article is an interesting technology
    thanks to google I found you

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s