From 58064dbe0e19fad10a2a097016883d355531602b Mon Sep 17 00:00:00 2001 From: Dave McKnight Date: Thu, 16 Jan 2014 12:15:24 -0500 Subject: [PATCH] [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. --- .../ui/view/SystemViewRemoteFileAdapter.java | 6 ++- .../local/files/LocalFileService.java | 39 ++++++++++----- .../services/local/files/LocalHostFile.java | 48 +++++++++++++++---- .../local/search/LocalSearchHandler.java | 7 +-- .../LocalFileSubSystemConfiguration.java | 6 ++- 5 files changed, 79 insertions(+), 27 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java index efc314afbe0..b1a0416ffa0 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2013 IBM Corporation and others. + * Copyright (c) 2002, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -81,6 +81,7 @@ * David Mcknight (IBM) - [374681] Incorrect number of children on the properties page of a directory * Samuel Wu (IBM) - [398988] [ftp] FTP Only support to zVM * Xuan Chen (IBM) - [399101] RSE edit actions on local files that map to actually workspace resources should not use temp files + * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. *******************************************************************************/ package org.eclipse.rse.internal.files.ui.view; @@ -3961,6 +3962,9 @@ public class SystemViewRemoteFileAdapter */ public boolean supportsDeferredQueries(ISubSystem subSys) { + if (subSys instanceof IRemoteFileSubSystem){ + return ((IRemoteFileSubSystem)subSys).getParentRemoteFileSubSystemConfiguration().supportsDeferredQueries(); + } return !subSys.getHost().getSystemType().isLocal(); } diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java index 9c0bfce8d09..33ade1cbd05 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -54,6 +54,7 @@ * David McKnight (IBM) - [374538] [local] localFile service tries to set modified time on virtual files * Samuel Wu (IBM) - [395981] Local file encoding is not handled properly * David McKnight (IBM) - [422508] Unable to map A:\ and B:\ as selectable drives in RSE View + * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -225,9 +226,15 @@ public class LocalFileService extends AbstractFileService implements ILocalServi boolean result = false; File entry = new File(dir, name); if (entry.exists()) { - if (entry.isFile()) { + boolean isDirectory = entry.isDirectory(); + boolean isFile = !isDirectory; + if (isFile){ + isFile = entry.isFile(); + } + + if (isFile) { result = _matcher.matches(name); - } else if (entry.isDirectory()) { + } else if (isDirectory) { if (type == IFileService.FILE_TYPE_FILES_AND_FOLDERS || type == IFileService.FILE_TYPE_FOLDERS) { result = true; } @@ -727,7 +734,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi // this is needed because Windows paths are case insensitive if (isWindows()) { try { - localParent = localParent.getCanonicalFile(); + localParent = localParent.getCanonicalFile(); // can this be avoided for network drives? } catch (IOException e) { System.out.println("Can not get canonical path: " + localParent.getAbsolutePath()); //$NON-NLS-1$ } @@ -790,30 +797,36 @@ public class LocalFileService extends AbstractFileService implements ILocalServi for (int i = 0; i < files.length; i++) { File file = files[i]; - if (file.isDirectory()) + boolean isDirectory = file.isDirectory(); + boolean isFile = !isDirectory; + if (isFile){ + isFile = file.isFile(); + } + + if (isDirectory) { if (type == IFileService.FILE_TYPE_FILES_AND_FOLDERS || type == IFileService.FILE_TYPE_FOLDERS) { - results.add(new LocalHostFile(file)); + results.add(new LocalHostFile(file, false, isFile)); } } - else if (file.isFile()) + else if (isFile) { if (type == IFileService.FILE_TYPE_FILES_AND_FOLDERS || type == IFileService.FILE_TYPE_FILES) { - results.add(new LocalHostFile(file)); + results.add(new LocalHostFile(file, false, isFile)); } else if (type == IFileService.FILE_TYPE_FOLDERS && ArchiveHandlerManager.getInstance().isArchive(file)) { // On Local Archive's should be considered Folders // as they are containers that can be opened. - results.add(new LocalHostFile(file)); + results.add(new LocalHostFile(file, false, isFile)); } } else if (file.exists()) { - results.add(new LocalHostFile(file)); + results.add(new LocalHostFile(file, false, isFile)); } } } @@ -824,7 +837,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi { String userHome =System.getProperty("user.home"); //$NON-NLS-1$ File userHomeFile = new File(userHome); - return new LocalHostFile(userHomeFile, (userHomeFile.getParent() == null)); + return new LocalHostFile(userHomeFile, (userHomeFile.getParent() == null), userHomeFile.isFile()); } @@ -856,7 +869,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi IHostFile[] fileObjs = new LocalHostFile[v.size()]; for (int idx = 0; idx < v.size(); idx++) { - fileObjs[idx] = new LocalHostFile((File) v.get(idx), true); + fileObjs[idx] = new LocalHostFile((File) v.get(idx), true, false); } return fileObjs; @@ -885,7 +898,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi if (!isVirtualParent && !isArchiveParent) { File file = isRoot ? new File(name) : new File(remoteParent, name); - return new LocalHostFile(file, isRoot); + return new LocalHostFile(file, isRoot, file.isFile()); } else { diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java index 48417702d21..e29a09fb2d7 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - Fix [168591] LocalHostFile missing equals() * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files * David McKnight (IBM) - [294521] Local "hidden" files and folders are always shown + * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -30,6 +31,14 @@ import org.eclipse.rse.services.files.IHostFilePermissionsContainer; public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer { private File _file; + + // cache + private long _lastQueryTime = 0; + private Boolean _isFile = null; + private Boolean _isDirectory = null; + private Boolean _exists = null; + private Boolean _isHidden = null; + private boolean _isRoot = false; private boolean _isArchive = false; private IHostFilePermissions _permissions = null; @@ -40,12 +49,15 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer _isArchive = ArchiveHandlerManager.getInstance().isArchive(_file); } - public LocalHostFile(File file, boolean isRoot) + public LocalHostFile(File file, boolean isRoot, boolean isFile) { _file = file; _isRoot = isRoot; - _isArchive = ArchiveHandlerManager.getInstance().isArchive(_file); - + if (!isRoot){ + _isArchive = ArchiveHandlerManager.getInstance().isArchive(_file); + _isFile = new Boolean(isFile); + _isDirectory = new Boolean(!isFile); + } } /* (non-Javadoc) @@ -75,8 +87,11 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public boolean isHidden() { - String name = getName(); - return name.charAt(0) == '.' || (!_isRoot && _file.isHidden()); + if (_isHidden == null || needsQuery()){ + String name = getName(); + _isHidden = new Boolean(name.charAt(0) == '.' || (!_isRoot && _file.isHidden())); + } + return _isHidden.booleanValue(); } public String getParentPath() @@ -86,7 +101,10 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public boolean isDirectory() { - return _file.isDirectory(); + if (_isDirectory == null){ + _isDirectory = new Boolean(_file.isDirectory()); + } + return _isDirectory.booleanValue(); } public boolean isRoot() @@ -96,7 +114,10 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public boolean isFile() { - return _file.isFile(); + if (_isFile == null){ + _isFile = new Boolean(_file.isFile()); + } + return _isFile.booleanValue(); } public File getFile() @@ -106,7 +127,10 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer public boolean exists() { - return _file.exists(); + if (_exists == null || needsQuery()){ + _exists = new Boolean(_file.exists()); + } + return _exists.booleanValue(); } public String getAbsolutePath() @@ -151,4 +175,12 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer _permissions = permissions; } + private boolean needsQuery(){ + long t = System.currentTimeMillis(); + if (_lastQueryTime == 0 || (t - _lastQueryTime) > 5000){ + _lastQueryTime = t; + return true; + } + return false; + } } diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java index 6255af4623c..a10ae3d65f6 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI threadj * Xuan Chen (IBM) - [194865] [local][Archives] Searching contents of a file in an Archive doesn't work * Xuan Chen (IBM) - [205448] [search]All the files are listed as in the Remote Search view even only found one match in a file + * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. *******************************************************************************/ package org.eclipse.rse.internal.services.local.search; @@ -270,7 +271,7 @@ public class LocalSearchHandler implements ISearchHandler { // note that the file can not be root - file = new LocalHostFile(theFile, false); + file = new LocalHostFile(theFile, false, true); /* TODO if (!isArchive) @@ -378,7 +379,7 @@ public class LocalSearchHandler implements ISearchHandler // file is root boolean isRoot = false; //TODO - fileImpl = new LocalHostFile(theFile, isRoot); + fileImpl = new LocalHostFile(theFile, isRoot, true); } // create local file differently for virtual directory else diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java index bb61f72b547..56cb0f7f9dc 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2009 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2014 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -17,6 +17,7 @@ * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal * David Dykstal (IBM) - [222270] clean up interfaces in org.eclipse.rse.core.filters * David McKnight (IBM) - [280605] SystemTextEditor.isLocal() returns false for LocalFileSubSystemConfiguration + * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. ********************************************************************************/ package org.eclipse.rse.subsystems.files.local; @@ -206,7 +207,8 @@ public class LocalFileSubSystemConfiguration extends FileServiceSubSystemConfigu public boolean supportsDeferredQueries() { //No need for deferred queries in Local, since these are always fast - return false; + //return false; + return true; } public IConnectorService getConnectorService(IHost host)