datatable.refresh() takes more than 10x as long to run than rebuilding the table from scratch
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- frontend, performance
Research direction
Reproduce the timing comparison in the provided renderDatatable method using DataTable construction and refresh(), with the column format function enabled and disabled. Use browser profiling around the format callback and refresh path to identify the source of the slowdown; done means explaining the discrepancy and identifying a reliable fix or documented limitation.
Written by the indexing model from the issue text.
Description
The following output was collected from datatable v1.14, but I get similar output for 1.15.3
renderDatatable(data=null) {
console.time('rendertable');
// display the table
this.form.set_df_property(this.formAttr.section, 'hidden', false);
this.form.fields_dict[this.formAttr.section].collapse(false);
// set up the field to receive the datatable
this.form.get_field(this.formAttr.field).html(`
<div id='${this.formAttr.sel.substring(1)}'></div>
`);
// render the datatable
this.table = new DataTable(this.formAttr.sel, {
...this.datatableOptions,
columns : this.columns,
data : data || this.data.tableData,
});
console.timeEnd('rendertable');
console.time('REFRESH');
this.table.refresh();
console.timeEnd('REFRESH');
}
Rendering the table with two rows:
rendertable: 60.090087890625 ms
REFRESH: 666.958984375 ms
60ms seems reasonable to create a table with two rows. Note that I have a format function that runs on most columns. 667ms refresh is an over 10x as slow though. What could be causing the slowdown?
There are inconsistencies, although no practice workarounds that I have discovered aside from re-creating the table from scratch.
This is quite interesting: when I profile my cell format method, the initial table render takes longer (expected, since I'm writing to the log), but the refresh no longer takes extra time to run. Note that I am unable to replicate the speedup in the refresh method by simply forcing the format function to take longer; it only appears to respond to console.time():
formatting: 0.02001953125 ms
formatting: 0.01904296875 ms
formatting: 0.004150390625 ms
formatting: 0.005126953125 ms
formatting: 0.004150390625 ms
formatting: 0.00390625 ms
formatting: 0.003173828125 ms
formatting: 0.00390625 ms
formatting: 0.002685546875 ms
formatting: 0.004150390625 ms
formatting: 0.0087890625 ms
formatting: 0.003662109375 ms
formatting: 0.004150390625 ms
formatting: 0.004150390625 ms
formatting: 0.00390625 ms
formatting: 0.004150390625 ms
formatting: 0.01513671875 ms
formatting: 0.007080078125 ms
formatting: 0.004150390625 ms
formatting: 0.003173828125 ms
formatting: 0.003173828125 ms
formatting: 0.003173828125 ms
formatting: 0.0029296875 ms
formatting: 0.0048828125 ms
formatting: 0.0029296875 ms
formatting: 0.00390625 ms
formatting: 0.001953125 ms
formatting: 0.001708984375 ms
formatting: 0.0029296875 ms
formatting: 0.003173828125 ms
formatting: 0.004150390625 ms
formatting: 0.004150390625 ms
formatting: 0.003173828125 ms
formatting: 0.0048828125 ms
rendertable: 364.31201171875 ms
formatting: 0.005859375 ms
formatting: 0.00390625 ms
formatting: 0.0029296875 ms
formatting: 0.007080078125 ms
formatting: 0.003173828125 ms
formatting: 0.002685546875 ms
formatting: 0.00390625 ms
formatting: 0.0029296875 ms
formatting: 0.003173828125 ms
formatting: 0.003173828125 ms
formatting: 0.0029296875 ms
formatting: 0.0029296875 ms
formatting: 0.003173828125 ms
formatting: 0.003173828125 ms
formatting: 0.002685546875 ms
formatting: 0.0029296875 ms
formatting: 0.0029296875 ms
formatting: 0.002685546875 ms
formatting: 0.003173828125 ms
formatting: 0.003173828125 ms
formatting: 0.0029296875 ms
formatting: 0.003173828125 ms
formatting: 0.001953125 ms
formatting: 0.0029296875 ms
formatting: 0.001953125 ms
formatting: 0.0029296875 ms
formatting: 0.003173828125 ms
formatting: 0.001708984375 ms
formatting: 0.003173828125 ms
formatting: 0.002197265625 ms
formatting: 0.004150390625 ms
formatting: 0.001953125 ms
formatting: 0.0029296875 ms
formatting: 0.0029296875 ms
REFRESH: 383.912109375 ms
What's going on here?
- Dominant language
- JavaScript
- Stars
- 1.3k
- Forks
- 223
- Avg merge
- 23h 14m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from frappe/datatable
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Datatable stops responding to clicks after selecting across collapsed or scrolled-out rowsPossibly taken @RaphaelFakhri claimed this 24 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
Bug with serialNoColumn= falsePossibly taken @Valley-15 claimed this 295 days ago. Open
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in frappe/datatable
Similar issues
-
db-d1-sqlite: upsert is aliased to updateOne, so payload.kv.set never inserts new keysPossibly taken @pcbeingused333 claimed this today. OpenBug db: d1-sqlite Payload OSS
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
payloadcms/payload#19766 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
HarperFast/rocksdb-js#1131 ·
Maintainers usually reply within 1 day
-
Reveal: resolved but blocked Pending boundary hides its fallbackPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
anothaDev/luci-theme-vantage#137 ·
Maintainers usually reply within 1 day
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
wso2/api-platform#4369 ·
Maintainers usually reply within 1 day