Skip to content

Commit e7969e9

Browse files
authored
fix: implement proper scrolling for ISA explorer using data chunks (#990)
Fixes #831. Currently the instructions and CSR tables in ISA explorer take very long to load or do not load properly. By loading large datasets in chunks, the tables can be rendered quickly on page load. This can be done using the `addData` method provided by tabulator to populate the table after its been built. Scrolling Instructions table currently: https://github.com/user-attachments/assets/3d62860e-4551-48a9-9985-04cd11066f25 Scrolling Instructions table with fix applied: https://github.com/user-attachments/assets/5ac7d695-983c-43f0-ac57-5a94dc65493b Requesting review @james-ball-qualcomm
1 parent bd0e5e5 commit e7969e9

File tree

6 files changed

+64
-3
lines changed

6 files changed

+64
-3
lines changed

backends/isa_explorer/csr_table.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<div id="csr_table"></div>
1010
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
1111
<script type="text/javascript" src="csr_table.js"></script>
12+
<script type="text/javascript" src="load_table.js"></script>
1213
</body>
1314
</html>

backends/isa_explorer/ext_table.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<div id="ext_table"></div>
1010
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
1111
<script type="text/javascript" src="ext_table.js"></script>
12+
<script type="text/javascript" src="load_table.js"></script>
1213
</body>
1314
</html>

backends/isa_explorer/inst_table.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<div id="inst_table"></div>
1010
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
1111
<script type="text/javascript" src="inst_table.js"></script>
12+
<script type="text/javascript" src="load_table.js"></script>
1213
</body>
1314
</html>

backends/isa_explorer/isa_explorer.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ def gen_js_table(table, div_name, output_pname)
346346
fp.write " ]\n"
347347
fp.write "});\n"
348348
fp.write "\n"
349+
350+
fp.write "// Load data in chunks after table is built\n"
351+
fp.write "table.on(\"tableBuilt\", function() {\n"
352+
fp.write " loadDataInChunks(tabledata);\n"
353+
fp.write "});\n"
354+
fp.write "\n"
349355
end
350356
end
351357

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Chunked data loading for better performance
2+
function loadDataInChunks(data, chunkSize = 500, delay = 50) {
3+
if (!Array.isArray(data) || data.length === 0) return;
4+
5+
const totalChunks = Math.ceil(data.length / chunkSize);
6+
let currentChunk = 0;
7+
8+
function loadNextChunk() {
9+
const startIndex = currentChunk * chunkSize;
10+
const endIndex = Math.min(startIndex + chunkSize, data.length);
11+
const chunk = data.slice(startIndex, endIndex);
12+
13+
try {
14+
if (currentChunk === 0) {
15+
table.clearData();
16+
table.setData(chunk);
17+
} else {
18+
table.addData(chunk);
19+
}
20+
21+
currentChunk++;
22+
console.log(`Chunk ${currentChunk}/${totalChunks}: ${endIndex}/${data.length} items`);
23+
24+
if (currentChunk < totalChunks) {
25+
setTimeout(loadNextChunk, delay);
26+
} else {
27+
console.log('All data loaded successfully.');
28+
}
29+
} catch (error) {
30+
console.error('Error loading chunk:', error);
31+
if (currentChunk < totalChunks) setTimeout(loadNextChunk, delay);
32+
}
33+
}
34+
35+
loadNextChunk();
36+
}

backends/isa_explorer/tasks.rake

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ BACKEND_DIR = "#{$root}/backends/#{BACKEND_NAME}"
1515
SRC_EXT_HTML_PNAME = "#{BACKEND_DIR}/ext_table.html"
1616
SRC_INST_HTML_PNAME = "#{BACKEND_DIR}/inst_table.html"
1717
SRC_CSR_HTML_PNAME = "#{BACKEND_DIR}/csr_table.html"
18+
SRC_LOAD_TABLE_JS_PNAME = "#{BACKEND_DIR}/load_table.js"
1819

1920
# Generated directories/files
2021
GEN_ROOT = $root / "gen" / BACKEND_NAME
@@ -93,7 +94,8 @@ end
9394

9495
file "#{GEN_HTML_EXT_TABLE}" => [
9596
__FILE__,
96-
SRC_EXT_HTML_PNAME
97+
SRC_EXT_HTML_PNAME,
98+
SRC_LOAD_TABLE_JS_PNAME
9799
].flatten do |t|
98100
# Ensure directory holding target file is present.
99101
FileUtils.mkdir_p File.dirname(t.name)
@@ -109,11 +111,16 @@ file "#{GEN_HTML_EXT_TABLE}" => [
109111

110112
# Just copy static HTML file.
111113
FileUtils.copy_file(SRC_EXT_HTML_PNAME, t.name)
114+
115+
# Copy static JS file for table loading
116+
js_target = File.join(File.dirname(t.name), File.basename(SRC_LOAD_TABLE_JS_PNAME))
117+
FileUtils.copy_file(SRC_LOAD_TABLE_JS_PNAME, js_target)
112118
end
113119

114120
file "#{GEN_HTML_INST_TABLE}" => [
115121
__FILE__,
116-
SRC_INST_HTML_PNAME
122+
SRC_INST_HTML_PNAME,
123+
SRC_LOAD_TABLE_JS_PNAME
117124
].flatten do |t|
118125
# Ensure directory holding target file is present.
119126
FileUtils.mkdir_p File.dirname(t.name)
@@ -129,11 +136,16 @@ file "#{GEN_HTML_INST_TABLE}" => [
129136

130137
# Just copy static HTML file.
131138
FileUtils.copy_file(SRC_INST_HTML_PNAME, t.name)
139+
140+
# Copy static JS file for table loading
141+
js_target = File.join(File.dirname(t.name), File.basename(SRC_LOAD_TABLE_JS_PNAME))
142+
FileUtils.copy_file(SRC_LOAD_TABLE_JS_PNAME, js_target)
132143
end
133144

134145
file "#{GEN_HTML_CSR_TABLE}" => [
135146
__FILE__,
136-
SRC_CSR_HTML_PNAME
147+
SRC_CSR_HTML_PNAME,
148+
SRC_LOAD_TABLE_JS_PNAME
137149
].flatten do |t|
138150
# Ensure directory holding target file is present.
139151
FileUtils.mkdir_p File.dirname(t.name)
@@ -149,6 +161,10 @@ file "#{GEN_HTML_CSR_TABLE}" => [
149161

150162
# Just copy static HTML file.
151163
FileUtils.copy_file(SRC_CSR_HTML_PNAME, t.name)
164+
165+
# Copy static JS file for table loading
166+
js_target = File.join(File.dirname(t.name), File.basename(SRC_LOAD_TABLE_JS_PNAME))
167+
FileUtils.copy_file(SRC_LOAD_TABLE_JS_PNAME, js_target)
152168
end
153169

154170
file "#{GEN_JS_EXT_TABLE}" => [

0 commit comments

Comments
 (0)