BUILD: improve CDT indexer's performance
authorGun Kim <gune.kim@samsung.com>
Wed, 7 Sep 2016 06:07:22 +0000 (15:07 +0900)
committerGun Kim <gune.kim@samsung.com>
Thu, 8 Sep 2016 01:46:54 +0000 (10:46 +0900)
When the project is created, CDT indexer will use a pre-built PDOM on which rootstrap information is written.

Change-Id: I4360bd90c063262c00e4ceb4c6b2082aa01fe5af
Signed-off-by: Gun Kim <gune.kim@samsung.com>
core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IIndexTaskProvider.java [new file with mode: 0644]
core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMRebuildTask.java
core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMUpdateTask.java
core/org.eclipse.cdt.core/plugin.xml
core/org.eclipse.cdt.core/pom.xml
core/org.eclipse.cdt.core/schema/IndexTaskProvider.exsd [new file with mode: 0644]
pom.xml

index 11216c0..5d0d55a 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
-Bundle-Version: 5.11.0.qualifier
+Bundle-Version: 5.11.0.201602051005
 Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
index f4c9e6e..6473a4f 100644 (file)
  *     Thomas Corbat (IFS)
  *     Marc-Andre Laperle (Ericsson)
  *******************************************************************************/
+/**
+* 2016-09-07 Gun Kim gune.kim@samsung.com
+* Modifications by S-Core Co., Ltd.
+* 1. Improved CDT indexer's performance when the project is created
+*/
+
 package org.eclipse.cdt.internal.core.pdom;
 
 import java.lang.reflect.InvocationTargetException;
@@ -94,6 +100,10 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
        private static enum UpdateKind { REQUIRED_SOURCE, REQUIRED_HEADER, ONE_LINKAGE_HEADER, OTHER_HEADER }
 
        private static final Pattern HEADERNAME_PATTERN = Pattern.compile("@headername\\{(?<header>[^\\}]+)\\}");  //$NON-NLS-1$
+       /* Tizen */
+       private boolean isReusage = false;
+       private IScannerInfo scannerInfo;
+       /* ===== */
 
        private static class LinkageTask {
                final int fLinkageID;
@@ -1009,8 +1019,22 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
                }
        }
 
+       /* Tizen */
+       public void setReuseBuildOption(boolean isReusage) {
+               this.isReusage = isReusage;
+       }
+       /* ===== */
+
+       /* Tizen */
+//             final IScannerInfo scannerInfo = fResolver.getBuildConfiguration(linkageID, contextTu);
        private IScannerInfo getScannerInfo(int linkageID, Object contextTu) {
-               final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, contextTu);
+               if (isReusage) {
+                       if (scannerInfo != null) {
+                               return scannerInfo;
+                       }
+               }
+               scannerInfo = fResolver.getBuildConfiguration(linkageID, contextTu);
+       /* ===== */
                if (scannerInfo instanceof ExtendedScannerInfo) {
                        ExtendedScannerInfo extendedScannerInfo = (ExtendedScannerInfo) scannerInfo;
                        extendedScannerInfo.setIncludeExportPatterns(getIncludeExportPatterns());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IIndexTaskProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IIndexTaskProvider.java
new file mode 100644 (file)
index 0000000..23de495
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Gun Kim <gune.kim@samsung.com>
+ * SangHo Park <sangho.p@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.eclipse.cdt.internal.core.pdom;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.IPDOMIndexer;
+import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
+import org.eclipse.cdt.core.model.ICProject;
+
+/**
+ * This interface is for providing <@code IPDOMIndexerTask> to index source files on project.
+ *
+ * @author Gun Kim <gune.kim@samsung.com>
+ */
+public interface IIndexTaskProvider {
+       public static final String EXTENSION_ID = CCorePlugin.PLUGIN_ID + ".IndexTaskProvider";
+
+       /**
+        * Returns <@code IPDOMIndexerTask> that indexes source files on project.
+        */
+       public IPDOMIndexerTask getPdomIndexerTask(ICProject project, IPDOMIndexer indexer);
+
+}
index 1769f38..4d01004 100644 (file)
  *     Martin Oberhuber (Wind River) - [397652] fix up-to-date check for PDOM
  *     IBM Corporation
  *******************************************************************************/
+/**
+* 2016-09-07 Gun Kim gune.kim@samsung.com
+* Modifications by S-Core Co., Ltd.
+* 1. Improved CDT indexer's performance when the project is created
+*/
 package org.eclipse.cdt.internal.core.pdom;
 
 import java.io.File;
@@ -92,6 +97,10 @@ import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtension;
+/* Tizen */
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+/* ===== */
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.ISafeRunnable;
 import org.eclipse.core.runtime.IStatus;
@@ -195,6 +204,9 @@ public class PDOMManager implements IWritableIndexManager, IListener {
        private boolean fInShutDown;
 
        boolean fTraceIndexerSetup;
+       /* Tizen */
+       private Set<IIndexTaskProvider> indexTaskProvidsers = new HashSet<IIndexTaskProvider> ();
+       /* ===== */
 
        public PDOMManager() {
                PDOM.sDEBUG_LOCKS= "true".equals(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/locks"));  //$NON-NLS-1$//$NON-NLS-2$
@@ -210,6 +222,26 @@ public class PDOMManager implements IWritableIndexManager, IListener {
                fSetupJob= new PDOMSetupJob(this);
                fIndexerJob= new PDOMIndexerJob(this);
                fNotificationJob= createNotifyJob();
+               /* Tizen */
+               IExtensionRegistry registry = Platform.getExtensionRegistry();
+               IExtensionPoint ep = registry.getExtensionPoint(IIndexTaskProvider.EXTENSION_ID);
+               IExtension[] indexerExt = ep.getExtensions();
+               if (indexerExt == null) {
+                       return;
+               }
+               for (IExtension extension : indexerExt) {
+                       IConfigurationElement[] elements = extension.getConfigurationElements();
+                       for (IConfigurationElement element : elements) {
+                               if ("provider".equals(element.getName())) { //$NON-NLS-1$
+                                       try {
+                                               indexTaskProvidsers.add((IIndexTaskProvider) element.createExecutableExtension("class"));
+                                       } catch (CoreException e) {
+                                               CCorePlugin.log("Failed to get IIndexTaskProvider: " + extension, e);
+                                       }
+                               }
+                       }
+               }
+               /* ===== */
        }
 
        public Job startup() {
@@ -640,7 +672,18 @@ public class PDOMManager implements IWritableIndexManager, IListener {
                                        } else {
                                                if (fTraceIndexerSetup)
                                                        System.out.println("Indexer: Rebuiding for project " + name); //$NON-NLS-1$
-                                               task= new PDOMRebuildTask(indexer);
+                                               /* Tizen */
+//                                             task = new PDOMRebuildTask(indexer);
+                                               for (IIndexTaskProvider provider : indexTaskProvidsers) {
+                                                       task = provider.getPdomIndexerTask(project, indexer);
+                                                       if (task != null) {
+                                                               break;
+                                                       }
+                                               }
+                                               if (task == null) {
+                                                       task = new PDOMRebuildTask(indexer);
+                                               }
+                                               /* ===== */
                                        }
                                        enqueue(task);
                                }
index f1213fc..5704b0c 100644 (file)
@@ -9,6 +9,11 @@
  *     Markus Schorn - initial API and implementation
  *     Sergey Prigogin (Google)
  *******************************************************************************/ 
+/**
+* 2016-09-07 Gun Kim gune.kim@samsung.com
+* Modifications by S-Core Co., Ltd.
+* 1. Improved CDT indexer's performance when the project is created
+*/
 package org.eclipse.cdt.internal.core.pdom.indexer;
 
 import java.util.ArrayList;
@@ -93,7 +98,11 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
                        fProgressMonitor = null;
                }
        }
-       
+       /* Tizen */
+       public boolean isReuseBuildOption() {
+               return false;
+       }
+       /* ===== */
        private void clearIndex(ICProject project, IWritableIndex index) throws CoreException, InterruptedException {
                // First clear the pdom
                index.acquireWriteLock(fProgressMonitor);
@@ -122,6 +131,9 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
                        final PDOMIndexerTask pdomIndexerTask = (PDOMIndexerTask) delegate;
                        pdomIndexerTask.setUpdateFlags(IIndexManager.UPDATE_ALL);
                        pdomIndexerTask.setWriteInfoToLog();
+                       /* Tizen */
+                       pdomIndexerTask.setReuseBuildOption(isReuseBuildOption());
+                       /* ===== */
                }
                synchronized (this) {
                        fDelegate= delegate;
index 26fa99c..f23352c 100644 (file)
@@ -9,6 +9,11 @@
  *        Markus Schorn - initial API and implementation
  *        Sergey Prigogin (Google)
 ******************************************************************************/ 
+/**
+* 2016-09-07 Gun Kim gune.kim@samsung.com
+* Modifications by S-Core Co., Ltd.
+* 1. Improved CDT indexer's performance when the project is created
+*/
 package org.eclipse.cdt.internal.core.pdom.indexer;
 
 import java.io.File;
@@ -172,10 +177,17 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
                if (delegate instanceof PDOMIndexerTask) {
                        final PDOMIndexerTask task = (PDOMIndexerTask) delegate;
                        task.setUpdateFlags(fUpdateOptions);
+                       /* Tizen */
+                       task.setReuseBuildOption(isReuseBuildOption());
+                       /* ===== */
                }
                setDelegate(delegate);
        }
-
+       /* Tizen */
+       public boolean isReuseBuildOption() {
+               return false;
+       }
+       /* ===== */
        private ITranslationUnit getTranslationUnit(IIndexFileLocation location, ICProject project) {
                IPath path= IndexLocationFactory.getAbsolutePath(location);
                if (path == null)
index d5e0020..2d953ec 100644 (file)
    <extension-point id="LanguageSettingsProvider" name="%LanguageSettingsProvider.name" schema="schema/LanguageSettingsProvider.exsd"/>
    <extension-point id="UNCPathConverter" name="%uncPathConverter.name" schema="schema/UNCPathConverter.exsd"/>
    <extension-point id="ProblemMarkerFilter" name="%problemMarkerFilter.name" schema="schema/ProblemMarkerFilter.exsd"/>
-
+   <!-- Tizen -->
+   <extension-point id="IndexTaskProvider" name="IndexTaskProvider" schema="schema/IndexTaskProvider.exsd"/>
+   <!-- ===== -->
    <extension
          point="org.eclipse.cdt.core.templateProcessTypes">
       <processType
index e82aa91..b5d3f63 100644 (file)
@@ -11,7 +11,7 @@
     <relativePath>../../pom.xml</relativePath>
   </parent>
 
-  <version>5.11.0-SNAPSHOT</version>
+  <version>5.11.0.201602051005</version>
   <artifactId>org.eclipse.cdt.core</artifactId>
   <packaging>eclipse-plugin</packaging>
 </project>
diff --git a/core/org.eclipse.cdt.core/schema/IndexTaskProvider.exsd b/core/org.eclipse.cdt.core/schema/IndexTaskProvider.exsd
new file mode 100644 (file)
index 0000000..a21d538
--- /dev/null
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Tizen -->
+<!--
+2016-09-07 Gun Kim gune.kim@samsung.com
+Addition file by S-Core Co., Ltd.
+1. Improved CDT indexer's performance when the project is created
+-->
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.core" id="IndexTaskProvider" name="IndexTaskProvider"/>
+      </appInfo>
+      <documentation>
+         The IndexTaskProvider is used to provide proper IPDOMIndexTask which indexes source files middle of creating project.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="provider"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="provider">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  A class which extends org.eclipse.cdt.internal.core.pdom.extensions.IIndexTaskProvider
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.internal.core.pdom.extensions.IIndexTaskProvider:"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
+<!-- ===== -->
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e47d3e1..55701ea 100644 (file)
--- a/pom.xml
+++ b/pom.xml
 -->
                <module>debug/org.eclipse.cdt.debug.core</module>
                <module>debug/org.eclipse.cdt.debug.ui</module>
+               <module>core/org.eclipse.cdt.core</module>
                <module>core/org.eclipse.cdt.ui</module>
                <module>dsf-gdb/org.eclipse.cdt.dsf.gdb</module>
                <module>dsf-gdb/org.eclipse.cdt.dsf.gdb.ui</module>