Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4675952

java.util.regex routines should use less stack space

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 1.4.1
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      x86
    • OS:
      generic

      Description

      The following magic program breaks on most x86 platforms.

      Sparc 32-bit:----------
      Runs with 6meg of stack; dies with stackoverflow with 4meg for both client and server, -Xint more or -Xmixed.

      WinNT:----------
      Dies with stackoverflow for both client & server, in mixed and -Xint modes for both, up to -Xss128m.

      At -Xss256m, client -Xint crashes; server -Xint gets a
      Fatal: Unable to create signal thread (may be due to resource limit)

      Linux:-----------
      RUNS -client with no other stack options.
      Dies with -client -Xint with stackoverflow.
      Dies with -client -Xint -Xss128meg with stackoverflow.
      Dies with -server, -server -Xint, -server -Xint -Xss128meg, -server -Xss128meg with stack overflow

      SolX86:-----------
      Runs with 4meg of stack; dies with stackoverflow with 4meg for both client and server, -Xint more or -Xmixed.

      ###@###.### 2002-04-26


      import java.util.regex.*;
      public class JavaBenchmark {
       public static void main(String [] args)
       {
         Matcher Regex1 = Pattern.compile("^(a|b|c|d|e|f|g)+$").matcher("");
         Matcher Regex2 = Pattern.compile("^[a-g]+$").matcher("");
         long TimesToDo = 2000;

         StringBuffer Temp = new StringBuffer();
         for (int i = 500; i > 0; i--)
                 Temp.append("abababdedfg");
         String TestString = Temp.toString();

         // Time first one...
         long Count = TimesToDo;
         long StartTime = System.currentTimeMillis();
         while (--Count > 0)
               Regex1.reset(TestString).matches();
         double Seconds = (System.currentTimeMillis()-StartTime)/1000.0;
         System.out.println("Alternation takes " + Seconds + " seconds");

         // Time second one...
         Count = TimesToDo;
         StartTime = System.currentTimeMillis();
         while (--Count > 0)
               Regex2.reset(TestString).matches();
         Seconds = (System.currentTimeMillis()-StartTime)/1000.0;
         System.out.println("Character Class takes " + Seconds + " seconds");
       }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sherman Xueming Shen
                Reporter:
                cclicksunw Clifford Click (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: