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
chore: greatly speed up migrator and lower memory usage #2874
chore: greatly speed up migrator and lower memory usage #2874
Conversation
- prevent disabling password login - prevent updating `memos-demo` user - prevent setting additional style - prevent setting additional script - add some error feedback to system settings UI
This reverts commit 2716377.
- remove all Store indirections - query database directly with prepared statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think we can remove these migrators writen with golang in the next release.
still |
Try using |
Same. I pulled the latest v0.19. When logged in the latest memos seem to be loaded normally, but once I clicked click to fetch more the page crashed. After refresh clicked fetch more again and it crashed again. Same applied to the explore page. |
I have tried |
Works fine for me! Thanks a lot. |
At some point, these migrations probably should be split into each database driver. But in it's current state, the queries used in these migrations are compatible across SQLite, Postgres and MySQL.
This most likely closes #2850.
The resource path migrator is taking more than 25 minutes to complete with 300k resources at current v0.19.0. Memory usage peaked at 280MB, and CPU usage is not so high, but never goes down. And as it commits each change separately, the total data written on disk is also nuts, going over 2.5GB. That's probably why some VPS and low-end systems are having a hard time to upgrade to v0.19.0.
memos-stable-1 | 2024-01-31T08:09:14.919Z INFO store/migrator.go:54 migrated 300000 local resource paths in 28m31.269576206s
At time of writing, it's still stuck with this message, probably still committing data, and the server is not yet available.
This PR brings down the migration time with the same dataset to under 4 seconds in my machine, and the memory usage never goes beyond 125 MB. The total data written is a little over the database size (113 MB).
memos-dev-1 | 2024-01-31T07:40:45.866Z INFO store/migrator.go:108 Migrated 300000 local resource paths in 3.860779589s
Both containers on these captures were seeded with the same data and started at the same time.
If you'd like, I can add the docker-compose file and the Python seeding script that helped with this testing.