From: Florian Philipp <lists@binarywings.net>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Fast file system for cache directory with lot's of files
Date: Tue, 14 Aug 2012 17:09:45 +0200 [thread overview]
Message-ID: <502A6A39.4000800@binarywings.net> (raw)
In-Reply-To: <502A5889.8070506@admin-box.com>
[-- Attachment #1: Type: text/plain, Size: 2227 bytes --]
Am 14.08.2012 15:54, schrieb Daniel Troeder:
> On 14.08.2012 11:46, Neil Bothwick wrote:
>> On Tue, 14 Aug 2012 10:21:54 +0200, Daniel Troeder wrote:
>>
>>> There is also the possibility to write a really small daemon (less than
>>> 50 lines of C) that registers with inotify for the entire fs and
>>> journals the file activity to a sqlite-db.
>>
>> sys-process/incron ?
> Uh... didn't know that one! ... very interesting :)
>
> Have you used it?
> How does it perform if there are lots of modifications going on?
> Does it have a throttle against fork bombing?
> must-read-myself-a-little.....
>
> A incron line
> # sqlite3 /file.sql 'INSERT filename, date INTO table'
> would be inefficient, because it spawn lots of processes, but it would
> be very nice to simply test out the idea. Then a
> # sqlite3 /file.sql 'SELECT filename FROM table SORTBY date < date-30days'
> or something to get the files older than 30 days, and voilá :)
>
>
Maybe inotifywait is better for this kind of batch job.
Collecting events:
inotifywait -rm -e CREATE,DELETE --timefmt '%s' --format \
"$(printf '%%T\t%%e\t%%w%%f')" /tmp > events.tbl
# the printf is there because inotifywait's format does not
# recognize common escapes like \t
# Output format:
# Seconds since epoch \t CREATE/DELETE \t file name \n
Filtering events:
sort --stable -k3 events.tbl |
awk '
function update() {
line=$0; exists= $2=="DELETE" ? 0 : 1; file=$3
}
NR==1{ update(); next }
{ if($3!=file && exists==1){ print line } update() }'
# Sorts by file name while preserving temporal order.
# Uses awk to suppress output of files that have been deleted.
# Output: Last CREATE event for each existing file
Retrieving files created 30+ days ago:
awk -v newest=$(date -d -5seconds +%s) '
$1>newest{ nextfile }
{ print $3 }'
Remarks:
The awk scripts need some improvement if you have to handle whitespaces
in filenames but with the input format, it should be able to work with
everything except newlines.
Inotifywait itself is utterly useless when dealing with newlines in file
names unless you want to put some serious effort into sanitizing the output.
Regards,
Florian Philipp
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
next prev parent reply other threads:[~2012-08-14 15:12 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 13:16 [gentoo-user] Fast file system for cache directory with lot's of files Michael Hampicke
2012-08-13 13:22 ` Nilesh Govindrajan
2012-08-13 13:54 ` Michael Hampicke
2012-08-13 14:19 ` Pandu Poluan
2012-08-13 14:42 ` Michael Hampicke
2012-08-13 14:52 ` Michael Mol
2012-08-13 15:26 ` Michael Hampicke
2012-08-13 15:52 ` Michael Mol
2012-08-13 17:14 ` Florian Philipp
2012-08-13 18:18 ` Michael Hampicke
2012-08-14 14:00 ` Florian Philipp
2012-08-14 17:42 ` Michael Hampicke
2012-08-13 14:40 ` Dale
2012-08-13 14:58 ` Michael Hampicke
2012-08-13 15:20 ` Nilesh Govindrajan
2012-08-13 14:38 ` Daniel Troeder
2012-08-13 14:53 ` Michael Hampicke
2012-08-14 8:21 ` Daniel Troeder
2012-08-14 9:46 ` Neil Bothwick
2012-08-14 13:00 ` Florian Philipp
2012-08-14 13:54 ` Daniel Troeder
2012-08-14 15:09 ` Florian Philipp [this message]
2012-08-14 15:33 ` Florian Philipp
2012-08-16 16:54 ` Neil Bothwick
2012-08-14 17:45 ` Michael Hampicke
2012-08-13 20:13 ` Paul Hartman
2012-08-13 20:41 ` Volker Armin Hemmann
2012-08-14 2:07 ` Adam Carter
2012-08-14 16:36 ` Helmut Jarausch
2012-08-14 17:05 ` Pandu Poluan
2012-08-14 17:21 ` Jason Weisberger
2012-08-14 17:42 ` Volker Armin Hemmann
2012-08-14 17:50 ` Michael Hampicke
2012-08-14 19:55 ` Alecks Gates
2012-08-14 20:17 ` Michael Mol
2012-08-14 20:57 ` Alecks Gates
2012-08-14 17:48 ` Michael Hampicke
2012-08-14 17:42 ` Volker Armin Hemmann
2012-08-14 19:39 ` Paul Hartman
2012-08-15 7:31 ` Bill Kenworthy
2012-08-15 8:13 ` Bill Kenworthy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=502A6A39.4000800@binarywings.net \
--to=lists@binarywings.net \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox