No runtime found, using MemoryCacheStorageManager

Hi, I have created the following application for streamlit and I think I am losing a lot of performance because of the cache. When I run one of the pages in visual studio, I get this in the console repeatedly

If you go into the application, you can see how it is too long in running time. I have measured the code execution time in python and it is quite low.
2

If you’re experiencing performance issues with your Streamlit application, particularly related to the caching mechanism, here are a few suggestions to improve the performance:

  1. Optimize your code: Analyze your code to identify any potential bottlenecks or areas that can be optimized. Look for inefficient loops, redundant calculations, or unnecessary data manipulation. By improving the efficiency of your code, you can reduce the overall execution time.

  2. Granular caching: Check if you’re caching the entire page or function when only specific parts need to be cached. Streamlit’s caching mechanisms, such as @st.cache decorator, allow you to cache specific functions or sections of code. By narrowing down the scope of what you cache, you can avoid unnecessary recalculations and improve performance.

  3. Use memoization techniques: Streamlit’s caching mechanism is based on memoization. However, in some cases, you might benefit from implementing your own memoization technique tailored to your specific use case. This allows you to have more fine-grained control over the caching process and optimize it according to your needs.

  4. Leverage background processes: If your Streamlit app involves long-running tasks or computations, consider offloading those tasks to background processes or worker threads. This can prevent the UI from becoming unresponsive and enhance overall performance. You can use Python libraries like multiprocessing or concurrent.futures to achieve parallel or asynchronous execution.

  5. Profile your code: Use profiling tools, such as Python’s cProfile module, to identify the exact areas of your code that are taking the most time to execute. This will help you pinpoint performance bottlenecks and focus your optimization efforts where they will have the most impact.

  6. Consider asynchronous programming: If your Streamlit app involves making multiple external API calls or performing I/O operations, consider using asynchronous programming techniques. Libraries like asyncio or aiohttp allow you to perform multiple tasks concurrently, improving overall performance by minimizing waiting times.

By following these suggestions, you can identify and address performance bottlenecks in your Streamlit application. Remember to profile your code to target specific areas for optimization and test the performance improvements iteratively.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.