Mintplex-Labs / anything-llm

The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, and more.
https://anythingllm.com
MIT License
27.47k stars 2.77k forks source link

AnythingLLM lags and freezes. #2602

Closed DangerousBerries closed 1 week ago

DangerousBerries commented 2 weeks ago

I'm using Dockerized AnythingLLM. When I mouse over things like the edit/copy buttons, send new messages, or save edits, AnythingLLM freezes and slows down for something like half a minute. It doesn't seem to use the CPU/GPU much when it lags, can anything be done about that? Why does this happen? This happens specifically in very long chats, but I need that context.

I tried to ask Claude about this... It told me the lag is likely related to: React's event handling system dealing with many interactive elements Browser rendering updates for hover states and UI changes Large DOM tree traversal in long conversations Virtual scrolling/windowing should be implemented: Only render messages currently in view Reduce active DOM elements Libraries like react-window or react-virtualized can help Check if there are any React development modes enabled: Ensure you're using production builds Development builds have extra checks that can slow things down Profile the application: Use React Developer Tools Check Chrome/Edge Performance panel Look for long tasks and render bottlenecks
timothycarambat commented 1 week ago

Being in docker, this almost seems like it would be related to the browser. When this lag occurs, is the microphone icon in the prompt window visible and does this only happen in the chat window on load?

Otherwise, you may want to turn of hardware acceleration in your browser

DangerousBerries commented 1 week ago

Being in docker, this almost seems like it would be related to the browser. When this lag occurs, is the microphone icon in the prompt window visible and does this only happen in the chat window on load?

Otherwise, you may want to turn of hardware acceleration in your browser

No microphone icon. This happens in the chat window every time I mouse over something or submit anything, not only on load. This happens in Firefox, Edge, and Chrome. I tried turning off hardware acceleration and it didn't change anything. There's no lag in short chats.

You think this is a Docker problem? is there a way to copy chats between them so I could test the Desktop version?

timothycarambat commented 1 week ago

I dont think its a docker issue since it happens when even just hovering over icons and actions. If the microphone icon is missing I wonder if there is something going on with the permission request firing over and over to load the microphone.

What are you machine specs also? I dont think this is the docker container. When a performance monitor open do you seem RAM spikes in the browser process when this is going on?

Also how many chats in the history are we talking about here šŸ‘€

DangerousBerries commented 1 week ago

I dont think its a docker issue since it happens when even just hovering over icons and actions. If the microphone icon is missing I wonder if there is something going on with the permission request firing over and over to load the microphone.

What are you machine specs also? I dont think this is the docker container. When a performance monitor open do you seem RAM spikes in the browser process when this is going on?

Also how many chats in the history are we talking about here šŸ‘€

Oh wait the prompt window, the send a message box? the microphone icon in the bottom right? its there when it lags sorry. The browser pretty much freezes, it even gives me "this page isn't responding" sometimes. I use the AORUS 17H laptop https://www.gigabyte.com/Laptop/AORUS-17H--2023/sp#sp RAM stays the same, CPU goes up a little bit. Is there a way to check the chat number? It will take time to count to be honest.

Edit: Gemini says its 57,985 tokens and 77 AI responses.

timothycarambat commented 1 week ago

With those specs its certainly not the machine then. No wild extensions on the page or anything right?

Might be worth opening the chrome inspector and running a benchmark or something - certainly something is going on. Easiest way would be going to settings > workspace chats and telling me how many pages are there and just assuming every chat is in the window

DangerousBerries commented 1 week ago

With those specs its certainly not the machine then. No wild extensions on the page or anything right?

Might be worth opening the chrome inspector and running a benchmark or something - certainly something is going on. Easiest way would be going to settings > workspace chats and telling me how many pages are there and just assuming every chat is in the window

I counted 20 pages. How do I run a benchmark?

timothycarambat commented 1 week ago

If you right click on the window after its done lagging and go to inspect it will open up a popup, go to "Perfomance" tab and click on record button and let it reload the page. Should become clear which process is taking forever to finish or looping.

DangerousBerries commented 1 week ago

If you right click on the window after its done lagging and go to inspect it will open up a popup, go to "Perfomance" tab and click on record button and let it reload the page. Should become clear which process is taking forever to finish or looping.

2024-11-08 21_08_36-AnythingLLM _ Your personal LLM trained on anything

This is what showed up.

FunctionZ @ index.js:25:1892 Functionk @ index.js:25:1388 Functionw0 @ index.js:40:34408 Function(anonymous) @ index.js:40:40648 Functionmo @ index.js:40:41239

DangerousBerries commented 1 week ago

It's pretty much unusable now. Is there anything that can be temporarily done about this?

2024-11-13 18_15_02-Settings

timothycarambat commented 1 week ago

Found the root cause - fixed in https://github.com/Mintplex-Labs/anything-llm/pull/2627

When that is mered and the latest tag is deployed to docker you can re-pull the image and it will be resolved.

timothycarambat commented 1 week ago

Building now: https://github.com/Mintplex-Labs/anything-llm/actions/runs/11824161974/job/32945059599

DangerousBerries commented 1 week ago

Found the root cause - fixed in #2627

When that is mered and the latest tag is deployed to docker you can re-pull the image and it will be resolved.

Loading the chat takes about half the time I think, but many actions are still very laggy:

I click the edit button and then cancel.

clicking the edit and canceling

I click the copy button. After the freeze, I try to scroll, but scrolling is laggy. When I click the middle mouse button to auto-scroll, it freezes again.

copying then middle click

I just hover over the edit button.

Hovering

Is there a way to delete all responses besides the last 45 ones? If there is I could fork the chat, I assume that would help.

timothycarambat commented 1 week ago

@DangerousBerries Can you confirm what docker tag and SHA you are on? After that above build was completed you re-pulled the image and deleted and started a new container in docker?

That call stack still very much looks like the previous image and you never upgraded it.

You can get the SHA from docker manifest

DangerousBerries commented 1 week ago

@DangerousBerries Can you confirm what docker tag and SHA you are on? After that above build was completed you re-pulled the image and deleted and started a new container in docker?

That call stack still very much looks like the previous image and you never upgraded it.

You can get the SHA from docker manifest

My bad you're right. Many thanks.

timothycarambat commented 1 week ago

sha256:0a3c126d696c072bf739db9e2e8c26cc0685a69fd9a03db7ba78e7be0cbc1443

Is the current index digest - you have also totally destroyed the previous container and restored it with the new image? pulling the newest image typically does not rebuild the entire container. I am not sure how Watchtower works as I have never used it.

My process is usually docker pull mintplexlabs:anythingllm:latest docker rm <CONTAINER> Then run the normal start command

export STORAGE_LOCATION=$HOME/anythingllm && \
mkdir -p $STORAGE_LOCATION && \
touch "$STORAGE_LOCATION/.env" && \
docker run -d -p 3001:3001 \
--cap-add SYS_ADMIN \
-v ${STORAGE_LOCATION}:/app/server/storage \
-v ${STORAGE_LOCATION}/.env:/app/server/.env \
-e STORAGE_DIR="/app/server/storage" \
mintplexlabs/anythingllm

Then i should have a new container with new name/container ID that is using the just pulled image. Ill even usually docker prune just to get rid of duplicate/stales

EDIT: Saw your response