Skip to contentSkip to conversation

Performance fix for Linux implementation

PATCH New Ioana Grigoropol 1 participant 1 message Jan 16, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Performance fix for Linux implementation

- run each command in a separate shell - needs explicit sourcing of environment and closing for each command
- tested only against Linux host & Linux local host connection
- needs local patch for upstream API

---
 plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF       |    1 +
 .../src/org/yocto/bc/bitbake/BBRecipe.java         |    5 +-
 .../src/org/yocto/bc/bitbake/ShellSession.java     |   23 ++-
 .../org/yocto/bc/remote/utils/CommandRunnable.java |   90 +++++++++
 .../yocto/bc/remote/utils/ProcessStreamBuffer.java |   12 +-
 .../org/yocto/bc/remote/utils/RemoteHelper.java    |   98 ++++------
 .../org/yocto/bc/remote/utils/RemoteMachine.java   |  127 +++++++++++--
 .../remote/utils/YoctoHostShellProcessAdapter.java |  198 --------------------
 .../bc/remote/utils/YoctoRunnableWithProgress.java |  191 ++++++++++++++++---
 .../bc/ui/wizards/NewBitBakeFileRecipeWizard.java  |    2 +-
 .../ui/wizards/NewBitBakeFileRecipeWizardPage.java |   71 ++++---
 .../yocto/bc/ui/wizards/install/InstallWizard.java |   29 +--
 12 files changed, 467 insertions(+), 380 deletions(-)
 create mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/CommandRunnable.java
 delete mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java
plugins/org.yocto.bc.ui/META-INF/MANIFEST.MF +1 -0
index 1f0e63e..4e57f33 100644
@@ -29,6 +29,7 @@ Import-Package: org.eclipse.cdt.managedbuilder.core,
  org.eclipse.rse.core,
  org.eclipse.rse.core.model,
  org.eclipse.rse.core.subsystems,
+ org.eclipse.rse.internal.services.local.shells,
  org.eclipse.rse.services,
  org.eclipse.rse.services.clientserver.messages,
  org.eclipse.rse.services.files,
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java +3 -2
index 6a33ade..6d003ce 100644
@@ -26,9 +26,9 @@ public class BBRecipe extends BBSession {
 		super(session.shell, session.pinfo.getURI());
 		this.session = session;
 		this.fileURI = filePath;
-		this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e -b " + filePath.getPath();
+		this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e -b " + filePath.getPath() + " >& " + BB_ENV_FILE;
 	}
