-
Notifications
You must be signed in to change notification settings - Fork 154
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
pickerInput is slow to render large amounts of data #184
Comments
Mmmh thanks for reporting that, it's indeed an issue with the R code ( |
That would be excellent if it could be improved. Let me know how I can help, thanks! |
I agree it. I am using pickerInput very useful, but I have same problem. Please improve this problem. |
Just to confirm, I've tested this with the underlying javascript library (bootstrap-select v1.13.0) and it doesn't seem to be slow when using the javascript library directly (example). So this does suggest that there may be a performance issue with the R implementation |
Hi Daattali, |
This is the (internal) R function shinyWidgets/R/input-selectpicker.R Line 363 in 43b890a
So the HTML tags generation is slow but it's in R not in HTML : library(shinyWidgets)
choices <- sample.int(1e6, 1e5) # 10000 choices
system.time({
mypicker <- pickerInput(
inputId = "id",
label = "Label :",
choices = choices,
multiple = TRUE
)
}) # 11.78 sec |
Has anyone been using any type of work around for the issue? |
I played a bit with the This is the result with 10.000 choices, with res0 being the original function.
Result with 100.000 choices (I just compared res4 to res0):
Its not very much, but at least a tiny bit faster. :) |
I've updated the function to do the same thing as |
Not only,
And you could also change I think that was it :) |
when will it be updated in the widgets ? |
@lalitsc12 you can install from GitHub to try it out. @trafficonese thanks for the precision, some thoughts :
|
Great! |
@pvictor - Another thing which is much faster. But I think most time-saving will come from the new function |
If i'm not mistaken |
Indeed, |
I ran into this problem with 100,000 options with no choiceOpts. The "mapply" underlying "selectOptions" is very slow (it's essentially running a "for" loop under the hood). It would be much faster to flag list options, run code on just those options, run different code on the non-list options, and then paste everything together. Also - note that "vapply" is faster than "sapply" and is more reliable because you can specify the function return value. The code below (which worked on a few test examples, although I didn't test it thoroughly) took .36 seconds with 100000 choices, where the original function took 37.8 seconds. If you can get away from using mapply/lapply, the calls will be much faster.
|
Hi! I'm facing this issue as well, of picker input being slow about rendering large amounts of data. I have a vector of ~50K records. Has any solution been implemented yet? |
I am struggling with this as well with ~20,000+ choices. I am thinking of using
This is out of my depth, but I wonder if existing code from Update: When profiling my shiny app, it looked like |
|
Has this been finally implemented ? |
Hello, Thanks |
@lalitsc12 You should take a look at |
hello, Thanks |
@lalitsc12 That's correct, you can choose to render only 100 values but then search to render more values. It drastically improves performance. |
@tyluRp |
Here's an example with server-side library(shiny)
# choices: 97,310 names
baby_names <- sort(unique(babynames::babynames$name))
# ui
ui <- fluidPage(
selectizeInput(
inputId = "ID",
label = "Select Something",
choices = NULL,
selected = 1
)
)
# server
server <- function(input, output, session) {
updateSelectizeInput(
session = session,
inputId = "ID",
choices = baby_names,
server = TRUE
)
}
# app
shinyApp(ui = ui, server = server) There's no equivalent with Victor |
@pvictor - do you think you will implement the change suggested |
Hi there! I am running into the same problem and it looks like the suggestions here have not yet been implemented to date. Could you please provide a walkthrough on how to implement this? |
@jgsarm-rb There are effectively three ways of implementing and testing a change like this:
|
@swnydick cool! So I simply have to fork pickerInput's repo here, replace pickerSelectOptions with your own version (selectOptions), and use that repo to install the modified package in my R installation. Did I get that right? |
@jgsarm-rb yes that should work, unless there have been any other changes under-the-hood to the package since the original comments that make the package not work anymore with this change. |
I was wondering the same thing. |
I did what @swnydick told me to do. It reduced the 50 second processing time to just a fraction of a second. Now, the only thing left is to speed up is the rendering of the actual drop down menu. From a whopping 1:58 to render 100k choices, now it's down to 50s. |
@jgsarm-rb that's great news! I hope the dropdown menu part soon gets optimized as well. If @pvictor finds it suitable, would you be willing to submit a PR of what you accomplished so far? |
Sure you can submit a PR with those improvments, just be sure that results are the same than before. Moreover, in last pre-release of bootstrap-select you have a |
I submitted a pull request for the issue. Thanks @pvictor! |
If you need a fast select menu, here's an experiment: https://github.com/dreamRs/shinyvs |
@pvictor Holy cow Victor! I tried this and it works fine. I have to put this into bigger tests with our applications and will report if I encounter any bugs. How do I submit feedback? Posting it in this thread will deviate from the topic at hand. |
Thanks for testing @jgsarm-rb ! You can try the discussion feature in the other repo : https://github.com/dreamRs/shinyvs/discussions |
@pvictor , this is great man! |
in accordance with dreamRs#184 comment by user swnydick
Hello,
I'm using pickerInput in my shiny apps due to the nice built in features, i.e. live-search and action-box to select/deselect all options. I have a large amount of data in some of these, ~10,000 options in some. This may seem extreme but it's manageable with the search features. I'm trying to reduce load time for my app and I've found pickerInputs with large amounts of data are the biggest issue. When comparing load time to a selectizeInput it takes about 12 times the time to load. I understand the additional features (live-search and action-box) may take additional time to load, if I remove the additional features it still takes 10 times the amount of time to load, (both instances I use virtual-scrolling for the pickerInput).
I've attached screenshots of the profile run in R.
Below is the sample app with a pickerInput and selectizeInput you can run to see the performance difference.
I know my case may be the extreme but it would be nice if the performance was closer to that of selectizeInput, not sure if there's anything in the code that could be optimized. Thanks!
Run without
actions-box
= TRUE &live-search
= TRUE:Run WITH
actions-box
= TRUE &live-search
= TRUE:The text was updated successfully, but these errors were encountered: