Re: Eureka! (was Re: UTF-8 and case-insensitivity)

From: Jamie Lokier
Date: Thu Feb 19 2004 - 19:55:39 EST


Linus Torvalds wrote:

> I can't imagine that a file manager is all that interested in seeing
> the changes it itself does be reported back to it.

No, but any file manager that's made of libraries where one thread is
showing the window and another thread is doing operations will care -
unless they explicitly communicate. Right now they might, or they
might not.

> (That said, clearly it's better to just have a new flag, since that way
> there is no possibility of anything breaking).

Quite.

> And I don't really know of any other uses of dnotify.

High performance web template cache:
dnotify is used to invalidate cached info about prerequisite files,
so that quite a lot of files can be used to create a page, the
output is cached, and validating the cache for each page request
as actually zero cost (because dnotify is a signal, so validating is
just checking that you didn't receive the signal).

Accelerated Make:
dnotify is used to invalidate cached stat() results between runs.
A daemon runs in the background to retain the information.
(Communicating with the daemon is only faster than calling stat()
if the retained information includes precomputed dependencies,
pre-parsed Makefiles and such.

Java VM accelerator:
Let the JVM precompile class files to a machine-specific code and
keep that in a mmaped file between invocations. When a new JVM
process is started, it checks that all the class files for a
particular program haven't changed; a daemon using dnotify can
speed up this check, or even provide a stronger guarantee, if you
don't trust stat() mtimes.

Fontconfig accelerator:
When a program using fontconfig (e.g. any GNOME program and many
others) starts, it calls stat() on every font file in ~/.fonts.
This is lovely to use because you just drop font files in there,
but the stat() calls are slow when you have a very large number.
A daemon using dnotify can monitor this and allow a program to
skip those calls.

Maildir accelerator:
Similar to fontconfig, but on mail directories for validating
the cached summary information about all mails in a folder.

Shared cache directory:
A program stores files in a shared cache, e.g. like a web browser.
dnotify can be used to monitor the cached files, to invalidate
in-memory data structures parsed from them if other programs are
modifying the same cached file data structures.

Shared database in a file (like Berkeley DB et al):
dnotify is used to notice when another process modifies the file.
You still need to lock and write updates, but you can avoid reading
and parsing the database file between queries and use calculated
in-memory data for the queries, if you know the file hasn't been
changed by another process.

One thing you can't do is real-time updatedb+locate, because of the
need to have an open file descriptor for every directory that's monitored.

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