From a9296bf6ee794d8726f013c254654bb606da0b7e Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Wed, 27 Apr 2016 12:49:25 -0400 Subject: [PATCH] regexp: update README --- README.md | 9 +++++++-- exec_test.go | 6 ++++++ internal/dfa/dfa.go | 8 ++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0476a7d..145f4b0 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,10 @@ See [golang.org/cl/12081](https://golang.org/cl/12081) -* The regexp conformance tests pass, but there's still work to be done on state cache management, thread-safety, and readability. -* Please don't use this in production. +* The regexp tests pass. Though there may still be uncaught bugs. + Let me know if you find any of them! No guarantees! +* regexp/internal/dfa tests are currently failing. I need to fix + some thingsn there. +* I've got a small change to the DFA that uses package unsafe + and makes matches 2x faster. I'll try to get it up soon. +* A bunch of cleanup needs to be done all over this package. diff --git a/exec_test.go b/exec_test.go index 737b60b..bba7799 100644 --- a/exec_test.go +++ b/exec_test.go @@ -675,6 +675,7 @@ const ( easy1 = "A[AB]B[BC]C[CD]D[DE]E[EF]F[FG]G[GH]H[HI]I[IJ]J$" medium = "[XYZ]ABCDEFGHIJKLMNOPQRSTUVWXYZ$" hard = "[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$" + hard1 = "ABCE|CDEG|GHIK|HIJM|IJKN|KLMO|LMNP|PQRT|STUW|WXYA" ) func BenchmarkMatchEasy0_32(b *testing.B) { benchmark(b, easy0, 32<<0) } @@ -697,6 +698,11 @@ func BenchmarkMatchHard_1K(b *testing.B) { benchmark(b, hard, 1<<10) } func BenchmarkMatchHard_32K(b *testing.B) { benchmark(b, hard, 32<<10) } func BenchmarkMatchHard_1M(b *testing.B) { benchmark(b, hard, 1<<20) } func BenchmarkMatchHard_32M(b *testing.B) { benchmark(b, hard, 32<<20) } +func BenchmarkMatchHard1_32(b *testing.B) { benchmark(b, hard1, 32<<0) } +func BenchmarkMatchHard1_1K(b *testing.B) { benchmark(b, hard1, 1<<10) } +func BenchmarkMatchHard1_32K(b *testing.B) { benchmark(b, hard1, 32<<10) } +func BenchmarkMatchHard1_1M(b *testing.B) { benchmark(b, hard1, 1<<20) } +func BenchmarkMatchHard1_32M(b *testing.B) { benchmark(b, hard1, 32<<20) } func TestLongest(t *testing.T) { re, err := Compile(`a(|b)`) diff --git a/internal/dfa/dfa.go b/internal/dfa/dfa.go index 5fed543..50b423e 100644 --- a/internal/dfa/dfa.go +++ b/internal/dfa/dfa.go @@ -88,18 +88,18 @@ var errFallBack = errors.New("falling back to NFA") func (d *DFA) loadNextState(from *State, r rune) *State { // TODO(matloob): Do an atomic read from from.next and eliminate mutex. runerange := d.rangemap.lookup(r) - from.mu.Lock() +// from.mu.Lock() s := from.next[runerange] - from.mu.Unlock() +// from.mu.Unlock() return s } func (d *DFA) storeNextState(from *State, r rune, to *State) { // TODO(matloob): Do an atomic write to from.next and eliminate mutex. runerange := d.rangemap.lookup(r) - from.mu.Lock() +// from.mu.Lock() from.next[runerange] = to - from.mu.Unlock() +// from.mu.Unlock() } func (d *DFA) analyzeSearch(params *searchParams) bool {