app boot takes 98% less time when snapd is disabled

This commit is contained in:
Vinicius Moreira
2019-08-07 15:50:38 -03:00
parent de819d543f
commit 2722d8c612
5 changed files with 51 additions and 14 deletions

View File

@@ -6,8 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.5.1]
### Improvements:
- suggestions are now retrieved asynchronously. Response time takes 45% less.
- search response time takes an average of 20% less ( reaching 35% for several results )
- suggestions are now retrieved asynchronously taking 45% less time.
- search response takes an average of 20% less time ( reaching 35% for several results )
- app boot takes 98% less time when snapd is disabled
### Fixes:
- [flatpak dependency](https://github.com/vinifmor/fpakman/issues/36)

View File

@@ -21,7 +21,6 @@ from fpakman.core.snap.model import SnapApplication
from fpakman.util import util
from fpakman.util.cache import Cache
from fpakman.util.memory import CacheCleaner
from fpakman.view.qt import dialog
from fpakman.view.qt.systray import TrayIcon
from fpakman.view.qt.window import ManageWindow
@@ -135,18 +134,11 @@ if args.tray:
manage_window=manage_window,
check_interval=args.check_interval,
update_notification=bool(args.update_notification))
manage_window.tray_icon = trayIcon
trayIcon.show()
else:
manage_window.refresh_apps()
manage_window.show()
warnings = manager.list_warnings()
if warnings:
for warning in warnings:
dialog.show_warning(title=locale_keys['warning'].capitalize(), body=warning)
CacheCleaner(caches).start()
sys.exit(app.exec_())

View File

@@ -104,6 +104,12 @@ class GenericApplicationManager(ApplicationManager):
self.map = {m.get_app_type(): m for m in self.managers}
self.disk_loader_factory = disk_loader_factory
self._enabled_map = {} if app_args.check_packaging_once else None
self.thread_prepare = None
def _wait_to_be_ready(self):
if self.thread_prepare:
self.thread_prepare.join()
self.thread_prepare = None
def _sort(self, apps: List[Application], word: str) -> List[Application]:
exact_name_matches, contains_name_matches, others = [], [], []
@@ -126,7 +132,6 @@ class GenericApplicationManager(ApplicationManager):
return res
def _is_enabled(self, man: ApplicationManager):
if self._enabled_map is not None:
enabled = self._enabled_map.get(man.get_app_type())
@@ -145,6 +150,8 @@ class GenericApplicationManager(ApplicationManager):
res['new'].extend(apps_found['new'])
def search(self, word: str, disk_loader: DiskCacheLoader = None) -> Dict[str, List[Application]]:
self._wait_to_be_ready()
res = {'installed': [], 'new': []}
norm_word = word.strip().lower()
@@ -171,6 +178,8 @@ class GenericApplicationManager(ApplicationManager):
return res
def read_installed(self, disk_loader: DiskCacheLoader = None) -> List[Application]:
self._wait_to_be_ready()
installed = []
disk_loader = None
@@ -262,18 +271,26 @@ class GenericApplicationManager(ApplicationManager):
return man.requires_root(action, app)
def refresh(self, app: Application, root_password: str) -> FpakmanProcess:
self._wait_to_be_ready()
man = self._get_manager_for(app)
if man:
return man.refresh(app, root_password)
def prepare(self):
def _prepare(self):
if self.managers:
for man in self.managers:
if self._is_enabled(man):
man.prepare()
def prepare(self):
self.thread_prepare = Thread(target=self._prepare)
self.thread_prepare.start()
def list_updates(self) -> List[ApplicationUpdate]:
self._wait_to_be_ready()
updates = []
if self.managers:

View File

@@ -347,4 +347,18 @@ class FindSuggestions(AsyncAction):
def run(self):
self.signal_finished.emit(self.man.list_suggestions(limit=-1))
class ListWarnings(QThread):
signal_warnings = pyqtSignal(list)
def __init__(self, man: ApplicationManager, locale_keys: dict):
super(QThread, self).__init__()
self.locale_keys = locale_keys
self.man = man
def run(self):
warnings = self.man.list_warnings()
if warnings:
self.signal_warnings.emit(warnings)

View File

@@ -18,7 +18,7 @@ from fpakman.view.qt.history import HistoryDialog
from fpakman.view.qt.info import InfoDialog
from fpakman.view.qt.root import is_root, ask_root_password
from fpakman.view.qt.thread import UpdateSelectedApps, RefreshApps, UninstallApp, DowngradeApp, GetAppInfo, \
GetAppHistory, SearchApps, InstallApp, AnimateProgress, VerifyModels, RefreshApp, FindSuggestions
GetAppHistory, SearchApps, InstallApp, AnimateProgress, VerifyModels, RefreshApp, FindSuggestions, ListWarnings
from fpakman.view.qt.view_model import ApplicationView
DARK_ORANGE = '#FF4500'
@@ -213,6 +213,19 @@ class ManageWindow(QWidget):
self.dialog_about = None
self.first_refresh = suggestions
self.thread_warnings = ListWarnings(man=manager, locale_keys=locale_keys)
self.thread_warnings.signal_warnings.connect(self._show_warnings)
def _show_warnings(self, warnings: List[str]):
if warnings:
for warning in warnings:
dialog.show_warning(title=self.locale_keys['warning'].capitalize(), body=warning)
def show(self):
super(ManageWindow, self).show()
if not self.thread_warnings.isFinished():
self.thread_warnings.start()
def _show_about(self):
if self.dialog_about is None:
self.dialog_about = AboutDialog(self.locale_keys)