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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor::UpdateFPS() clobbers database every second #4199

Open
alandpearson opened this issue Dec 28, 2024 · 9 comments
Open

Monitor::UpdateFPS() clobbers database every second #4199

alandpearson opened this issue Dec 28, 2024 · 9 comments

Comments

@alandpearson
Copy link

Describe Your Environment

  • Version of ZoneMinder [v1.37.65, development ]
  • How you installed ZoneMinder [e.g. .deb package for Debian bookworm]
  • Full name and version of OS
  • Browser name and version (if this is an issue with the web interface)

Describe the bug
In the current master branch zm_monitor.cpp Monitor::UpdateFPS() updates the database every second, causing high io when several cameras are in use. In previous versions (1.36 branch) updates were constrained to every ten seconds.
This causes large IO on the mysql transaction log.
Suggest ten-second behaviour is restored or, behaviour of the database update matches the FPSReportInterval in monitor->misc_>options ?

Either way, once a second seems a little aggressive.

To Reproduce
Steps to reproduce the behavior:

  1. setup a monitor
  2. enable mysql general_log to see all queries
  3. notice every second, every monitor issuing UPDATE LOW_PRIORITY Monitor_Status SET statements

Expected behavior
Database should not be updates each second for monitor status

Copy link

welcome bot commented Dec 28, 2024

Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!

@connortechnology
Copy link
Member

The code is actually set to only do it every 10 seconds per monitor... so that's weird.

@connortechnology
Copy link
Member

We actually put the sql into a queue which gets processed in another thread.. so I suppose if there was a backlog we might see this...but then it could be a lot faster than 1/s and you would think it would catch up quickly. Are there warnings in the logs about a db queue backlog?

@connortechnology
Copy link
Member

I have reproduced this, so I should be able to fix this soon.

@alandpearson
Copy link
Author

alandpearson commented Dec 30, 2024 via email

@alandpearson
Copy link
Author

Thank you Issac, our message overlapped, appreciated.

@connortechnology
Copy link
Member

Apparently I was looking at the code in 1.36 which is every 10 seconds. I guess I never got around to doing the same in master. So now I have.

Honestly though I don't consider 1/s to be a significant load on the db. For event frame data etc we target 1/s for updates.

@alandpearson
Copy link
Author

Thanks. Would it not be better to tie this to the frame update interval ?
You once commented on this reddit thread that is how it should work :

https://www.reddit.com/r/ZoneMinder/comments/127tfso/are_constant_repetitive_database_queries_normal/

On the once per second.. multiply that by all monitors (I have 15) and it’s enough to keep the hard drive light on solid on my system (granted no SSD).
I guess because you’re hitting an ACID complaint DB the overhead is more than you’d imagine.
But it makes sense to be as effecient as possible, so appreciate your attention to it.
I caught my attention as I was trying to debug the high IO (and iowaits) mysql was generating, and took a bit of sleuthing to find out why.

Turning this frequency down really improved my system responsive and dramatically dropped iowait.

Thanks again
Alan

@connortechnology
Copy link
Member

The problem is that people set their update frequency to very large values. This table is like a heartbeat. It is how we know that things are still alive.

Initially I made it an in-ram table, but mysql's ram tables don't have row level locking so it became a bottleneck. You could re-create the table as a ram based and see how that goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants