Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

It is easier to change the specification to fit the program than vice versa.


devel / comp.lang.tcl / Re: Question about TCL speed

SubjectAuthor
* Question about TCL speedaotto1968
+* Re: Question about TCL speedChristian Gollwitzer
|`* Re: Question about TCL speedChristian Gollwitzer
| `* Re: Question about TCL speedaotto1968
|  `- Re: Question about TCL speedGerald Lester
`- Re: Question about TCL speedheinrichmartin

1
Question about TCL speed

<t8vklm$uku$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Question about TCL speed
Date: Wed, 22 Jun 2022 19:48:37 +0200
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <t8vklm$uku$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 22 Jun 2022 17:48:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="13618de74b0e45759ab024677107c373";
logging-data="31390"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IcWSb+11WR9ky+IzaJN5HdUZ0SQ1/QHM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:0NypheyTnZ9Pnm4U5C/jQIV7HiY=
Content-Language: en-US
 by: aotto1968 - Wed, 22 Jun 2022 17:48 UTC

Hi,

this is a piece of code to delete a *const* prefix (librx) from a string
(str)

OLD:

proc pCleanLibRx { str } {
regsub "${::librx}(\\w+)$" $str {\1}
}

as you see the string is *not* static by definition only by *logic*

Question it is efficient to keep the code as it is **OR** to add a
global variable with a *non-changing* global value

NEW

set myRX "${::librx}(\\w+)$"

proc pCleanLibRx { str } {
regsub $::myRX $str {\1}
}

If second is faster than TCL has an open point to add a CONST on-time
define to a inline string.

possible NEW:

