9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] seeking for the truth
@ 2004-02-12 18:19 David Presotto
  2004-02-12 18:30 ` rog
  2004-02-14 22:47 ` Scott Schwartz
  0 siblings, 2 replies; 23+ messages in thread
From: David Presotto @ 2004-02-12 18:19 UTC (permalink / raw)
  To: 9fans

I can't find anything that currently uses on the length of
stream files, just debugging stuff I have.  I'ld be willing to
get rid of the length, though its helped me many times
debugging things especially with IP.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 18:30 ` rog
@ 2004-02-12 18:27   ` David Presotto
  2004-02-12 20:30   ` boyd, rounin
  1 sibling, 0 replies; 23+ messages in thread
From: David Presotto @ 2004-02-12 18:27 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 61 bytes --]

The problem is that the file isn't always there, as in pipes.

[-- Attachment #2: Type: message/rfc822, Size: 1919 bytes --]

From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] seeking for the truth
Date: Thu, 12 Feb 2004 18:30:14 0000
Message-ID: <c901327c41d26f44589e429d49ed219a@vitanuova.com>

> I'ld be willing to
> get rid of the length, though its helped me many times
> debugging things especially with IP.

wouldn't it be more appropriate to have it available
in another file (e.g. status)?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 18:19 [9fans] seeking for the truth David Presotto
@ 2004-02-12 18:30 ` rog
  2004-02-12 18:27   ` David Presotto
  2004-02-12 20:30   ` boyd, rounin
  2004-02-14 22:47 ` Scott Schwartz
  1 sibling, 2 replies; 23+ messages in thread
From: rog @ 2004-02-12 18:30 UTC (permalink / raw)
  To: 9fans

> I'ld be willing to
> get rid of the length, though its helped me many times
> debugging things especially with IP.

wouldn't it be more appropriate to have it available
in another file (e.g. status)?



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 18:30 ` rog
  2004-02-12 18:27   ` David Presotto
@ 2004-02-12 20:30   ` boyd, rounin
  1 sibling, 0 replies; 23+ messages in thread
From: boyd, rounin @ 2004-02-12 20:30 UTC (permalink / raw)
  To: 9fans

> wouldn't it be more appropriate to have it available
> in another file (e.g. status)?

no, we already have the length and i think it should
indicate the amount of readable data (like a real
file) on pipes and network connections and other
'synthetic' files, if that information is available.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 18:19 [9fans] seeking for the truth David Presotto
  2004-02-12 18:30 ` rog
@ 2004-02-14 22:47 ` Scott Schwartz
  2004-02-16 20:10   ` rog
  1 sibling, 1 reply; 23+ messages in thread
From: Scott Schwartz @ 2004-02-14 22:47 UTC (permalink / raw)
  To: 9fans

On Thu, Feb 12, 2004 at 01:19:51PM -0500, David Presotto wrote:
> I can't find anything that currently uses on the length of
> stream files, just debugging stuff I have.  I'ld be willing to
> get rid of the length, though its helped me many times
> debugging things especially with IP.

I'm not sure I like getting rid of it;  I feel like buffers ought to
have a cheap way to ask how full they are.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-14 22:47 ` Scott Schwartz
@ 2004-02-16 20:10   ` rog
  2004-02-17  4:47     ` boyd, rounin
  0 siblings, 1 reply; 23+ messages in thread
From: rog @ 2004-02-16 20:10 UTC (permalink / raw)
  To: 9fans

> I'm not sure I like getting rid of it;  I feel like buffers ought to
> have a cheap way to ask how full they are.

stat is no cheaper than read.

and since we have fd2path, it's not too difficult to work out where to
find the information (for /net at any rate), even if you only have a
file descriptor.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-16 20:10   ` rog
@ 2004-02-17  4:47     ` boyd, rounin
  0 siblings, 0 replies; 23+ messages in thread
From: boyd, rounin @ 2004-02-17  4:47 UTC (permalink / raw)
  To: 9fans