-	
+
 	@Override
 	public void initialize() throws Exception {
 		if (this.size() == 0) {
@@ -37,6 +37,7 @@ public class BBRecipe extends BBSession {
 		}
 	}
 
+	@Override
 	protected URI getDefaultDepends() {
 		return this.fileURI;
 	}
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +18 -5
index 6441029..ef01d96 100644
@@ -48,6 +48,7 @@ public class ShellSession {
 	public static final String LT = System.getProperty("line.separator");
 	public static final String exportCmd = "export BB_ENV_EXTRAWHITE=\"DISABLE_SANITY_CHECKS $BB_ENV_EXTRAWHITE\"";
 	public static final String exportColumnsCmd = "export COLUMNS=1000";
+	private static final String BUILD_DIR = "/build/";
 
 	public static String getFilePath(String file) throws IOException {
 		File f = new File(file);
@@ -87,8 +88,11 @@ public class ShellSession {
 	private void initializeShell(IProgressMonitor monitor) throws IOException {
 		try {
 			if (root != null) {
-				RemoteHelper.runCommandRemote(projectInfo.getConnection(), new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""));
-				RemoteHelper.runCommandRemote(projectInfo.getConnection(), new YoctoCommand(exportCmd, root.getAbsolutePath(), ""));
+				IHost connection = projectInfo.getConnection();
+//				RemoteHelper.runCommandRemote(projectInfo.getConnection(), new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""));
+				RemoteHelper.handleRunCommandRemote(connection, new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""), monitor);
+//				RemoteHelper.runCommandRemote(projectInfo.getConnection(), new YoctoCommand(exportCmd, root.getAbsolutePath(), ""));
+				RemoteHelper.handleRunCommandRemote(connection,  new YoctoCommand(exportCmd, root.getAbsolutePath(), ""), monitor);
 			} else {
 				throw new Exception("Root file not found!");
 			}
@@ -107,9 +111,11 @@ public class ShellSession {
 
 		try {
 			if (projectInfo.getConnection() != null) {
-				hasErrors = RemoteHelper.runCommandRemote(projectInfo.getConnection(), new YoctoCommand(command, root.getAbsolutePath() + "/build/", ""));
+//				hasErrors = RemoteHelper.runCommandRemote(projectInfo.getConnection(), new YoctoCommand(command, root.getAbsolutePath() + "/build/", ""));
+				command = getInitCmd() + command;
+				RemoteHelper.handleRunCommandRemote(projectInfo.getConnection(), new YoctoCommand(command, getBuildDirAbsolutePath(), ""), new NullProgressMonitor());
 //				return RemoteHelper.getProcessBuffer(projectInfo.getConnection()).getMergedOutputLines();
-				return root.getAbsolutePath() + "/build/";
+				return getBuildDirAbsolutePath();
 			}
 			return null;
 		} catch (Exception e) {
@@ -118,9 +124,16 @@ public class ShellSession {
 		return null;
 	}
 
+	private String getBuildDirAbsolutePath(){
+		return root.getAbsolutePath() + BUILD_DIR;
+	}
+
+    private String getInitCmd() {
+    	return "source " + initCmd + " " + getBuildDirAbsolutePath() + " > tempsf; rm -rf tempsf;";
+	}
+
 synchronized
 	public void execute(String command, ICommandResponseHandler handler) throws IOException {
-		System.out.println(command);
 		execute(command, TERMINATOR, handler);
 	}
 
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/CommandRunnable.java new file +90 -0

90 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ProcessStreamBuffer.java +6 -6
index 2c6d122..e0d502c 100644
@@ -8,27 +8,27 @@ public class ProcessStreamBuffer {
 	private static final String WHITESPACES = "\\s+";
 	List<String> errorLines;
 	List<String> outputLines;
-	
+
 	ProcessStreamBuffer(){
 		errorLines = new ArrayList<String>();
 		outputLines = new ArrayList<String>();
 	}
-	
+
 	public void addErrorLine(String line){
 		errorLines.add(line);
 	}
 	public void addOutputLine(String line){
 		outputLines.add(line);
 	}
-	
+
 	public List<String> getOutputLines(){
 		return outputLines;
 	}
-	
+
 	public List<String> getErrorLines(){
 		return errorLines;
 	}
-	
+
 	public String getMergedOutputLines(){
 		String returnVal = "";
 		for (int i = 0; i < outputLines.size(); i++) {
@@ -65,6 +65,6 @@ public class ProcessStreamBuffer {
 				}
 			}
 		}
-		return null;
+		return "";
 	}
 }
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java +33 -65

142 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteMachine.java +114 -13

166 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java deleted +0 -198

198 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoRunnableWithProgress.java +161 -30

233 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizard.java +1 -1
index 7345b77..1f15922 100644
@@ -204,7 +204,7 @@ public class NewBitBakeFileRecipeWizard extends Wizard implements INewWizard {
 			public void run(IProgressMonitor monitor) throws InvocationTargetException {
 				try {
 					doFinish(element, monitor);
-					RemoteHelper.runCommandRemote(connection, new YoctoCommand("rm -rf " + element.getMetaDir() + "/temp", "", ""));
+					RemoteHelper.handleRunCommandRemote(connection, new YoctoCommand("rm -rf " + element.getMetaDir() + "/temp", "", ""), monitor);
 				} catch (Exception e) {
 					throw new InvocationTargetException(e);
 				} finally {
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java +34 -37

169 lines not on this page · raw message

plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java +6 -23
index 4fbaca3..071f6aa 100644
@@ -6,7 +6,6 @@ import java.util.Hashtable;
 import java.util.Map;
 
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.IWizardContainer;
@@ -20,6 +19,7 @@ import org.eclipse.ui.console.MessageConsole;
 import org.yocto.bc.remote.utils.CommandResponseHandler;
 import org.yocto.bc.remote.utils.ConsoleWriter;
 import org.yocto.bc.remote.utils.RemoteHelper;
+import org.yocto.bc.remote.utils.YoctoCommand;
 import org.yocto.bc.remote.utils.YoctoRunnableWithProgress;
 import org.yocto.bc.ui.Activator;
 import org.yocto.bc.ui.model.ProjectInfo;
@@ -112,18 +112,17 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard
 			IRemoteServices remoteServices = ((IRemoteServices)model.get(InstallWizard.SELECTED_REMOTE_SERVICE));
 			final IHost connection = RemoteHelper.getRemoteConnectionByName(remoteConnection.getName());
 			final CommandResponseHandler cmdHandler = RemoteHelper.getCommandHandler(connection);
-			final YoctoRunnableWithProgress adapter = (YoctoRunnableWithProgress)RemoteHelper.getHostShellProcessAdapter(connection);
 			final IWizardContainer container = this.getContainer();
 			if (((Boolean)options.get(GIT_CLONE)).booleanValue()) {
 				String cmd = "/usr/bin/git clone --progress";
 				String args = "git://git.yoctoproject.org/poky.git " + uri.getPath();
 				String taskName = "Checking out Yocto git repository";
 
+				YoctoRunnableWithProgress adapter = new YoctoRunnableWithProgress(new YoctoCommand(cmd, "", args));
+
 				adapter.setRemoteConnection(remoteConnection);
 				adapter.setRemoteServices(remoteServices);
 				adapter.setTaskName(taskName);
-				adapter.setCmd(cmd);
-				adapter.setArgs(args);
 				try {
 					container.run(true, true, adapter);
 				} catch (InvocationTargetException e) {
@@ -148,31 +147,15 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard
 				pinfo.setRemoteServices(remoteServices);
 
 				final ConsoleWriter cw = new ConsoleWriter();
-				final ProjectInfo pInfoFinal = pinfo;
-
-				Thread t = new Thread(new Runnable() {
-
-					@Override
-					public void run() {
-						try {
-							Thread.sleep(2000);
-							new BBConfigurationInitializeOperation(pInfoFinal, null).run(new NullProgressMonitor());
-						} catch (InvocationTargetException e) {
-							e.printStackTrace();
-						} catch (InterruptedException e) {
-							e.printStackTrace();
-						}
-					}
-				});
-
+//				final ProjectInfo pInfoFinal = pinfo;
+				container.run(false, false, new BBConfigurationInitializeOperation(pinfo, null));
 				console = RemoteHelper.getConsole(connection);
 				console.newMessageStream().println(cw.getContents());
 
 				model.put(InstallWizard.KEY_PINFO, pinfo);
 				Activator.putProjInfo(pinfo.getURI(), pinfo);
 
-				container.run(true, true, new CreateBBCProjectOperation(pinfo));
-				t.start();
+				container.run(false, false, new CreateBBCProjectOperation(pinfo));
 				return true;
 			}
 		} catch (Exception e) {
Signature · 1 line
1.7.9.5