Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regexp: regex is much slower than java #16758

Closed
liketic opened this issue Aug 17, 2016 · 2 comments
Closed

regexp: regex is much slower than java #16758

liketic opened this issue Aug 17, 2016 · 2 comments

Comments

@liketic
Copy link

liketic commented Aug 17, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go1.6 darwin/amd64
  2. What operating system and processor architecture are you using (go env)?
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
  3. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

I found Go regex is too slow. I compared the regex perf between java and Go:
Go code:

text := "$value1$;$value2$;$value3$"
    for i := 0; i < 1000000; i++ {
        match := pattern.FindAllStringSubmatch(text, -1)
        for _, _ = range match {
        }
    }

Java code:

        String value = "$value1$;$value2$;$value3$";
        for (int i = 0; i < 1000000; i++) {
            Matcher matcher = pattern.matcher(value);
            while (matcher.find()) {
                // do nothing
            }
        }

Go costs 2.702s and Java costs 472ms.

  1. What did you expect to see?
    I think Go regex should not slower than Java so much.
  2. What did you see instead?
    Go regex is much slower than Java.
@rakyll
Copy link
Contributor

rakyll commented Aug 17, 2016

Go regex is known to be slower than Java (such as [1]). Is there a recent case you are reporting where you have seen a major perf downgrade or are you talking about the general case where Go is known to be slower?

I don't know the current involvement but making the regex more performant is a long-shot goal, not sure we can keep track of it under an issue on the tracker.

[1] http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=java&lang2=go

@bradfitz
Copy link
Contributor

There are more concrete bugs tracking this... #15643, #13288, #11646, etc.

Closing this as a dup.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants