Skip to content

Performance regression launching promises in Shiny 1.10 #4213

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

Open
shikokuchuo opened this issue May 2, 2025 · 0 comments · May be fixed by #4214
Open

Performance regression launching promises in Shiny 1.10 #4213

shikokuchuo opened this issue May 2, 2025 · 0 comments · May be fixed by #4214

Comments

@shikokuchuo
Copy link
Member

Symptom

In Shiny 1.10, launching many promises at once e.g. by mirai::mirai() or mirai::mirai_map() is now noticeably slower than in previous versions.

Using this mirai Shiny vignette example, this blocked 1-2s before the counter started to update in v1.9.1, whereas in v1.10 it's taking up to 14s.

Cause

The cause has been isolated to this PR #4156 related to limiting deep call stack growth.

Profiling using profvis shows recursive calls to the hashing for stack trace deduplication taking up the most of the time. In fact most of the time is spent in this getCallNames() function, with the format() call within that being a particularly egregious offender.

Solution

@cpsievert looked over the evidence I provided and agrees on the cause. He also suggested a fix that gets us most of the way back (now blocking 3-4s).

As hashing uses rlang::hash(), this can take any arbitrary R object not just a string. Hence we can use another version of getCallNames() that completely avoids the expensive formatting calls, as long as they keep the structure of the calls and produce unique hashes.

@jcheng5 this is the issue I mentioned in passing a while ago.

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 a pull request may close this issue.

1 participant