Skip to content

Commit 9edb49c

Browse files
yaooqinndongjoon-hyun
authored andcommitted
[SPARK-51452][UI] Improve Thread dump table search
### What changes were proposed in this pull request? This PR improves thread dump search by: - query with pattern `tr[id^="thread_"]` w/o further patten matching - short-circuit the searching loop if found - ### Why are the changes needed? code refactoring for perf & cost ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? ![image](https://github.com/user-attachments/assets/306c6d72-8182-4a96-85a0-c3a19d733be7) ### Was this patch authored or co-authored using generative AI tooling? no Closes #50225 from yaooqinn/SPARK-51452. Authored-by: Kent Yao <yao@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent 890ee47 commit 9edb49c

File tree

1 file changed

+14
-19
lines changed
  • core/src/main/resources/org/apache/spark/ui/static

1 file changed

+14
-19
lines changed

core/src/main/resources/org/apache/spark/ui/static/table.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,26 @@ function onMouseOverAndOut(threadId) {
8282
}
8383

8484
function onSearchStringChange() {
85-
var searchString = $('#search').val().toLowerCase();
85+
const searchString = $('#search').val().toLowerCase();
8686
//remove the stacktrace
8787
collapseAllThreadStackTrace(false);
88-
if (searchString.length == 0) {
89-
$('tr').each(function() {
88+
$('tr[id^="thread_"]').each(function() {
89+
if (searchString.length === 0) {
9090
$(this).removeClass('d-none')
91-
})
92-
} else {
93-
$('tr').each(function(){
94-
if($(this).attr('id') && $(this).attr('id').match(/thread_[0-9]+_tr/) ) {
95-
var children = $(this).children();
96-
var found = false;
97-
for (var i = 0; i < children.length; i++) {
98-
if (children.eq(i).text().toLowerCase().indexOf(searchString) >= 0) {
99-
found = true;
100-
}
101-
}
102-
if (found) {
103-
$(this).removeClass('d-none')
91+
} else {
92+
let found = false;
93+
const children = $(this).children();
94+
let i = 0;
95+
while(!found && i < children.length) {
96+
if (children.eq(i).text().toLowerCase().indexOf(searchString) >= 0) {
97+
found = true;
10498
} else {
105-
$(this).addClass('d-none')
99+
i++;
106100
}
107101
}
108-
});
109-
}
102+
$(this).toggleClass('d-none', !found);
103+
}
104+
});
110105
}
111106
/* eslint-enable no-unused-vars */
112107

0 commit comments

Comments
 (0)