[hg] releases: fixing Bug #225299 Detect C/C++ specific performa...

  • From: Alexander Simon < >
  • To: ,
  • Subject: [hg] releases: fixing Bug #225299 Detect C/C++ specific performa...
  • Date: Fri, 01 Feb 2013 04:08:54 -0800

changeset d7afc3ee9ef6 in releases ((none))
details: http://hg.netbeans.org/releases/rev/d7afc3ee9ef6
description:
        fixing Bug #225299 Detect C/C++ specific performance problem
        - add infinite parsing notification

diffstat:

 cnd.discovery/nbproject/project.xml                                          
                  |   2 +-
 
cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/NotifyProjectProblem.java
     |  28 +++++
 
cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/PerformanceIssueDetector.java
 |  52 +++++++++-
 dlight.libs.common/nbproject/project.properties                              
                  |   2 +-
 
dlight.libs.common/src/org/netbeans/modules/dlight/libs/common/PerformanceLogger.java
          |  20 +++-
 5 files changed, 96 insertions(+), 8 deletions(-)

diffs (256 lines):

diff --git a/cnd.discovery/nbproject/project.xml 
b/cnd.discovery/nbproject/project.xml
--- a/cnd.discovery/nbproject/project.xml
+++ b/cnd.discovery/nbproject/project.xml
@@ -115,7 +115,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>1.22</specification-version>
+                        <specification-version>1.23</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
diff --git 
a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/NotifyProjectProblem.java
 
b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/NotifyProjectProblem.java
--- 
a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/NotifyProjectProblem.java
+++ 
b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/NotifyProjectProblem.java
@@ -111,11 +111,28 @@
                                                 +"</ul>\n"
                                                 +"Details:<br>\n"
                                                 +"{1}"
