Article View: news.software.nntp
Article #19233Re: Diablo Q
From: Matt Dillon
Date: Sun, 13 Jul 1997 00:00
Date: Sun, 13 Jul 1997 00:00
54 lines
2301 bytes
2301 bytes
:In article <5qaheh$d5u@netaxs.com>, Avi Freedman <freedman@netaxs.com> wrote:
:>Hey, Matt -
:>
:>What's the reason you don't go totally cyclic?
:>Locking overhead?
:>
:>I'm doing multi-process news receiving with semaphore locking
:>with some totally custom code to cyclic files and it goes zoom
:>just fine...
:>
:>Avi
It depends heavily on how the code works. If you are doing an
exclusive lock to write a record:
exclusive lock
append to cyclic file
unlcok
Then you effectively single-thread that portion of the code. As
the number of processes build, it becomes more of a bottleneck
because any delay (e.g. buffer cache miss) whatsoever inside the
semaphore will block ALL the processes rather then just one.
There are ways around the problem. In diablo, I switched from an
exclusive file lock for append to a non-blocking record lock:
/*
* Lock the append point.
*/
off = lseek(HFd, 0L, 2);
while (hflock(HFd, off, XLOCK_NB|XLOCK_EX) < 0)
off += sizeof(History);
(note: hflock a procedure in diablo/lib/lock.c that does a fcntl()
record lock).
This is a cool algorithm, IMHO, because it is virtually guarenteed to
work efficiently no matter how many processes are trying to append to
the history file. The only problem with it is that you need to hold the
lock until you are sure no other process is holding an 'old' append
offset. Diablo is a bit inefficient in the way it checks at the moment,
but I'll clean it up in the next few releases. You can't just hold the
lock forever, that would create a mess inside the kernel.
-Matt
Technical Details
Message-ID:
<5qb7g8$ql4$1@flea.best.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<5qaheh$d5u@netaxs.com>Show Full Headers
Complete Article Headers
Message-ID: <5qb7g8$ql4$1@flea.best.net> Subject: Re: Diablo Q Date: Sun, 13 Jul 1997 00:00:00 +0000 From: dillon@flea.best.net (Matt Dillon) References: <5qaheh$d5u@netaxs.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 256655973 Organization: Best Internet Communications, Inc. - 415 964 BEST Newsgroups: news.software.nntp