diff mbox series

[07/11] kernel-shark-qt: Optimize the search in a case of a small data-set

Message ID 20181121151356.16901-9-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Small modifications and bug fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov Nov. 21, 2018, 3:14 p.m. UTC
Parallelizing the search (map-reduce) and showing the progress make
sense only in the case of very big data-sets. If the data-set is
small we do not want to have the overhead added by the update of
the progress bar. This overhead turns to be not so small (~1s. on
my laptop).

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsTraceViewer.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/KsTraceViewer.cpp b/kernel-shark-qt/src/KsTraceViewer.cpp
index 1f96234..64c9fb7 100644
--- a/kernel-shark-qt/src/KsTraceViewer.cpp
+++ b/kernel-shark-qt/src/KsTraceViewer.cpp
@@ -579,6 +579,12 @@  void KsTraceViewer::_resizeToContents()
 	_view.setColumnWidth(0, columnSize);
 }
 
+//! @cond Doxygen_Suppress
+
+#define KS_SEARCH_SHOW_PROGRESS_MIN 100000
+
+//! @endcond
+
 size_t KsTraceViewer::_searchItems(int column,
 				   const QString &searchText,
 				   condition_func cond)
@@ -588,7 +594,14 @@  size_t KsTraceViewer::_searchItems(int column,
 	_searchProgBar.show();
 	_pbAction->setVisible(true);
 
-	if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
+	if (_proxyModel.rowCount({}) < KS_SEARCH_SHOW_PROGRESS_MIN) {
+		/*
+		 * This is a small data-set. Do a single-threaded search
+		 * without showing the progress.
+		 */
+		_proxyModel.search(column, searchText, cond, &_matchList,
+				   nullptr, nullptr);
+	} else if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
 	    column == KsViewModel::TRACE_VIEW_COL_LAT) {
 		_searchStopAction->setVisible(true);
 		_proxyModel.search(column, searchText, cond, &_matchList,