+    ,"NotifyProjectProblem.infinite.parse.message.text=Infinite File Parsing"
+    ,"NotifyProjectProblem.infinite.parse.adviceL.text=<li>Exclude files 
from code assistance</li>\n"
+                                                     +"<li>Filter out files 
from project</li>\n"
+                                                     +"<li>Open the project 
on a more powerful computer by using VNC or X11 forwarding</li>\n"
+    ,"NotifyProjectProblem.infinite.parse.adviceR.text=<li>Exclude files 
from code assistance</li>\n"
+                                                     +"<li>Filter out files 
from project</li>\n"
+                                                     +"<li>Open the project 
on a more powerful computer by using VNC or X11 forwarding</li>\n"
+    ,"# {0} - advice"
+    ,"# {1} - details"
+    ,"NotifyProjectProblem.infinite.parse.explanation.text=The IDE has 
detected infinite files parsing, which is caused by a bug in the IDE or too 
big files.<br>\n"
+                                                         +"To resolve this 
problem, you can try:<br>\n"
+                                                         +"<ul>\n"
+                                                         +"{0}"
+                                                         +"</ul>\n"
+                                                         +"Details:<br>\n"
+                                                         +"{1}"
 })
 public class NotifyProjectProblem extends javax.swing.JPanel {
     public static final int CREATE_PROBLEM = 1;
     public static final int READ_PROBLEM = 2;
     public static final int PARSE_PROBLEM = 3;
+    public static final int INFINITE_PARSE_PROBLEM = 4;
 
     /**
      * Creates new form NotifyProjectProblem
@@ -166,6 +183,17 @@
                 shortDescription = 
Bundle.NotifyProjectProblem_parse_message_text();
                 break;
             }
+            case INFINITE_PARSE_PROBLEM: {
+                String advice;
+                if (isRemoteSources) {
+                    advice = 
Bundle.NotifyProjectProblem_infinite_parse_adviceR_text();
+                } else {
+                    advice = 
Bundle.NotifyProjectProblem_infinite_parse_adviceL_text();
+                }
+                explanation = 
Bundle.NotifyProjectProblem_infinite_parse_explanation_text(advice, details);
+                shortDescription = 
Bundle.NotifyProjectProblem_infinite_parse_message_text();
+                break;
+            }
             default:
                 throw new IllegalArgumentException();
         }
diff --git 
a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/PerformanceIssueDetector.java
 
b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/PerformanceIssueDetector.java
--- 
a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/PerformanceIssueDetector.java
+++ 
b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/performance/PerformanceIssueDetector.java
@@ -44,6 +44,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -75,6 +76,7 @@
     private final Map<String,ReadEntry> readPerformance = new 
HashMap<String,ReadEntry>();
     private final Map<String,CreateEntry> createPerformance = new 
HashMap<String,CreateEntry>();
     private final Map<String,ParseEntry> parsePerformance = new 
HashMap<String,ParseEntry>();
+    private final Map<FileObject,PerformanceLogger.PerformanceEvent> 
parseTimeOut = new HashMap<FileObject,PerformanceLogger.PerformanceEvent>();
     private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
     private final ScheduledFuture<?> periodicTask;
     private static final int SCHEDULE = 15; // period in seconds
@@ -194,15 +196,17 @@
     }
 
     private void processGetItemFileObject(PerformanceLogger.PerformanceEvent 
event) {
+        Item item = (Item) event.getSource();
+        long time = event.getTime();
+        String path = item.getAbsPath();
         if (event.getAttrs().length == 0) {
             //TODO: process timeout
+            LOG.log(timeOutLevel, "Timeout {0}s of find file object {1}", 
new Object[]{time/NANO_TO_SEC, path}); //NOI18N
             return;
         }
-        Item item = (Item) event.getSource();
-        long time = event.getTime();
+        String dirName = CndPathUtilitities.getDirName(path);
         long cpu = event.getCpuTime();
         long user = event.getUserTime();
-        String dirName = 
CndPathUtilitities.getDirName(item.getAbsolutePath());
         lock.writeLock().lock();
         try {
             CreateEntry entry = createPerformance.get(dirName);
@@ -255,6 +259,12 @@
         if (event.getAttrs().length == 0) {
             //TODO: process timeout
             LOG.log(timeOutLevel, "Timeout {0}s of parsing file{1}", new 
Object[]{time/NANO_TO_SEC, fo.getPath()}); //NOI18N
+            lock.writeLock().lock();
+            try {
+                parseTimeOut.put(fo, event);
+            } finally {
+                lock.writeLock().unlock();
+            }
             return;
         }
         int readLines = ((Integer) event.getAttrs()[0]).intValue();
@@ -263,6 +273,7 @@
         String dirName = CndPathUtilitities.getDirName(fo.getPath());
         lock.writeLock().lock();
         try {
+            parseTimeOut.remove(fo);
             ParseEntry entry = parsePerformance.get(dirName);
             if (entry == null) {
                 entry = new ParseEntry();
@@ -311,6 +322,7 @@
             analyzeCreateItems();
             analyzeReadFile();
             analyzeParseFile();
+            analyzeInfiniteParseFile();
         } catch (Throwable ex) {
             ex.printStackTrace(System.err);
         } finally {
@@ -450,6 +462,40 @@
                 new Object[]{format(parseSpeed), format(lines), 
format(time/NANO_TO_MILLI), format(cpu/NANO_TO_MILLI), 
format(user/NANO_TO_MILLI)});
     }
 
+    @Messages({
+         "# {0} - table"
+        ,"Details.infinite.files.parse=The parsing of the files:\n"
+                                     +"<table><tbody>\n"
+                                     +"<tr><th>File</th><th>Time, 
s</th><tr>\n"
+                                     +"{0}\n"
+                                     +"</tbody></table>\n"
+                                     +"are nether finished or consumes too 
much time.<br>\n"
+        ,"# {0} - file"
+        ,"# {1} - time"
+        ,"Details.infinite.file.parse=<tr><td>{0}</td><td>{1}</td>\n"
+    })
+    private void analyzeInfiniteParseFile() {
+        StringBuilder buf = new StringBuilder();
+        Iterator<Map.Entry<FileObject, PerformanceLogger.PerformanceEvent>> 
iterator = parseTimeOut.entrySet().iterator();
+        while(iterator.hasNext()) {
+            Map.Entry<FileObject, PerformanceLogger.PerformanceEvent> entry 
= iterator.next();
+            FileObject fo = entry.getKey();
+            PerformanceLogger.PerformanceEvent event = entry.getValue();
+            long delta = (System.nanoTime() - 
event.getStartTime())/NANO_TO_SEC;
+            if (delta > 100) {
+                iterator.remove();
+                buf.append(Bundle.Details_infinite_file_parse(fo.getPath(), 
format(delta)));
+                LOG.log(Level.INFO, "Too long file {0} parsing time {1}s. 
Probably parser has infinite loop or file is too big", new 
Object[]{fo.getPath(), format(delta)}); //NOI18N
+            }
+        }
+        if (buf.length() > 0) {
+            if (!CndUtils.isUnitTestMode() && !CndUtils.isStandalone()) {
+                String details = 
Bundle.Details_infinite_files_parse(buf.toString());
+                notifyProblem(NotifyProjectProblem.INFINITE_PARSE_PROBLEM, 
details);
+            }
+        }
+    }
+
     private String format(long val) {
         String res = Long.toString(val);
         StringBuilder buf = new StringBuilder();
diff --git a/dlight.libs.common/nbproject/project.properties 
b/dlight.libs.common/nbproject/project.properties
--- a/dlight.libs.common/nbproject/project.properties
+++ b/dlight.libs.common/nbproject/project.properties
@@ -1,6 +1,6 @@
 is.autoload=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
-spec.version.base=1.22
+spec.version.base=1.23
 
 test.config.stableBTD.includes=**/*Test.class
diff --git 
a/dlight.libs.common/src/org/netbeans/modules/dlight/libs/common/PerformanceLogger.java
 
b/dlight.libs.common/src/org/netbeans/modules/dlight/libs/common/PerformanceLogger.java
--- 
a/dlight.libs.common/src/org/netbeans/modules/dlight/libs/common/PerformanceLogger.java
+++ 
b/dlight.libs.common/src/org/netbeans/modules/dlight/libs/common/PerformanceLogger.java
@@ -91,6 +91,7 @@
          * Event will be automatically logged after time out.
          * By default time out is infinite.
          * The automatic logging does not prevent final logging by method 
log.
+         * It is ensured that timeout event is sent before regular logging 
event or does not be sent.
          * 
          * @param timeOut in seconds
          */
@@ -148,6 +149,12 @@
 
         /**
          *
+         * @return event start time in nanoseconds
+         */
+        long getStartTime();
+
+        /**
+         *
          * @return wall time from start to log event in nanoseconds
          */
         long getTime();
@@ -290,7 +297,7 @@
                 cpuTime = 0;
                 userTime = 0;
             }
-            PerformanceEvent event = new PerformanceEventImpl(action.id, 
action.source, delta, cpuTime, userTime, usedMemeory, extra);
+            PerformanceEvent event = new PerformanceEventImpl(action.id, 
action.source, action.start, delta, cpuTime, userTime, usedMemeory, extra);
             lineLock.writeLock().lock();
             try {
                 register.remove(action);
@@ -308,7 +315,7 @@
             long usedMemeory = runtime.totalMemory() - runtime.freeMemory();
             long cpuTime = 0;
             long userTime = 0;
-            PerformanceEvent event = new PerformanceEventImpl(action.id, 
action.source, delta, cpuTime, userTime, usedMemeory, new Object[0]);
+            PerformanceEvent event = new PerformanceEventImpl(action.id, 
action.source, action.start, delta, cpuTime, userTime, usedMemeory, new 
Object[0]);
             lineLock.writeLock().lock();
             try {
                 Integer remove = register.remove(action);
@@ -353,15 +360,17 @@
 
         private final String id;
         private final Object source;
+        private final long startTime;
         private final long time;
         private final long cpu;
         private final long user;
         private final Object[] extra;
         private final long usedMemeory;
 
-        private PerformanceEventImpl(String id, Object source, long time, 
long cpu, long user, long usedMemeory, Object[] extra) {
+        private PerformanceEventImpl(String id, Object source, long 
startTime, long time, long cpu, long user, long usedMemeory, Object[] extra) {
             this.id = id;
             this.source = source;
+            this.startTime = startTime;
             this.time = time;
             this.cpu = cpu;
             this.user = user;
@@ -385,6 +394,11 @@
         }
 
         @Override
+        public long getStartTime() {
+            return startTime;
+        }
+
+        @Override
         public long getTime() {
             return time;
         }

[hg] releases: fixing Bug #225299 Detect C/C++ specific performa...

Alexander Simon 02/01/2013

<Possible follow-up(s)>

[hg] releases: fixing Bug #225299 Detect C/C++ specific performa...

Alexander Simon 02/01/2013

[hg] releases: fixing Bug #225299 Detect C/C++ specific performa...

Alexander Simon 02/07/2013

[hg] releases: fixing Bug #225299 Detect C/C++ specific performa...

Alexander Simon 02/08/2013

Project Features

About this Project

CND was started in November 2009, is owned by Leonid Lenyashin, and has 130 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close