Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Always leave room to add an explanation if it doesn't work out.


devel / comp.lang.tcl / Why does this take more as a second

SubjectAuthor
* Why does this take more as a secondCecil Westerhof
`* Re: Why does this take more as a secondRich
 `* Re: Why does this take more as a secondCecil Westerhof
  `- Re: Why does this take more as a secondRich

1
Why does this take more as a second

<87zgfeqbo3.fsf@munus.decebal.nl>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20038&group=comp.lang.tcl#20038

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Cecil@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Why does this take more as a second
Date: Mon, 05 Sep 2022 13:54:20 +0200
Organization: Decebal Computing
Lines: 47
Message-ID: <87zgfeqbo3.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="6231e3e3cd8adf713d94bfea119aed53";
logging-data="3758946"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gPOZvANxgiUXrLePTz7sRJZsusyZrL/g="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:HEBSa2OSFoR9ZNRaQZEpGtOeG1E=
sha1:5SyYQ9S6Sz/ql9DDX2lAXFURnMA=
 by: Cecil Westerhof - Mon, 5 Sep 2022 11:54 UTC

This is part of a tclsh script that I am running as a systemd service
in Linux.

I have the following proc (waitMinutes is a proc I defined to wait for
the begin of a minute):
proc getVmstatFp {} {
puts "Wait for begin minute"
waitMinutes 1
puts "Starting vmstat run"
set count [expr {1441 - [getMinuteInDay]}]
set command "|env TZ=UTC vmstat -n -S M -t ${::runLength} ${count}"
set vmstat [open ${command} RDONLY]
# The first three lines need to be skipped
# First two are header, third is average
for {set i 0} {${i} < 3} {incr i} {
gets ${vmstat}
}
return ${vmstat}
}

It is used in the following loop:
while {True} {
set vmstat [getVmstatFp]
# Get and save lines until the end of the day
# The reason is that after a bit more as a day vmstat goes out of sync
while {-1 != [gets ${vmstat} line]} {
saveVmstatInfo ${line}
}
puts "Stopped vmstat run"
close ${vmstat}
}

Sometimes there is two seconds between:
puts "Stopped vmstat run"
and:
puts "Wait for begin minute"

The first could be on the end of the second and the second at the
begin of a second, but that still means that there is more as a second
between those two. That seems a lot of time for the close.
Is something wrong here, or is this normal?
(Most of the time the two statements are executed in the same second.)

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Why does this take more as a second

<tf511s$3jiqj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20039&group=comp.lang.tcl#20039

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Why does this take more as a second
Date: Mon, 5 Sep 2022 14:28:12 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <tf511s$3jiqj$1@dont-email.me>
References: <87zgfeqbo3.fsf@munus.decebal.nl>
Injection-Date: Mon, 5 Sep 2022 14:28:12 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="1c5ccac9674198cbe1e570796cfb95c1";
logging-data="3787603"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/6zD6BvzZF7Od/wbUZRjNq"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:8/+ylRqqfY6npUjZo0ZNA5hhNj4=
 by: Rich - Mon, 5 Sep 2022 14:28 UTC

Cecil Westerhof <Cecil@decebal.nl> wrote:
> This is part of a tclsh script that I am running as a systemd service
> in Linux.
>
> set command "|env TZ=UTC vmstat -n -S M -t ${::runLength} ${count}"
> set vmstat [open ${command} RDONLY]
> ...
> close ${vmstat}
>
> Sometimes there is two seconds between:
> puts "Stopped vmstat run"
> and:
> puts "Wait for begin minute"
>
> The first could be on the end of the second and the second at the
> begin of a second, but that still means that there is more as a second
> between those two. That seems a lot of time for the close.
> Is something wrong here, or is this normal?
> (Most of the time the two statements are executed in the same second.)

From "man n close":

If channelId is a blocking channel for a command pipeline then
close waits for the child processes to complete.

You are closing a command pipeline, and the code you show did not set
non-blocking mode. The extra time you are seeing is probably vmstat
sleep jitter (i.e., it sometimes takes vmstat an extra second before it
learns its stdout has disappeared and exits).

Re: Why does this take more as a second

<87v8q1rfp3.fsf@munus.decebal.nl>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20040&group=comp.lang.tcl#20040

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Cecil@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Why does this take more as a second
Date: Mon, 05 Sep 2022 17:42:00 +0200
Organization: Decebal Computing
Lines: 44
Message-ID: <87v8q1rfp3.fsf@munus.decebal.nl>
References: <87zgfeqbo3.fsf@munus.decebal.nl> <tf511s$3jiqj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="6231e3e3cd8adf713d94bfea119aed53";
logging-data="3809426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZvbewLHk3xfMQCsZlPXcIPkH2pKlqI/s="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:i75s0ZsLXjN4raHnDxkaO2jkVUs=
sha1:qgL/MbT6VW+jTPJwIjLHqQuaH7w=
 by: Cecil Westerhof - Mon, 5 Sep 2022 15:42 UTC

Rich <rich@example.invalid> writes:

> Cecil Westerhof <Cecil@decebal.nl> wrote:
>> This is part of a tclsh script that I am running as a systemd service
>> in Linux.
>>
>> set command "|env TZ=UTC vmstat -n -S M -t ${::runLength} ${count}"
>> set vmstat [open ${command} RDONLY]
>> ...
>> close ${vmstat}
>>
>> Sometimes there is two seconds between:
>> puts "Stopped vmstat run"
>> and:
>> puts "Wait for begin minute"
>>
>> The first could be on the end of the second and the second at the
>> begin of a second, but that still means that there is more as a second
>> between those two. That seems a lot of time for the close.
>> Is something wrong here, or is this normal?
>> (Most of the time the two statements are executed in the same second.)
>
> From "man n close":
>
> If channelId is a blocking channel for a command pipeline then
> close waits for the child processes to complete.
>
> You are closing a command pipeline, and the code you show did not set
> non-blocking mode. The extra time you are seeing is probably vmstat
> sleep jitter (i.e., it sometimes takes vmstat an extra second before it
> learns its stdout has disappeared and exits).

But when I am closing the process it is already finished. It still can
happen then?
It is not really important, but I was just wondering. (When I see
something 'strange', I like to know the reason for it.) I think I will
keep it this way, because with non-blocking I do not get an error.
Should never happen, but if the 'impossible' happens, I want to know
about it.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Re: Why does this take more as a second

<tf5bmo$3krll$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20041&group=comp.lang.tcl#20041

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Why does this take more as a second
Date: Mon, 5 Sep 2022 17:30:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <tf5bmo$3krll$1@dont-email.me>
References: <87zgfeqbo3.fsf@munus.decebal.nl> <tf511s$3jiqj$1@dont-email.me> <87v8q1rfp3.fsf@munus.decebal.nl>
Injection-Date: Mon, 5 Sep 2022 17:30:01 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="1c5ccac9674198cbe1e570796cfb95c1";
logging-data="3829429"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XivgmSqt05523sRus9rMo"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:s+Iy4xAAy77ayJg8t8w+ZK3OVhI=
 by: Rich - Mon, 5 Sep 2022 17:30 UTC

Cecil Westerhof <Cecil@decebal.nl> wrote:
> Rich <rich@example.invalid> writes:
>
>> Cecil Westerhof <Cecil@decebal.nl> wrote:
>>> This is part of a tclsh script that I am running as a systemd service
>>> in Linux.
>>>
>>> set command "|env TZ=UTC vmstat -n -S M -t ${::runLength} ${count}"
>>> set vmstat [open ${command} RDONLY]
>>> ...
>>> close ${vmstat}
>>>
>>> Sometimes there is two seconds between:
>>> puts "Stopped vmstat run"
>>> and:
>>> puts "Wait for begin minute"
>>>
>>> The first could be on the end of the second and the second at the
>>> begin of a second, but that still means that there is more as a second
>>> between those two. That seems a lot of time for the close.
>>> Is something wrong here, or is this normal?
>>> (Most of the time the two statements are executed in the same second.)
>>
>> From "man n close":
>>
>> If channelId is a blocking channel for a command pipeline then
>> close waits for the child processes to complete.
>>
>> You are closing a command pipeline, and the code you show did not set
>> non-blocking mode. The extra time you are seeing is probably vmstat
>> sleep jitter (i.e., it sometimes takes vmstat an extra second before it
>> learns its stdout has disappeared and exits).
>
> But when I am closing the process it is already finished. It still can
> happen then?

Unknown -- but this is most likely the explanation. Something taking
just a bit longer during the close.

> It is not really important, but I was just wondering. (When I see
> something 'strange', I like to know the reason for it.) I think I will
> keep it this way, because with non-blocking I do not get an error.
> Should never happen, but if the 'impossible' happens, I want to know
> about it.

To dig deeper you'd have to strace (with the follow forks option) and
start trying to piece together the actual order of events.


devel / comp.lang.tcl / Why does this take more as a second

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor