comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de>
Subject: Re: GNAT's stack checking in Ubuntu 9.04 (and Shootout regex-dna)
Date: Tue, 11 Aug 2009 01:34:05 +0200
Date: 2009-08-11T01:34:06+02:00	[thread overview]
Message-ID: <4a80ae6e$0$31877$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <9adb4985-582c-4cbf-906c-3afa7dcd31f6@g1g2000vbr.googlegroups.com>

jonathan wrote:

> I was going to give up on regexdna.adb, but I had to
> try one last thing. [...]
>    Stack_Size : constant Positive := 2000;
> 
> with
> 
>    Stack_Size : constant Positive := 129;
> 
> in GNAT_spitbol.patterns.

> The program running time (single-core) dropped [...]

Interesting.

Does regexdna-multi.ada work on your system?

On a dual core system it seems to be shortening
the running time by almost a third.

(The slowdown in general is in the match-replace part;
the (first) matching part seems to be performing well.)

> Last remark: someone with experience using the
> spitbol routines might be able to optimize
> further.  There are tricks using "anchors"
> mentioned in spec of GNAT.spitbol.patterns.

Yes, I went up and down all kinds of anchoring and
saving cursor positions and using a function pointer
whose function would replace behind the scene and then
return False (like in the Match case) thus advancing
without requiring the loop in the match-replace part
(relying on the backtracking mechanism which would not
trigger backtracking, since the function returned False).
I also tried a Match and Replace pair.
But the results always seemed to indicate this
issue with VString and replacements:

(1) the match-replace is dominated by VString
which is Unbounded_String which is slow replacing
string slices no matter how the replacement is done.
(See also Bob Duff's remarks on Unbounded_String
in this thread.)
Constructing a new VString, for example, using Append
did not help (I was hoping that no shifting of characters
would be necessary).

(2) the lines in the match-replace section are reasonably
short,  Any("A") is a correspondingly short linear search.
The captured match is exactly the one character that
is replaced.
While the search is restarted from the string's
beginning in every loop, anchoring didn't seem to
make things faster.  For example,
 Pos(Saved_Cursor)  -- saved after last match
  & Break("A")
  & Len(1)
  & Setcur(Saved_Cursor'Access)
will in general capture a span of characters not
to be replaced.  This then requires either copying
the saved parts or saving the cursor position and
calling the Replace procedure with a Match object.
Works, but has been invariably slower in both cases.

But there is no end to ideas using SPITBOL patterns,
so yes, maybe someone has another idea? :-)

SNOBOL-4:

There is a great implementation of SPITBOL by
Phil Budne at http://www.snobol4.org/

I learned about SNOBOL-4 some years ago through
the GNAT packages, and immediately wanted to learn it,
which I did.  A pleasant experience---if you can avoid
debugging patterns :-)  Tables, Lists, user defined
types, type conversions, CODE, computed goto,
multiple function entry points,  and all this accessible
everywhere including in patterns! :)
I liked the SNOBOL-4 introduction by Susan Hockey,
Gimpel's book is a SNOBOL-4 treasure trove.



  parent reply	other threads:[~2009-08-10 23:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 22:54 GNAT's stack checking in Ubuntu 9.04 (and Shootout regex-dna) Georg Bauhaus
2009-08-03 22:56 ` Georg Bauhaus
2009-08-04  7:50   ` Ludovic Brenta
2009-08-04  9:17     ` Georg Bauhaus
2009-08-04  9:58       ` Vadim Godunko
2009-08-04 10:44         ` Georg Bauhaus
2009-08-04 12:30           ` Vadim Godunko
2009-08-04 14:15             ` Georg Bauhaus
2009-08-04 22:20         ` Egil
2009-08-04 15:38       ` Robert A Duff
2009-08-04 11:59 ` Brian Drummond
2009-08-04 14:18   ` Georg Bauhaus
2009-08-09 19:13   ` Georg Bauhaus
2009-08-10 13:10     ` jonathan
2009-08-10 20:12     ` jonathan
2009-08-10 20:29       ` Ludovic Brenta
2009-08-10 23:34       ` Georg Bauhaus [this message]
2009-08-11 20:02         ` jonathan
2009-08-11 21:19           ` jonathan
2009-08-11 21:38           ` Georg Bauhaus
2009-08-11  0:27       ` Georg Bauhaus
2009-08-11 19:05         ` jonathan
2009-08-12  9:32           ` Ludovic Brenta
2009-08-12 16:37             ` jonathan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox