Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AG-14117 - Fix tooltip forced relayout + misc optimisations. #3744

Merged
merged 6 commits into from
Mar 12, 2025

Conversation

alantreadway
Copy link
Member

@alantreadway alantreadway requested a review from a team as a code owner March 11, 2025 12:52
@alantreadway alantreadway changed the title ag 14117/fix tooltip size forcing relayout AG-14117 - Fix tooltip size forcing relayout. Mar 11, 2025
@alantreadway alantreadway force-pushed the ag-14117/fix-tooltip-size-forcing-relayout branch from ef17fc5 to 45469e6 Compare March 11, 2025 13:00
@alantreadway alantreadway changed the title AG-14117 - Fix tooltip size forcing relayout. AG-14117 - Fix tooltip positioning forcing relayout. Mar 11, 2025
@alantreadway alantreadway changed the title AG-14117 - Fix tooltip positioning forcing relayout. AG-14117 - Fix tooltip forced relayout + misc optimisations. Mar 12, 2025
@@ -890,7 +890,9 @@ export class DataModel<
const columnScopes = new Set(def.scopes);
const columnScope = first(def.scopes);
const columnSource = sources.get(columnScope) as unknown[];
const column = columnSource.map((valueDatum, datumIndex) => {
const column = new Array<unknown>(columnSource.length);
Copy link
Contributor

@jacobp100 jacobp100 Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .map here - if you use new Array(length), it basically forces the array into a Map<number, element> behind the scenes. That was one of the big wins for the high performance work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based upon https://jsbench.me/t6m85tuhgv/1, our best option seems to be to just use new Array() without .map() - the main issue is likely that the closure can't be easily optimised at runtime for this particular case.


const font = TextUtils.toFontString(this);
// Try to avoid this assignment, which typically always incurs a font switch cost.
if (ctx.font !== font) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is showing as a hot path, it might be worth storing the resolved font on the instance too, and reading that to avoid the overhead of crossing the language barrier since the .font getter is C++

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably ok, as with a prior iteration of this change the hotspot was significantly reduced with just this guard added. We'd need to track the current font in the renderContext for this to be accurate, which seems more complexity than I'd like to add right now.

@alantreadway alantreadway merged commit b7f604c into latest Mar 12, 2025
26 checks passed
@alantreadway alantreadway deleted the ag-14117/fix-tooltip-size-forcing-relayout branch March 12, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants