diff mbox series

[v2,3/8] kernel-shark-qt: Make the parallelized search stoppable

Message ID 20181214125212.9637-4-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series More modifications toward KS 1.0 | expand

Commit Message

Yordan Karadzhov Dec. 14, 2018, 12:52 p.m. UTC
So far only the single-threaded search inside the "Latency" and "Info"
columns can be stopped by the "stop search" button. This patch makes it
possible to stop also the parallelized search. Note that after stopping
the parallelized search, the list of matches will contain entries which
may not be consecutive, because each thread was searching in its own
subset of the data and was stoped at an arbitrary position in this
subset.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsModels.cpp      |  6 +++++-
 kernel-shark-qt/src/KsModels.hpp      |  5 ++++-
 kernel-shark-qt/src/KsTraceViewer.cpp | 19 ++++++++++++-------
 3 files changed, 21 insertions(+), 9 deletions(-)

Comments

Steven Rostedt Dec. 14, 2018, 5:17 p.m. UTC | #1
On Fri, 14 Dec 2018 12:52:37 +0000
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:

> So far only the single-threaded search inside the "Latency" and "Info"
> columns can be stopped by the "stop search" button. This patch makes it
> possible to stop also the parallelized search. Note that after stopping
> the parallelized search, the list of matches will contain entries which
> may not be consecutive, because each thread was searching in its own
> subset of the data and was stoped at an arbitrary position in this
> subset.
> 

Also I noticed:

  _searchStopButton(QIcon::fromTheme("process-stop"), "", this),

I don't have a "process-stop" theme. I'm not running KDE. All I see is
a blank button. Is there a way to add text to it too, or define the
theme if it is not set?

-- Steve
Yordan Karadzhov Dec. 17, 2018, 5:02 p.m. UTC | #2
On 14.12.18 г. 19:17 ч., Steven Rostedt wrote:
> On Fri, 14 Dec 2018 12:52:37 +0000
> Yordan Karadzhov <ykaradzhov@vmware.com> wrote:
> 
>> So far only the single-threaded search inside the "Latency" and "Info"
>> columns can be stopped by the "stop search" button. This patch makes it
>> possible to stop also the parallelized search. Note that after stopping
>> the parallelized search, the list of matches will contain entries which
>> may not be consecutive, because each thread was searching in its own
>> subset of the data and was stoped at an arbitrary position in this
>> subset.
>>
> 
> Also I noticed:
> 
>    _searchStopButton(QIcon::fromTheme("process-stop"), "", this),
> 
> I don't have a "process-stop" theme. I'm not running KDE. All I see is
> a blank button. Is there a way to add text to it too, or define the
> theme if it is not set?
> 

This is strange. This line means that the button have to show the 
"process-stop" icon and the version (look) of the icon has to be 
determined form your current theme. Everywhere in the code I use the 
standardized icon names provided here

https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html 


Looks like for some reason your theme does not provide this icon.

Thanks!
Yordan

> -- Steve
>
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/KsModels.cpp b/kernel-shark-qt/src/KsModels.cpp
index d67ee62..c8cc410 100644
--- a/kernel-shark-qt/src/KsModels.cpp
+++ b/kernel-shark-qt/src/KsModels.cpp
@@ -80,7 +80,11 @@  void KsFilterProxyModel::_search(int column,
 			matchList->append(row);
 
 		if (_searchStop) {
-			_searchStop = false;
+			if (notify) {
+				_searchProgress = KS_PROGRESS_BAR_MAX;
+				_pbCond.notify_one();
+			}
+
 			break;
 		}
 
diff --git a/kernel-shark-qt/src/KsModels.hpp b/kernel-shark-qt/src/KsModels.hpp
index b66c259..08019e7 100644
--- a/kernel-shark-qt/src/KsModels.hpp
+++ b/kernel-shark-qt/src/KsModels.hpp
@@ -178,7 +178,10 @@  public:
 	int searchProgress() const {return _searchProgress;}
 
 	/** Reset the progress value of the search. */
-	void searchReset() {_searchProgress = 0;}
+	void searchReset() {
+		_searchProgress = 0;
+		_searchStop = false;
+	}
 
 	/** Stop the serch for all threads. */
 	void searchStop() {_searchStop = true;}
diff --git a/kernel-shark-qt/src/KsTraceViewer.cpp b/kernel-shark-qt/src/KsTraceViewer.cpp
index 7f0f1e2..aeed5f7 100644
--- a/kernel-shark-qt/src/KsTraceViewer.cpp
+++ b/kernel-shark-qt/src/KsTraceViewer.cpp
@@ -446,6 +446,7 @@  void KsTraceViewer::_searchStop()
 {
 	_searchStopAction->setVisible(false);
 	_proxyModel.searchStop();
+	_lockSearchPanel(false);
 }
 
 void KsTraceViewer::_clicked(const QModelIndex& i)
@@ -625,7 +626,6 @@  size_t KsTraceViewer::_searchItems(int column,
 {
 	int count, dataRow;
 
-	_searchProgBar.show();
 	_pbAction->setVisible(true);
 
 	if (_proxyModel.rowCount({}) < KS_SEARCH_SHOW_PROGRESS_MIN) {
@@ -635,15 +635,20 @@  size_t KsTraceViewer::_searchItems(int column,
 		 */
 		_proxyModel.search(column, searchText, cond, &_matchList,
 				   nullptr, nullptr);
-	} else if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
-	    column == KsViewModel::TRACE_VIEW_COL_LAT) {
+	} else {
 		_searchStopAction->setVisible(true);
-		_proxyModel.search(column, searchText, cond, &_matchList,
-				   &_searchProgBar, &_searchCountLabel);
+
+		if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
+		    column == KsViewModel::TRACE_VIEW_COL_LAT) {
+			_proxyModel.search(column, searchText,
+					   cond, &_matchList,
+					   &_searchProgBar,
+					   &_searchCountLabel);
+		} else {
+			_searchItemsMapReduce(column, searchText, cond);
+		}
 
 		_searchStopAction->setVisible(false);
-	} else {
-		_searchItemsMapReduce(column, searchText, cond);
 	}
 
 	count = _matchList.count();