rjkroege/edwood

Backword search is too slow

Closed this issue · 1 comments

When using win in edwood, it's natual to execute some shell commands.
I execute make under a project, the output log is long and result in a error.
Then I want to backword search for the error message and execute this:

Edit -/FAIL

The program hang, CPU usage reach 100% with the stack looks like this:

goroutine 84 [runnable]:
github.com/rjkroege/edwood/internal/regexp.(*machine).step(0xc0002da0f0, 0xc0002da130, 0xc0002da100, 0x19f85, 0x19f86, 0x30, 0xc0001d0b88)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/internal/regexp/exec.go:260 +0x6d0
github.com/rjkroege/edwood/internal/regexp.(*machine).match1(0xc0002da0f0, 0x9e2c20, 0xc0002381b0, 0x171f2, 0x0)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/internal/regexp/runesb.go:160 +0x1fc
github.com/rjkroege/edwood/internal/regexp.(*Regexp).doExecuteInput1(0xc0002e2090, 0x9e2c20, 0xc0002381b0, 0x171f2, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/internal/regexp/runesb.go:102 +0x84
github.com/rjkroege/edwood/internal/regexp.(*Regexp).allMatchesRunesBackward(0xc0002e2090, 0xc000516000, 0x31964, 0x3b000, 0x0, 0x31964, 0xa, 0xc0001d0d30)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/internal/regexp/runesb.go:63 +0x13c
github.com/rjkroege/edwood/internal/regexp.(*Regexp).FindBackward(0xc0002e2090, 0xc000516000, 0x31964, 0x3b000, 0x0, 0x31964, 0xa, 0xc0001d0dd8, 0x81393e, 0x92b980)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/internal/regexp/runesb.go:23 +0xfc
main.(*AcmeRegexp).rxbexecute(0xc0000fe020, 0x9e6860, 0xc000500120, 0x31964, 0xa, 0x3, 0x8f28a0, 0xc0001deb30)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/regx.go:37 +0xcb
main.nextmatch(0xc000502100, 0xc0001deb34, 0x4, 0x31964, 0xffffffffffffffff)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/ecmd.go:873 +0x35b
main.cmdaddress(0xc000238090, 0x31964, 0x31964, 0xc000502100, 0xffffffffffffffff, 0x0, 0x0, 0x432d60)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/ecmd.go:924 +0x587
main.cmdexec(0xc000500120, 0xc0001fa000, 0xc0001fa000)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/ecmd.go:82 +0x18f
main.editthread(0xc000257060)
	/media/genius/OS/project/src/github.com/rjkroege/edwood/edit.go:160 +0xbd
created by main.editcmd
	/media/genius/OS/project/src/github.com/rjkroege/edwood/edit.go:228 +0x1d5

Backword search is generally slow, this issue could be reproduce with any data long enough.

I think (cautiously) that the strategy to fix this is for file.ObservableEditableBuffer to implement a (reversed) io.RuneReader which could then be given to the Go regex code?