I hope this is the right place to send a tiny patch. In any case, this minor recoding makes the syntax check go a whole lot faster. Curtis Index: src/syntax.pl =================================================================== RCS file: /usr/local/CVS-routing-dev/irr-source/dbase/src/syntax.pl,v retrieving revision 2.4 diff -c -r2.4 syntax.pl *** syntax.pl 1997/11/14 20:49:12 2.4 --- syntax.pl 1998/03/17 19:59:25 *************** *** 490,501 **** # # Now check the actual keywords # ! while($tmppol =~ s/(\S+)//) { ! if (!&isaskeyword($1)) { ! return $O_ERROR, ! "syntax error in \"$ATTL{$key}: peer $as cost $pref\"\n\t$1 ". ! ! "is not a routing policy KEYWORD"; } } return $O_OK; --- 490,501 ---- # # Now check the actual keywords # ! local($tmpword); ! foreach $tmpword ( split("\\s+", "$tmppol") ) { ! if (!&isaskeyword($tmpword)) { ! return $O_ERROR, ! "syntax error in \"$ATTL{$key}: peer $as cost $pref\"\n". ! \t$tmpword is not a routing policy KEYWORD"; } } return $O_OK;
I don't run the code myself, but..... On Tue, 17 Mar 1998, Curtis Villamizar wrote:
Index: src/syntax.pl =================================================================== RCS file: /usr/local/CVS-routing-dev/irr-source/dbase/src/syntax.pl,v retrieving revision 2.4 diff -c -r2.4 syntax.pl *** syntax.pl 1997/11/14 20:49:12 2.4 --- syntax.pl 1998/03/17 19:59:25 *************** *** 490,501 **** # # Now check the actual keywords # ! while($tmppol =~ s/(\S+)//) { ! if (!&isaskeyword($1)) { ! return $O_ERROR, ! "syntax error in \"$ATTL{$key}: peer $as cost $pref\"\n\t$1 ". ! ! "is not a routing policy KEYWORD"; } } return $O_OK; --- 490,501 ---- # # Now check the actual keywords # ! local($tmpword); ! foreach $tmpword ( split("\\s+", "$tmppol") ) { ! if (!&isaskeyword($tmpword)) { ! return $O_ERROR, ! "syntax error in \"$ATTL{$key}: peer $as cost $pref\"\n". ! \t$tmpword is not a routing policy KEYWORD";
Aren't you missing a " in the beginning here?
} } return $O_OK;
Also, wouldn't this use of split by ever so slightly faster? : split(/\s+/, $tmppol) Sorry, I always use / instead of ' here, but I was mostly referring to wrapping $tmppol. Just a thought. I guess it's hard to measure :-) -- Robert Martin-Leghne (RM59), Network Manager, DKnet (AS2109), Denmark main(){int a[2],b[2];pipe(a);pipe(b);if(fork()){dup2(a[0],0);dup2(b[1],1) ;}else{dup2(b[0],0);dup2(a[1],1);write(1,"R",1);}execlp("cat","cat",0);}
In message <Pine.GSO.3.96.980317212825.9361D-100000@ns.DK.net>, Robert Martin-L egene writes:
I don't run the code myself, but.....
On Tue, 17 Mar 1998, Curtis Villamizar wrote:
Index: src/syntax.pl =================================================================== RCS file: /usr/local/CVS-routing-dev/irr-source/dbase/src/syntax.pl,v retrieving revision 2.4 diff -c -r2.4 syntax.pl *** syntax.pl 1997/11/14 20:49:12 2.4 --- syntax.pl 1998/03/17 19:59:25 *************** *** 490,501 **** # # Now check the actual keywords # ! while($tmppol =~ s/(\S+)//) { ! if (!&isaskeyword($1)) { ! return $O_ERROR, ! "syntax error in \"$ATTL{$key}: peer $as cost $pref\"\n\t$1 ". ! ! "is not a routing policy KEYWORD"; } } return $O_OK; --- 490,501 ---- # # Now check the actual keywords # ! local($tmpword); ! foreach $tmpword ( split("\\s+", "$tmppol") ) { ! if (!&isaskeyword($tmpword)) { ! return $O_ERROR, ! "syntax error in \"$ATTL{$key}: peer $as cost $pref\"\n". ! \t$tmpword is not a routing policy KEYWORD";
Aren't you missing a " in the beginning here?
Yes. I debugged, edited the original change one more time, mailed, tried it and fixed it. Already mailed. Oops.
} } return $O_OK;
Also, wouldn't this use of split by ever so slightly faster? :
split(/\s+/, $tmppol)
This was a serious performance problem, not just an inconsequential tweak. It went from over an hour to a few minutes for the very long string that is the as-in statement for AS1673. The difference is changing the length of the string $tmppol a few thousand times vs a single string split operation. Whether avoiding the double quotes around $tmppol or avoiding the local variable $tmpword would cut off another few seconds doesn't really matter much. Curtis
Curtis Villamizar wrote:
I hope this is the right place to send a tiny patch. In any case, this minor recoding makes the syntax check go a whole lot faster.
I have no idea about the right place, however, being a strict perl devotee, I couldn't let the following slip by:
! foreach $tmpword ( split("\\s+", "$tmppol") ) {
*horrified*. I guess you normally use TCL where such constructs are normal? I'd write (which makes it even faster because the regexp needn't be compiled every time) foreach $tmpword ( split( /\s+/, $tmppol ) ) { Sorry for the extra intrusion, -- #! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl ++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_; ($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)= \$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`
In message <199803172224.XAA24402@xs1.xs4all.nl>, Jan-Pieter Cornet writes:
Curtis Villamizar wrote:
I hope this is the right place to send a tiny patch. In any case, this minor recoding makes the syntax check go a whole lot faster.
I have no idea about the right place, however, being a strict perl devotee, I couldn't let the following slip by:
! foreach $tmpword ( split("\\s+", "$tmppol") ) {
*horrified*. I guess you normally use TCL where such constructs are normal? I'd write (which makes it even faster because the regexp needn't be compiled every time)
foreach $tmpword ( split( /\s+/, $tmppol ) ) {
Sorry for the extra intrusion,
We went from almost 2 hourse to under 10 minutes and you want to improve appearance and shave one large string copy and probably a few milliseconds. You guys just don't get it: while ($tmppol=~ s/(\S+)//) { On a very long string with a few thousand "words" this change the length of the string a couple of thousand times. These are the kind of things that actually make a difference. Thanks for the practical suggestion. :-) Curtis
You guys just don't get it:
while ($tmppol=~ s/(\S+)//) {
On a very long string with a few thousand "words" this change the length of the string a couple of thousand times. These are the kind of things that actually make a difference.
Erm - I realise this is reaching irrelevancy, but part of the point is the "non-standard" code; "\\s+" as a split operator is "not perl". A future maintainer will think there was some tricky reason for doing this rather than the standard split(/\s+/, ...) or split(' ', ...) And the thing to remember is that Perl is a language of optimisations; it's a scripting language not a system programming language. When you can use a perl optimisation without entering an obfuscation contest, it is always worth using them. That said, I personally find it's just easier not to argue with the nano-second saving perlmeisers :-); perlers are a very religious bunch, with a tendency to opt out of the laziness principle when it comes to discussing SEC (someone elses code). Oliver
Hi, sorry for the late response. it has been a little hectic around here at the NCC lately. Anyway we will be incorporating this into the code and make sure there are no side effects. Thanks for the input Curtis (et al), Joao Damas RIPE NCC
Hi, I tried to stay out of this obscure discussion but I recently had the luck to talk to Larry Wall and he had some nice relevant comments that I would like to share with all of you ... Oliver Smith writes:
And the thing to remember is that Perl is a language of optimisations; it's a scripting language not a system programming language. When you can use a perl optimisation without entering an obfuscation contest, it is always worth using them.
But Larry assurred me that writing a registry database in perl is a good thing to do, however, we should not have made this fact public for the people that are not 'enlightened' yet ... (Editorial comment: I don't know if the following is blasphemy but: I am not sure if I can fully agree since many people that know me, know that I actually already think for many years that a more solid foundation for such a piece of important software is a good thing (TM))
That said, I personally find it's just easier not to argue with the nano-second saving perlmeisers :-); perlers are a very religious bunch, with a tendency to opt out of the laziness principle when it comes to discussing SEC (someone elses code).
To add some more religion to the discussion: Do not forget Larry's philosophy which applies her quite well: There's More Than One Way To Do It! David K. ---
I have no idea about the right place, however, being a strict perl devotee, I couldn't let the following slip by:
! foreach $tmpword ( split("\\s+", "$tmppol") ) {
*horrified*. I guess you normally use TCL where such constructs are normal? I'd write (which makes it even faster because the regexp needn't be compiled every time)
foreach $tmpword ( split( /\s+/, $tmppol ) ) {
The optimum includes ignoring leading and trailing blanks, which is: foreach $tmpword (split(' ', $tmppol)) { This behaviour is documented as providing emulation of AWK behaviour. Oliver
participants (6)
-
Curtis Villamizar
-
davidk@ISI.EDU
-
Jan-Pieter Cornet
-
Joao Luis Silva Damas
-
Oliver Smith
-
Robert Martin-Legene