proc pCleanLibRx { str } {
regsub [CONST ${::librx}(\\w+)$"] $str {\1}
}

CONST = make a hint to the tcl that the string is CONST
→ the value can be cached

mfg

Re: Question about TCL speed

<t8vsvc$5ep$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: Question about TCL speed
Date: Wed, 22 Jun 2022 21:10:18 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <t8vsvc$5ep$1@dont-email.me>
References: <t8vklm$uku$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 22 Jun 2022 20:10:20 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4192459506726d34b960d810fabc5008";
logging-data="5593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BM719zicqnhJGX580jIWmHlpebPOPhtc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:e+130GmsUI+yf9h4hJC4mZwsQes=
In-Reply-To: <t8vklm$uku$1@dont-email.me>
Content-Language: en-US
 by: Christian Gollwitzer - Wed, 22 Jun 2022 20:10 UTC

Am 22.06.22 um 18:48 schrieb aotto1968:
>
> Hi,
>
> this is a piece of code to delete a *const* prefix (librx) from a string
> (str)
>
> OLD:
>
> proc pCleanLibRx { str } {
>   regsub "${::librx}(\\w+)$" $str {\1}
> }
>
> as you see the string is *not* static by definition only by *logic*

Instead of asking, which one is faster, you should benchmark it. There
is the time command in the core (and, in newer cores, also the timerate
command)

> Question it is efficient to keep the code as it is **OR** to add a
> global variable with a *non-changing* global value
>
> NEW
>
> set myRX "${::librx}(\\w+)$"

I would expect that there is no big difference. The largest effort is
put into compiling the RE into its internal representation. For both
code paths, this is done only once at the first regexp invocation. The
literal string in the proc is stored in a literal table, i.e. what you
propose to do, is already done by the byte code compiler AFAIUI.

Christian

Re: Question about TCL speed

<t8vt70$a38$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: Question about TCL speed
Date: Wed, 22 Jun 2022 21:14:22 +0100
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <t8vt70$a38$1@dont-email.me>
References: <t8vklm$uku$1@dont-email.me> <t8vsvc$5ep$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 22 Jun 2022 20:14:24 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4192459506726d34b960d810fabc5008";
logging-data="10344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YXntiCiYVPoLSu7/vF0ZYiZv+9CN7auU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:a0tO4AMgaDDNFDWABlOwg0z0HRk=
In-Reply-To: <t8vsvc$5ep$1@dont-email.me>
Content-Language: en-US
 by: Christian Gollwitzer - Wed, 22 Jun 2022 20:14 UTC

....sorry, that was a bit too fast;
Am 22.06.22 um 21:10 schrieb Christian Gollwitzer:
> Am 22.06.22 um 18:48 schrieb aotto1968:
>>

> Instead of asking, which one is faster, you should benchmark it. There
> is the time command in the core (and, in newer cores, also the timerate
> command)

This still holds: Time it
>
>
>> Question it is efficient to keep the code as it is **OR** to add a
>> global variable with a *non-changing* global value
>>
>> NEW
>>
>> set myRX "${::librx}(\\w+)$"
>
> I would expect that there is no big difference. The largest effort is

Indeed, for a dynamic string like this, the global variable should be
faster. Still, the RE engine caches not only the conmpiled expressino in
the intrep, but also the most recently used expression strings in order
to deal with this problem of dynamically constructed const strings. That
is special to regexp and does not hold for any other shimmering issue.

Christian

Re: Question about TCL speed

<t8vuo1$442$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: Question about TCL speed
Date: Wed, 22 Jun 2022 22:40:33 +0200
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <t8vuo1$442$1@dont-email.me>
References: <t8vklm$uku$1@dont-email.me> <t8vsvc$5ep$1@dont-email.me>
<t8vt70$a38$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 22 Jun 2022 20:40:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="13618de74b0e45759ab024677107c373";
logging-data="4226"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+rC2NWd3ghlPYQ+I7D1A7ZguV7TXvA4k="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:dP9FfCsN+/8St1DT9m5JkX7ZnD4=
In-Reply-To: <t8vt70$a38$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Wed, 22 Jun 2022 20:40 UTC

>>
>>> Question it is efficient to keep the code as it is **OR** to add a
>>> global variable with a *non-changing* global value
>>>
>>> NEW
>>>
>>> set myRX "${::librx}(\\w+)$"
>>
>> I would expect that there is no big difference. The largest effort is
>
> Indeed, for a dynamic string like this, the global variable should be
> faster. Still, the RE engine caches not only the conmpiled expressino in
> the intrep, but also the most recently used expression strings in order
> to deal with this problem of dynamically constructed const strings. That
> is special to regexp and does not hold for any other shimmering issue.
>
>     Christian

thanks for the answer… I thing a lot of performance is lost in tcl
because of the *const-by-logic* issue.

It is a typical task to define some *const* values at the beginning and
use this *const* to do any kind of 'workload' like the one above.

probably a better solution would be to define the object at all ans
const and in the code at any place a usage sonst will be const as well.

in our case

"${::librx}(\\w+)$" is a concat of "${::librx}" and "(\\w+)$" both are
*const* and the result will be *const* too.

mfg

Re: Question about TCL speed

<t901b7$qs8$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!tQGecgdXxZAKb1FaDldylw.user.46.165.242.75.POSTED!not-for-mail
From: Gerald.Lester@KnG-Consulting.net (Gerald Lester)
Newsgroups: comp.lang.tcl
Subject: Re: Question about TCL speed
Date: Wed, 22 Jun 2022 16:24:55 -0500
Organization: KnG Consulting, LLC
Message-ID: <t901b7$qs8$1@gioia.aioe.org>
References: <t8vklm$uku$1@dont-email.me> <t8vsvc$5ep$1@dont-email.me>
<t8vt70$a38$1@dont-email.me> <t8vuo1$442$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="27528"; posting-host="tQGecgdXxZAKb1FaDldylw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Gerald Lester - Wed, 22 Jun 2022 21:24 UTC

On 6/22/22 15:40, aotto1968 wrote:
>
>>>
>>>> Question it is efficient to keep the code as it is **OR** to add a
>>>> global variable with a *non-changing* global value
>>>>
>>>> NEW
>>>>
>>>> set myRX "${::librx}(\\w+)$"
>>>
>>> I would expect that there is no big difference. The largest effort is
>>
>> Indeed, for a dynamic string like this, the global variable should be
>> faster. Still, the RE engine caches not only the conmpiled expressino
>> in the intrep, but also the most recently used expression strings in
>> order to deal with this problem of dynamically constructed const
>> strings. That is special to regexp and does not hold for any other
>> shimmering issue.
>>
>> Christian
>
> thanks for the answer… I think a lot of performance is lost in tcl
> because of the *const-by-logic* issue.
>...

Don't think/guess -- test using the timing commands!!!!

--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald.Lester@kng-consulting.net |
+----------------------------------------------------------------------+

Re: Question about TCL speed

<d53b770b-92da-4518-a31c-65dd340e58dfn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:600c:5107:b0:3a0:2d93:ae23 with SMTP id o7-20020a05600c510700b003a02d93ae23mr2146526wms.81.1655965733752;
Wed, 22 Jun 2022 23:28:53 -0700 (PDT)
X-Received: by 2002:a05:6808:180f:b0:331:47ed:5f74 with SMTP id
bh15-20020a056808180f00b0033147ed5f74mr1323873oib.255.1655965733003; Wed, 22
Jun 2022 23:28:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.88.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 22 Jun 2022 23:28:52 -0700 (PDT)
In-Reply-To: <t8vklm$uku$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=91.217.55.78; posting-account=Od2xOAoAAACEyRX3Iu5rYt4oevuoeYUG
NNTP-Posting-Host: 91.217.55.78
References: <t8vklm$uku$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d53b770b-92da-4518-a31c-65dd340e58dfn@googlegroups.com>
Subject: Re: Question about TCL speed
From: martin.heinrich@frequentis.com (heinrichmartin)
Injection-Date: Thu, 23 Jun 2022 06:28:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: heinrichmartin - Thu, 23 Jun 2022 06:28 UTC

On Wednesday, June 22, 2022 at 7:48:43 PM UTC+2, aotto1 wrote:
> this is a piece of code to delete a *const* prefix (librx) from a string
> (str)
>
> OLD:
>
> proc pCleanLibRx { str } {
> regsub "${::librx}(\\w+)$" $str {\1}
> }

Besides, the RE is not as intended. You could also test with [regsub "^${::librx}" $str ""]. Note the anchor at the beginning of the string. And not matching the full string might or might not be valid in your use case (i.e. only remove the prefix for special strings?).

Also, have you looked at ::textutil::trimPrefix [1]?

[1] https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/textutil/textutil.md#14

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor