[Feature] Optional immutableMode to bypass expensive cloning and improve performance
- Dominant language
- TypeScript
- Stars
- 67.3k
- Forks
- 19.8k
- Avg merge
- 11d 14h
- Merged PRs (30d)
- 8
Description
### What problem does this feature solve?
In complex applications using frameworks like React, it is difficult to achieve optimal performance due to expensive cloning operations that have no way to opt out of. If the goal of these cloning operations ([example](https://github.com/apache/echarts/blob/4b2d52fd0f5732a6d97b3b808d592982f4138781/src/model/OptionManager.ts#L111)) is to protect ECharts internals from mutations from users of the library, then it may be unnecessary as mutations are an anti-pattern in these contexts.
Having an optional (and initially experimental) property to tell ECharts to bypass cloning would put more responsibility on users to not abuse setOption calls, but could have a high upside for power users struggling with memory / growing JS heap size / inefficient CPU. It may also help with open memory leak issues: #7002, #10130, #19984, #7125, #18312, #18686, [echarts-for-react/issues/533](https://github.com/hustcc/echarts-for-react/issues/533) (these may not actually be memory leaks but are a symptom of lingering performance issues).
### What does the proposed API look like?
Introduce an optional `immutableMode` property to setOption opts, aimed at optimizing performance for large datasets, where charts needs to re-render frequently. A very rough concept can be seen here: https://github.com/sjcobb/echarts/pull/1
Open to feedback on other ideas, [my branch](https://github.com/sjcobb/echarts/pull/1/files#r1635638734) is far from a working prototype, but I want to see if this idea has any traction before diving in further.
Contributor guide
Assessment
This issue has not been assessed yet.