Closed Bug 1166889 Opened 9 years ago Closed 9 years ago

Deactivate addon monitoring when the system is too busy

Categories

(Toolkit :: Performance Monitoring, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1200172

People

(Reporter: Yoric, Unassigned)

References

(Depends on 1 open bug)

Details

When the system is too busy (in particular when it's swapping), the add-on monitor is going to blame add-ons although they are not necessarily the culprits. We should deactivate addon monitoring (and possibly jank monitoring) when the system is busy due to other processes.
Any idea on how we could get the information under Windows, Aaron? Under MacOS, André? On other OSes, anyone?
Flags: needinfo?(areinald)
Flags: needinfo?(aklotz)
Also asking Paul, as this may be a problem also encountered in WebRTC.
Blocks: 1137635
No longer blocks: 1136927
Flags: needinfo?(padenot)
We have some sort of a CPU monitoring thing for WebRTC [0], that is used to back-off some costly processing bits. 

[0]: https://dxr.mozilla.org/mozilla-central/source/dom/media/systemservices/LoadMonitor.h
Flags: needinfo?(padenot)
Any chance you could move this to toolkit?
Flags: needinfo?(padenot)
I haven't written the code, it was gcp and pkerr iirc, I just happen to know it exists.

gcp, pkerr, any objection to moving the load monitor somewhere other people can use it? This would help Yoric to implement a more reliable add-on monitoring code to detect add-ons that are slowing down Firefox.
Flags: needinfo?(pkerr)
Flags: needinfo?(padenot)
Flags: needinfo?(gpascutto)
(In reply to David Rajchenbach-Teller [:Yoric] (use "needinfo") from comment #1)
> Any idea on how we could get the information under Windows, Aaron? Under
> MacOS, André? On other OSes, anyone?

For Mac, either use host_processor_info or host_statistics, they are defined in mach/... includes.
Useful info can be found here:
https://stackoverflow.com/questions/20471920/how-to-get-total-cpu-idle-time-in-objective-c-c-on-os-x

But if we already have working code to do that, it would make more sense to use it.
Flags: needinfo?(areinald)
(In reply to Paul Adenot (:padenot) from comment #6)
> gcp, pkerr, any objection to moving the load monitor somewhere other people
> can use it? This would help Yoric to implement a more reliable add-on
> monitoring code to detect add-ons that are slowing down Firefox.

No, seems like a fine idea. It was always meant as a generic service, there just weren't any consumers outside the media code yet.
Flags: needinfo?(gpascutto)
> No, seems like a fine idea. It was always meant as a generic service, there
> just weren't any consumers outside the media code yet.

Filed as bug 1167175.
(In reply to Paul Adenot (:padenot) from comment #6)
> I haven't written the code, it was gcp and pkerr iirc, I just happen to know
> it exists.
> 
> gcp, pkerr, any objection to moving the load monitor somewhere other people
> can use it? This would help Yoric to implement a more reliable add-on
> monitoring code to detect add-ons that are slowing down Firefox.

It is designed to notify multiple interested parties about system load. Moving it to toolkit should not impact our use for WebRTC. The code already contains OS specific mechanisms (some mentioned above) for load monitoring. When I landed the Windows and OSX bits, I confirmed that the reports matched the load monitoring tools supplied with each OS.
Flags: needinfo?(pkerr)
(In reply to David Rajchenbach-Teller [:Yoric] (use "needinfo") from comment #1)
> Any idea on how we could get the information under Windows, Aaron? Under
> MacOS, André? On other OSes, anyone?

Windows does expose performance counter data that could be used for this. See https://msdn.microsoft.com/en-us/library/windows/desktop/aa371903%28v=vs.85%29.aspx for API info. You could use the "Pages/sec" counter described at https://technet.microsoft.com/en-us/library/cc778082%28v=ws.10%29.aspx. The only problem with that counter is that the threshold for what constitutes "excessive" paging is relative to the system itself. One suggestion from https://msdn.microsoft.com/en-us/library/aa746253%28v=bts.10%29.aspx is to "observe whether processor activity drops significantly as paging increases."
Flags: needinfo?(aklotz)
(In reply to Aaron Klotz [:aklotz] (please use needinfo) from comment #11)
> (In reply to David Rajchenbach-Teller [:Yoric] (use "needinfo") from comment
> #1)
> > Any idea on how we could get the information under Windows, Aaron? Under
> > MacOS, André? On other OSes, anyone?
> 
> Windows does expose performance counter data that could be used for this.
> See
> https://msdn.microsoft.com/en-us/library/windows/desktop/aa371903%28v=vs.
> 85%29.aspx for API info. You could use the "Pages/sec" counter described at
> https://technet.microsoft.com/en-us/library/cc778082%28v=ws.10%29.aspx. The
> only problem with that counter is that the threshold for what constitutes
> "excessive" paging is relative to the system itself. One suggestion from
> https://msdn.microsoft.com/en-us/library/aa746253%28v=bts.10%29.aspx is to
> "observe whether processor activity drops significantly as paging increases."

There is code in LoadMonitor.cpp that contains OS specific mechanisms for determining per CPU and total system processing load.
https://dxr.mozilla.org/mozilla-central/source/dom/media/systemservices/LoadMonitor.cpp#485
https://dxr.mozilla.org/mozilla-central/source/dom/media/systemservices/LoadMonitor.cpp#379

Paging is not something that was measured directly for the WebRTC monitor.
Done differently in bug 1200172.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.