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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade react-range to fix memory usage of sliders #6764

Merged
merged 1 commit into from May 31, 2023

Conversation

wolfd
Copy link
Contributor

@wolfd wolfd commented May 30, 2023

馃摎 Context

As mentioned in https://blog.streamlit.io/six-tips-for-improving-your-streamlit-app-performance/ memory usage struggles in the browser if you have large ranges:

Due to implementation details, high-cardinality sliders don't suffer
from the serialization and network transfer delays mentioned earlier,
but they will still lead to a poor user experience (who needs to
specify house prices up to the dollar?) and high memory usage. In my
testing, the example above increased RAM usage by gigabytes until the
web browser eventually gave up (though this is something that should
be solvable on our end. We'll look into it!)

  • What kind of change does this PR introduce?

    • Bugfix
    • Feature
    • Refactoring
    • Other, please describe:

馃 Description of Changes

This was caused by a bug in react-range, which I fixed last year. tajo/react-range#178

At the time, I had figured it would get picked up by a random yarn upgrade and didn't worry too much about it.
But, apparently yarn doesn't really have an easy way of doing upgrades of transitive dependencies (see yarnpkg/yarn#4986)? I took the suggestion of someone in that thread to delete the entry and let yarn regenerate it.

Some technical details about the react-range fix from the original commit message (the "application" is a streamlit app):

We have an application that uses react-range under the hood, and we
noticed that a range input was taking 2GB of RAM on our machines. I
did some investigation and found that regardless of whether the marks
functionality was being used, refs were being created for each
possible value of the range.

We have some fairly huge ranges (we're using the input to scrub a
video with potential microsecond accuracy), and can imagine that
other people are affected by the previous behavior. This change
should allow us to continue using large input ranges without
incurring a memory penalty.

  • This is a breaking API change
  • This is a visible (user-facing) change

Revised:

(no visible changes)

Current:

(no visible changes)

馃И Testing Done

  • Screenshots included
  • Added/Updated unit tests
  • Added/Updated e2e tests

馃寪 References


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

As mentioned in
https://blog.streamlit.io/six-tips-for-improving-your-streamlit-app-performance/
memory usage struggles in the browser if you have large ranges:

> Due to implementation details, high-cardinality sliders don't suffer
> from the serialization and network transfer delays mentioned earlier,
> but they will still lead to a poor user experience (who needs to
> specify house prices up to the dollar?) and high memory usage. In my
> testing, the example above increased RAM usage by gigabytes until the
> web browser eventually gave up (though this is something that should
> be solvable on our end. We'll look into it!)

This was caused by a bug in react-range, which I fixed last year.
tajo/react-range#178

At the time, I had figured it would get picked up by a random yarn
upgrade and didn't worry too much about it.
But, apparently yarn doesn't really have an easy way of doing upgrades
of transitive dependencies (see yarnpkg/yarn#4986)?
I took the suggestion of someone in that thread to delete the entry and
let yarn regenerate it.

Some technical details about the react-range fix from the original
commit message (the "application" is a streamlit app):

> We have an application that uses react-range under the hood, and we
> noticed that a range input was taking 2GB of RAM on our machines. I
> did some investigation and found that regardless of whether the marks
> functionality was being used, refs were being created for each
> possible value of the range.

> We have some fairly huge ranges (we're using the input to scrub a
> video with potential microsecond accuracy), and can imagine that
> other people are affected by the previous behavior. This change
> should allow us to continue using large input ranges without
> incurring a memory penalty.
Copy link
Collaborator

@vdonato vdonato left a comment

Choose a reason for hiding this comment

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

馃帀 thanks @wolfd!

@vdonato vdonato merged commit c464422 into streamlit:develop May 31, 2023
42 checks passed
tconkling added a commit to tconkling/streamlit that referenced this pull request Jun 6, 2023
* develop:
  Remove tensorflow and pytorch from test requirements (streamlit#6807)
  Fix readme links (streamlit#6800)
  Update PR template to be simpler and more approachable (streamlit#6679)
  README updated with links to docs (streamlit#6780)
  Refactor: withHostCommunication -> HostCommunicationManager (streamlit#6746)
  Add python 3.11 to classifiers list. (streamlit#6786)
  Release/1.23.1 (streamlit#6777)
  We depend on typing-extensions 4.0.1 (streamlit#6776)
  Release/1.23.0 (streamlit#6773)
  Fix typo in data_editor docstring and deprecation msg: `edited_rows` -> `edited_cells` (streamlit#6770)
  Fix: Remove flaky date input calendar snapshot test (streamlit#6769)
  Fix 3218, patch pydantic in_ipython function (streamlit#6664)
  Upgrade react-range to fix memory usage of sliders (streamlit#6764)
  Make st.write pretty-print dataclasses using st.help (streamlit#6750)
  Replace curly with straightquotes in docstring examples (streamlit#6757)
eric-skydio pushed a commit to eric-skydio/streamlit that referenced this pull request Dec 20, 2023
As mentioned in
https://blog.streamlit.io/six-tips-for-improving-your-streamlit-app-performance/
memory usage struggles in the browser if you have large ranges:

> Due to implementation details, high-cardinality sliders don't suffer
> from the serialization and network transfer delays mentioned earlier,
> but they will still lead to a poor user experience (who needs to
> specify house prices up to the dollar?) and high memory usage. In my
> testing, the example above increased RAM usage by gigabytes until the
> web browser eventually gave up (though this is something that should
> be solvable on our end. We'll look into it!)

This was caused by a bug in react-range, which I fixed last year.
tajo/react-range#178

At the time, I had figured it would get picked up by a random yarn
upgrade and didn't worry too much about it.
But, apparently yarn doesn't really have an easy way of doing upgrades
of transitive dependencies (see yarnpkg/yarn#4986)?
I took the suggestion of someone in that thread to delete the entry and
let yarn regenerate it.

Some technical details about the react-range fix from the original
commit message (the "application" is a streamlit app):

> We have an application that uses react-range under the hood, and we
> noticed that a range input was taking 2GB of RAM on our machines. I
> did some investigation and found that regardless of whether the marks
> functionality was being used, refs were being created for each
> possible value of the range.

> We have some fairly huge ranges (we're using the input to scrub a
> video with potential microsecond accuracy), and can imagine that
> other people are affected by the previous behavior. This change
> should allow us to continue using large input ranges without
> incurring a memory penalty.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Mar 22, 2024
As mentioned in
https://blog.streamlit.io/six-tips-for-improving-your-streamlit-app-performance/
memory usage struggles in the browser if you have large ranges:

> Due to implementation details, high-cardinality sliders don't suffer
> from the serialization and network transfer delays mentioned earlier,
> but they will still lead to a poor user experience (who needs to
> specify house prices up to the dollar?) and high memory usage. In my
> testing, the example above increased RAM usage by gigabytes until the
> web browser eventually gave up (though this is something that should
> be solvable on our end. We'll look into it!)

This was caused by a bug in react-range, which I fixed last year.
tajo/react-range#178

At the time, I had figured it would get picked up by a random yarn
upgrade and didn't worry too much about it.
But, apparently yarn doesn't really have an easy way of doing upgrades
of transitive dependencies (see yarnpkg/yarn#4986)?
I took the suggestion of someone in that thread to delete the entry and
let yarn regenerate it.

Some technical details about the react-range fix from the original
commit message (the "application" is a streamlit app):

> We have an application that uses react-range under the hood, and we
> noticed that a range input was taking 2GB of RAM on our machines. I
> did some investigation and found that regardless of whether the marks
> functionality was being used, refs were being created for each
> possible value of the range.

> We have some fairly huge ranges (we're using the input to scrub a
> video with potential microsecond accuracy), and can imagine that
> other people are affected by the previous behavior. This change
> should allow us to continue using large input ranges without
> incurring a memory penalty.
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
As mentioned in
https://blog.streamlit.io/six-tips-for-improving-your-streamlit-app-performance/
memory usage struggles in the browser if you have large ranges:

> Due to implementation details, high-cardinality sliders don't suffer
> from the serialization and network transfer delays mentioned earlier,
> but they will still lead to a poor user experience (who needs to
> specify house prices up to the dollar?) and high memory usage. In my
> testing, the example above increased RAM usage by gigabytes until the
> web browser eventually gave up (though this is something that should
> be solvable on our end. We'll look into it!)

This was caused by a bug in react-range, which I fixed last year.
tajo/react-range#178

At the time, I had figured it would get picked up by a random yarn
upgrade and didn't worry too much about it.
But, apparently yarn doesn't really have an easy way of doing upgrades
of transitive dependencies (see yarnpkg/yarn#4986)?
I took the suggestion of someone in that thread to delete the entry and
let yarn regenerate it.

Some technical details about the react-range fix from the original
commit message (the "application" is a streamlit app):

> We have an application that uses react-range under the hood, and we
> noticed that a range input was taking 2GB of RAM on our machines. I
> did some investigation and found that regardless of whether the marks
> functionality was being used, refs were being created for each
> possible value of the range.

> We have some fairly huge ranges (we're using the input to scrub a
> video with potential microsecond accuracy), and can imagine that
> other people are affected by the previous behavior. This change
> should allow us to continue using large input ranges without
> incurring a memory penalty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

st.slider crashes browser tab when max_value=500000000 and step=1
2 participants