> > I'm not sure I like getting rid of it;  I feel like buffers ought to
> > have a cheap way to ask how full they are.
>
> stat is no cheaper than read.

ls -l and others use stat, not read.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 16:16 ` [9fans] seeking for the truth rog
  2004-02-12 16:32   ` David Presotto
  2004-02-12 16:50   ` Dave Lukes
@ 2004-02-12 20:19   ` boyd, rounin
  2 siblings, 0 replies; 23+ messages in thread
From: boyd, rounin @ 2004-02-12 20:19 UTC (permalink / raw)
  To: 9fans

> thoughts?

seeking on pipes doesn't scale.

adding more junk to support special cases is a bad idea.




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
@ 2004-02-12 19:00 David Presotto
  0 siblings, 0 replies; 23+ messages in thread
From: David Presotto @ 2004-02-12 19:00 UTC (permalink / raw)
  To: 9fans

OK.  Pipes, uarts, and tcp data files now stat as 0 length.  I'll probably
change the stats files for uarts and tcp to show how much is really there
for debuggering.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 18:00             ` rob pike, esq.
  2004-02-12 18:05               ` Charles Forsyth
@ 2004-02-12 18:10               ` rog
  2004-02-12 18:10                 ` David Presotto
  1 sibling, 1 reply; 23+ messages in thread
From: rog @ 2004-02-12 18:10 UTC (permalink / raw)
  To: 9fans

> > simpler might be: seekable = seek(fd, 0, 2) > 0;
>
> now you're talking.

pity it doesn't work on /net/tcp/0/data.

but i always thought that using the file size for "amount of unbuffered data"
was a nasty thing to do... does anything actually use that property?



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 18:10               ` rog
@ 2004-02-12 18:10                 ` David Presotto
  0 siblings, 0 replies; 23+ messages in thread
From: David Presotto @ 2004-02-12 18:10 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 119 bytes --]

It's true of qio files in general, including pipes.

I've used it often to know how much I can read without blocking.

[-- Attachment #2: Type: message/rfc822, Size: 1977 bytes --]

From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] seeking for the truth
Date: Thu, 12 Feb 2004 18:10:18 0000
Message-ID: <3b828656ea8bbad209d8a8a91f883860@vitanuova.com>

> > simpler might be: seekable = seek(fd, 0, 2) > 0;
>
> now you're talking.

pity it doesn't work on /net/tcp/0/data.

but i always thought that using the file size for "amount of unbuffered data"
was a nasty thing to do... does anything actually use that property?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 18:00             ` rob pike, esq.
@ 2004-02-12 18:05               ` Charles Forsyth
  2004-02-12 18:10               ` rog
  1 sibling, 0 replies; 23+ messages in thread
From: Charles Forsyth @ 2004-02-12 18:05 UTC (permalink / raw)
  To: 9fans

i ought to have pointed out that in some applications the
pointer needs to be restored after the seek(,2) test; i knew that
at the time, but it made the general case a bit less pretty!
tail does more messing about than i remembered.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 17:22           ` Charles Forsyth
@ 2004-02-12 18:00             ` rob pike, esq.
  2004-02-12 18:05               ` Charles Forsyth
  2004-02-12 18:10               ` rog
  0 siblings, 2 replies; 23+ messages in thread
From: rob pike, esq. @ 2004-02-12 18:00 UTC (permalink / raw)
  To: 9fans

> simpler might be: seekable = seek(fd, 0, 2) > 0;

now you're talking.

-rob



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 17:17         ` Charles Forsyth
  2004-02-12 17:22           ` Charles Forsyth
  2004-02-12 17:26           ` Fco.J.Ballesteros
@ 2004-02-12 17:35           ` Dave Lukes
  2 siblings, 0 replies; 23+ messages in thread
From: Dave Lukes @ 2004-02-12 17:35 UTC (permalink / raw)
  To: 9fans

> unseekable synthetic files typically are length 0 (because they have
> no particular length), or tiny (pipes have a hack that stat shows what's in them)

The man is, as usual, correct:
I had my mind too far into a un*x model of files/devices/pipes only.
My apologies.

> so change the test to declare seekable only if the file is big enough
> to warrant it.
:-))

>   one hack deserves another.  then we can get back
> to trying to get a version of ghostscript that doesn't blow up on
> recent pdf/ps.

Amen.
	Dave.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 17:17         ` Charles Forsyth
  2004-02-12 17:22           ` Charles Forsyth
@ 2004-02-12 17:26           ` Fco.J.Ballesteros
  2004-02-12 17:35           ` Dave Lukes
  2 siblings, 0 replies; 23+ messages in thread
From: Fco.J.Ballesteros @ 2004-02-12 17:26 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

I'd say this is a fundamental problem.
seek has sense for files that are always there.
But, as you said, many of your files are made
on demand, and the seek concept does not
apply well for them.

Isn't just enough to try to keep the seeking programs
to a bare minimum?

[-- Attachment #2: Type: message/rfc822, Size: 2423 bytes --]

From: Charles Forsyth <forsyth@terzarima.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] seeking for the truth
Date: Thu, 12 Feb 2004 17:17:59 0000
Message-ID: <c2f71f0dc611079cbba4d0909fc1afff@terzarima.net>

i'm not enthusiastic about having to change nearly every file server.
status files will be seekable but most synthetic ones won't.
some synthetic files will never be seekable in tail's sense because
they have no end, but they do interpret offsets, so are they QTSEEK or not?

isn't tail's seek an optimisation to avoid reading the file to the end?
unseekable synthetic files typically are length 0 (because they have
no particular length), or tiny (pipes have a hack that stat shows what's in them)
so change the test to declare seekable only if the file is big enough
to warrant it.  one hack deserves another.  then we can get back
to trying to get a version of ghostscript that doesn't blow up on
recent pdf/ps.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 17:17         ` Charles Forsyth
@ 2004-02-12 17:22           ` Charles Forsyth
  2004-02-12 18:00             ` rob pike, esq.
  2004-02-12 17:26           ` Fco.J.Ballesteros
  2004-02-12 17:35           ` Dave Lukes
  2 siblings, 1 reply; 23+ messages in thread
From: Charles Forsyth @ 2004-02-12 17:22 UTC (permalink / raw)
  To: 9fans

>>so change the test to declare seekable only if the file is big enough
>>to warrant it.  one hack deserves another.  then we can get back

simpler might be: seekable = seek(fd, 0, 2) > 0;



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 17:03       ` Fco.J.Ballesteros
@ 2004-02-12 17:17         ` Charles Forsyth
  2004-02-12 17:22           ` Charles Forsyth
                             ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Charles Forsyth @ 2004-02-12 17:17 UTC (permalink / raw)
  To: 9fans

i'm not enthusiastic about having to change nearly every file server.
status files will be seekable but most synthetic ones won't.
some synthetic files will never be seekable in tail's sense because
they have no end, but they do interpret offsets, so are they QTSEEK or not?

isn't tail's seek an optimisation to avoid reading the file to the end?
unseekable synthetic files typically are length 0 (because they have
no particular length), or tiny (pipes have a hack that stat shows what's in them)
so change the test to declare seekable only if the file is big enough
to warrant it.  one hack deserves another.  then we can get back
to trying to get a version of ghostscript that doesn't blow up on
recent pdf/ps.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 16:32   ` David Presotto
@ 2004-02-12 17:10     ` rog
  0 siblings, 0 replies; 23+ messages in thread
From: rog @ 2004-02-12 17:10 UTC (permalink / raw)
  To: 9fans

presotto:
> except diff doesn't seek the files it is comparing, only its temps...

actually, diff only makes temp files if it thinks it has to,
which is why diff <{gunzip<x.gz} <{gunzip<y.gz} didn't work
(actually i think the checks are a bit more rigorous now).

> Maybe, need a few days to think about it.  I'm vaguely disturbed by it
> but don't know why.  Perhaps because 9p2000 has no concept of seek and
> having a bit that talks about it seems odd.  Then again that's true of the
> exec permission bit also...

could call it "QTIGNORESOFFSETS" but i couldn't think of anything
in that line that was snappy enough.

rob:
> i can't get excited about this.  you used the word 'hack'
> yourself to describe the result.

it's a hack now. it wouldn't be if there was some system support
for it.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 16:59     ` Rob Pike
@ 2004-02-12 17:03       ` Fco.J.Ballesteros
  2004-02-12 17:17         ` Charles Forsyth
  0 siblings, 1 reply; 23+ messages in thread
From: Fco.J.Ballesteros @ 2004-02-12 17:03 UTC (permalink / raw)
  To: 9fans

> here's a fix:
>
> 	|cat|tail -r

But this shows a non-uniform behaviour.
I'd expect
	|tail -r
to be exactly like
	|cat|tail -r
but for the buffering involved.

I'm not sure about the real fix. My first attempt would
be to ban out seek; although I know that's not feasible in Plan 9...



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 16:50   ` Dave Lukes
@ 2004-02-12 16:59     ` Rob Pike
  2004-02-12 17:03       ` Fco.J.Ballesteros
  0 siblings, 1 reply; 23+ messages in thread
From: Rob Pike @ 2004-02-12 16:59 UTC (permalink / raw)
  To: 9fans

dave's right. there's no seek concept in 9P, only offsets.

i can't get excited about this.  you used the word 'hack'
yourself to describe the result.

here's a fix:

	|cat|tail -r

-rob



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 16:16 ` [9fans] seeking for the truth rog
  2004-02-12 16:32   ` David Presotto
@ 2004-02-12 16:50   ` Dave Lukes
  2004-02-12 16:59     ` Rob Pike
  2004-02-12 20:19   ` boyd, rounin
  2 siblings, 1 reply; 23+ messages in thread
From: Dave Lukes @ 2004-02-12 16:50 UTC (permalink / raw)
  To: 9fans

Definite plus vote from me.
Nugatory seeks have annoyed me ever since 6th Ed.

Also,
if anything out there _is_ seek()ing without checking the result,
then either it's broke anyway,
or it knows it can safely ignore the result.
So, off the top of my head, I don't see compatibility as an issue.

Obviously this would need some more looking at,
and a pile of "grep seek ..."s, but it sounds like a plan to me ...

	Dave.

On Thu, 2004-02-12 at 16:16, rog@vitanuova.com wrote:
> i was caught up short just now when i tried to reverse
> some lines in acme by selecting them and executing "|tail -r".
>
> it didn't work.
> the reason?
>
> /sys/src/cmd/tail.c:94: 	seekable = seek(file,0L,0) == 0;
>
> the seek() is succeeding, even though standard input
> isn't actually seekable.
>
> the trouble is, it can't do anything else.
>
> we don't see this problem much because of the special case hack for
> "#|" in sseek(), but the tail code is a common hack, and an insidious
> one.  there are loads of special files around that don't allow
> seeking, and many programs that require files that are seekable (diff
> being the age-old example).
>
> surely a better solution is possible?  in general, a fileserver knows
> whether its files are seekable or not, because it determines how to
> interpret the seek offset.
>
> why not add a new bit to the file attributes, say DMNOSEEK (and
> associated QTNOSEEK)?  if set, it would indicate that file offsets
> when reading and writing the file will be ignored.  0x2 seems to be
> available.
>
> then the above line from tail.c could work, and finally it would be
> possible to write programs that know definitively whether they are
> able to seek on a particular file or not, rather than failing
> strangely sometime later.
>
> the amount of code involved would be tiny, and as far as i can see
> it would be completely backwardly compatible.
>
> thoughts?
>



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [9fans] seeking for the truth
  2004-02-12 16:16 ` [9fans] seeking for the truth rog
@ 2004-02-12 16:32   ` David Presotto
  2004-02-12 17:10     ` rog
  2004-02-12 16:50   ` Dave Lukes
  2004-02-12 20:19   ` boyd, rounin
  2 siblings, 1 reply; 23+ messages in thread
From: David Presotto @ 2004-02-12 16:32 UTC (permalink / raw)
  To: 9fans

> seeking, and many programs that require files that are seekable (diff
> being the age-old example).

except diff doesn't seek the files it is comparing, only its temps...

> surely a better solution is possible?  in general, a fileserver knows
> whether its files are seekable or not, because it determines how to
> interpret the seek offset.

Fixing all the programs that seek without checking might also be nice.

> why not add a new bit to the file attributes, say DMNOSEEK (and
> associated QTNOSEEK)?  if set, it would indicate that file offsets
> when reading and writing the file will be ignored.  0x2 seems to be
> available.

Maybe, need a few days to think about it.  I'm vaguely disturbed by it
but don't know why.  Perhaps because 9p2000 has no concept of seek and
having a bit that talks about it seems odd.  Then again that's true of the
exec permission bit also...



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [9fans] seeking for the truth
  2004-02-12 14:35 [9fans] Strange boot behaviour David Presotto
@ 2004-02-12 16:16 ` rog
  2004-02-12 16:32   ` David Presotto
                     ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: rog @ 2004-02-12 16:16 UTC (permalink / raw)
  To: 9fans

i was caught up short just now when i tried to reverse
some lines in acme by selecting them and executing "|tail -r".

it didn't work.
the reason?

/sys/src/cmd/tail.c:94: 	seekable = seek(file,0L,0) == 0;

the seek() is succeeding, even though standard input
isn't actually seekable.

the trouble is, it can't do anything else.

we don't see this problem much because of the special case hack for
"#|" in sseek(), but the tail code is a common hack, and an insidious
one.  there are loads of special files around that don't allow
seeking, and many programs that require files that are seekable (diff
being the age-old example).

surely a better solution is possible?  in general, a fileserver knows
whether its files are seekable or not, because it determines how to
interpret the seek offset.

why not add a new bit to the file attributes, say DMNOSEEK (and
associated QTNOSEEK)?  if set, it would indicate that file offsets
when reading and writing the file will be ignored.  0x2 seems to be
available.

then the above line from tail.c could work, and finally it would be
possible to write programs that know definitively whether they are
able to seek on a particular file or not, rather than failing
strangely sometime later.

the amount of code involved would be tiny, and as far as i can see
it would be completely backwardly compatible.

thoughts?



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2004-02-17  4:47 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-12 18:19 [9fans] seeking for the truth David Presotto
2004-02-12 18:30 ` rog
2004-02-12 18:27   ` David Presotto
2004-02-12 20:30   ` boyd, rounin
2004-02-14 22:47 ` Scott Schwartz
2004-02-16 20:10   ` rog
2004-02-17  4:47     ` boyd, rounin
  -- strict thread matches above, loose matches on Subject: below --
2004-02-12 19:00 David Presotto
2004-02-12 14:35 [9fans] Strange boot behaviour David Presotto
2004-02-12 16:16 ` [9fans] seeking for the truth rog
2004-02-12 16:32   ` David Presotto
2004-02-12 17:10     ` rog
2004-02-12 16:50   ` Dave Lukes
2004-02-12 16:59     ` Rob Pike
2004-02-12 17:03       ` Fco.J.Ballesteros
2004-02-12 17:17         ` Charles Forsyth
2004-02-12 17:22           ` Charles Forsyth
2004-02-12 18:00             ` rob pike, esq.
2004-02-12 18:05               ` Charles Forsyth
2004-02-12 18:10               ` rog
2004-02-12 18:10                 ` David Presotto
2004-02-12 17:26           ` Fco.J.Ballesteros
2004-02-12 17:35           ` Dave Lukes
2004-02-12 20:19   ` boyd, rounin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).