notzed opened a new issue, #4141:
URL: https://github.com/apache/netbeans/issues/4141

   ### Apache NetBeans version
   
   Apache NetBeans 13
   
   ### What happened
   
   The output window has just always been very slow in general but _fails hard_ 
with long lines.  It makes netbeans feel very clunky and heavy and i always 
blamed it on swing and 'well, java is just kinda slow' even though i know it 
isn't.
   
   I traced it down to two trivial problems in 
extide/o.apache.tools.ant.module, file 
org.apache.tools.ant.module.bridge.impl.ForkedJoinOverride.java, method 
Copier::run().
   
   1. The `if (!STACK_TRACE.matcher(str).find())` call 
(ForkedJoinOverride.java:318) takes an extraordinary amount of time to execute 
on long lines.  This could be an openjdk issue.  Changing this to `if 
(!STACK_TRACE.matcher(str).matches())` speeds this up considerably but it's 
still terribly slow.  Note: java.project.JavaAntLogger uses .matches() and not 
.find() with the same regex.
   2. Calling in.read() and outputLine.write() one byte at a time. Changing 
this to read into a buffer first and then searching the buffer for '\n' with 
some simple logic to do everything in batches and avoid the conditional 
substring() delivers a further greater-than 20x speed improvement.  Note that 
simply using a bufferedinputstream doesn't help much.
   
   LOGGER_MAX_LINE_LENGTH default of 3000 also seems unreasonably long to avoid 
looking for stack traces.
   
   
   ### How to reproduce
   
   run this in an ant project.
   
       public static void main(String[] args) throws InterruptedException {
           for (int i = 0; i < 10000; i++) {
               for (int j = 0; j < 1000; j++) {
                   System.out.print(j);
               }
               System.out.println();
           }
       }
   
   As released netbeans will take in the order of 25 minutes(!!)  to run it to 
completion (ryzen 3900x, estimated, it was 16s for just 100 lines).  Just 
changing find() to matches() as suggested in 1. above it will complete in under 
2 minutes.  Fixing the code to use a locally buffered read and iterating over 
the byte array it will take about 5 seconds.
   
   
   ### Did this work correctly in an earlier version?
   
   No
   
   ### Operating System
   
   slackware64-current, gentoo
   
   ### JDK
   
   openjdk 18.0.1 from openjdk.net.  17.0.1 is no better.
   
   ### Apache NetBeans packaging
   
   Own source build
   
   ### Anything else
   
   I have prototype code but no suitable patch for this.
   
   
   ### Are you willing to submit a pull request?
   
   No
   
   ### Code of Conduct
   
   Yes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to