Re: (blead patch) New TRIE regex patch
by Demerphq other posts by this author
Mar 2 2005 1:38AM messages near this date
Re: (blead patch) New TRIE regex patch
|
Re: (blead patch) New TRIE regex patch
On Wed, 2 Mar 2005 04:16:37 +0000, Dave Mitchell <davem@[...].com> wrote:
> On Wed, Mar 02, 2005 at 04:08:38AM +0000, hv@[...].org wrote:
> > Hmm, locking a 'refcount--' doesn't make much sense to me: if two threads
> > both do this at the same time, they'll still then both try to free the
> > structure. But I see that op_free() does essentially the same thing,
> > which confuses me. Can anyone explain how that makes sense?
>
> I haven't been following this thread closely (I don't even know what a
> trie is), but I'll chip in anyway.
A trie is a way of storing keys in a tree structure where the
branching logic is determined by the value of the digits of the key.
Ie: if we have "car", "cart", "carp", "call", "cull" and "cars" we can
build a trie like this:
c + a + r + t
| | |
| | + p
| | |
| | + s
| |
| + l - l
|
+ u - l - l
What the patch does is make /a | list | of | words/ into a trie that
matches those words. This means that we can efficiently tell if any of
the words are at a given location in a strng by simply walking the
string and trie at the same time. In many cases we can rule out the
entire list by looking at only one character of the input. The current
way perl handles this would require looking at N chars where N is the
number of words involved. (BTW: Thats the beauty of a trie, its lookup
time is independent of the number of words it stores but rather on the
key length of the word being looked up. )
BTW, should i send a more detailed high level explanation of what this
patch does? I assumed most people would be familiar with the ideas it
involves.
>
> In the op_free() case, an op tree may be shared by CVs from differnt threads.
> The head of the tree contains an OP refcnt, so OP_REFCNT_LOCK is used to
> lock it before decrementing it.
>
> On the other hand, using OP_REFCNT_LOCK to lock an SV doesn't seem to make
> much sense (but as I said, I havn't been paying close attention).
I was trying to give thread security to the refcounting of the trie
records. Is there a better/propper way to do this?
Also are you aware of any reason not to use SAVEFREEPV() inside of regmatch()?
Cheers,
Yves
--
First they ignore you, then they laugh at you, then they fight you,
then you win.
+Gandhi
Thread:
Yitzchak Scott-Thoennes
Demerphq
Demerphq
Yitzchak Scott-Thoennes
Dave Mitchell
Demerphq
Dave Mitchell
Demerphq
Dave Mitchell
Demerphq
Demerphq
Yitzchak Scott-Thoennes
Rafael Garcia-Suarez
|