Bug 240053

Summary: 'tail -f' not responding ias snappy as technical possible
Product: [Fedora] Fedora Reporter: Folkert van Heusden <folkert>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: 6CC: meyering
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-05-15 14:28:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Folkert van Heusden 2007-05-14 17:51:08 UTC
Description of problem:
I noticed that tail does not react as snappy to changes in a file it
monitors (using 'tail -f') as is technically possible. So I did an
strace on it and found the following
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
...
as you can see it sleeps for a second between each check. Causing a
delay of maximum 1 second before a change in the file monitored is
reflected in the output of tail. Furthermore: it is not efficient to use
fstat to see what has changed to the file. I propose a change to tail
that either uses directly the inotify kernel-interface or via de sgi
FAM-daemon. I once already implemented this using the older dnotify
interface.

Version-Release number of selected component (if applicable):
ALL

How reproducible:
tail -f file
to see what I mean:
strace tail -f file

Steps to Reproduce:
1. tail -f file
2.
3.
  
Actual results:
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=3559, ...}) = 0
nanosleep({1, 0}, NULL)                 = 0
...

Expected results:
a call to inotify or the SGI FAM daemon or so

Additional info:
'turbotail' is more or less a drop-in replacement using the obsoleted dnotify
interface but contains bugs ( http://www.vanheusden.com/turbotail/ ).

Comment 1 Tim Waugh 2007-05-15 14:28:36 UTC
I think this is something to try to get upstream first of all.  It's a good idea
in theory, but I'm not sure it's something we want to spend much effort on. 
It's a fairly low benefit<->effort trade-off..