Is it bad to have lots of FileSystemChangeReaders? and Dolphin Threads?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it bad to have lots of FileSystemChangeReaders? and Dolphin Threads?

Tim M
I am watching for edits to a file so that I can reparse it if you make a
change - it seems simpler in my code to create a watcher for each file (and
as its intended to be a web app in swazoo) with an associated Thread to broadcast
the change to my object.

However is this a bad idea? From what I recall Threads are cheap - not sure
about ChangeReaders... I guess I am wondering if I really have to create
a single ChangeReader and Thread and have objects register with it for updates?

Tim


Reply | Threaded
Open this post in threaded view
|

Re: Is it bad to have lots of FileSystemChangeReaders? and Dolphin Threads?

Bernhard Kohlhaas-6
macta wrote:
> I am watching for edits to a file so that I can reparse it if you make a
> change - it seems simpler in my code to create a watcher for each file
> (and as its intended to be a web app in swazoo) with an associated
> Thread to broadcast the change to my object.
>
> However is this a bad idea? From what I recall Threads are cheap - not
> sure about ChangeReaders... I guess I am wondering if I really have to
> create a single ChangeReader and Thread and have objects register with
> it for updates?

Tim,

I'm afraid that I don't have a yes/no answer to your question, because I
have only used that Windows API with very few "ChangeReaders" (I have my
own implementation that I did in D5).

IF there is a performance problem, it might not be with the threads
(because they're not permanently created and discarded), but more likely
with the underlying Windows API that has to manage all those different
handles that are associated with the ChangeReaders.

The first question that comes to mind is, how many different
ChangeReaders are we actually talking about? 10s? 100s? 1000s?

If it is in the low double-digits, it's probably nothing to worry about.

Just my 2 cents,
Bernhard


Reply | Threaded
Open this post in threaded view
|

Re: Is it bad to have lots of FileSystemChangeReaders? and Dolphin Threads?

Tim M
Hi Bernhard,

> If it is in the low double-digits, it's probably nothing to worry
> about.

Its for a web template engine - the watchers would be on swazoo resources
you easily wanted to update and debug, so lowdouble digits is probably reasonable
(and in production you probably wouldn't use any).

I'm almost at a point to release it, not sure if anyone is interested - its
sort of a combination of Velocity and FreeMarker, so I guess I can always
mark that caveat in the readme.

Tim


Reply | Threaded
Open this post in threaded view
|

Re: Is it bad to have lots of FileSystemChangeReaders? and Dolphin Threads?

Chris Uppal-3
In reply to this post by Tim M
macta wrote:

> However is this a bad idea? From what I recall Threads are cheap - not
> sure about ChangeReaders... I guess I am wondering if I really have to
> create
> a single ChangeReader and Thread and have objects register with it for
> updates?

Processes ("threads") are cheap /provided/ that you don't do overlapped
external calls from them.  When you do (in D6) a new OS-level thread is set up
for its use which will last for at least as long as the "owning" Process does.
AFAICT, ChangeReaders themselves don't issue any overlapped calls.

I can't find any evidence that ChangeReaders themselves are especially costly
(n relation to what they do), but I don't think it's a very good idea to use
(routinely) more than one watcher in the same directory (and a watcher for a
file seems to be just a watcher for the containing folder with a specific
filter set).  Each watcher actually (it appears) watches all changes to one
directory, so using two watchers on two files in the same directory would
double the notification load.

    -- chris