Closed balbirthomas closed 1 year ago
This is completely normal. The program sits in a very tight loop servicing any GUI events such as mouse or keyboard clicks. The program in not multi-threaded and the main loop serves both the GUI events and capturing data and re-drawing the screen (when Run is clicked) etc. The OS will interrupt as needed to use the CPU for other programs based on priority.
Hi @damercer. Thank you for your response. I do not know the internals of Alice to dwell into details and you may very well be right. If it is any help I did try a Python/Tk based application for another device -- expeyes that I think is also single threaded. Attached is a screenshot of the application with output from top
.
However please do close the ticket if you feel that the particular nature of Alice precludes lower CPU usage.
I did a bit of profiling using the cProfile
module as in
python -m cProfile -o alice.log alice.py
alice.log is attached.
Then I used the pstats
to summarize the results of the 1 minute run of alice without any acquisition as in
import pstats
from pstats import SortKey
p = pstats.Stats('alice.log')
p.strip_dirs().sort_stats(-1).print_stats()
From the attached summary
stats.txt, given my limited knowledge of Alice's internals, the best I can infer is that the load seems to be generated by the Analog_In()
method's call to root.update()
and root.update_idletasks()
. Perhaps this is what you may have referred to when you mentioned the "tight" event loop. Though I am a bit surprised that Analog_In()
would still call update
methods in the absence of any acquisition.
PS: Is there any internals or developer documentation for Alice ? If I understood it a bit better I could do a deeper dive.
The “problem” has been identified and solved. Fixed version will be in next scheduled release. Releases are generally timed to the academic year (calendar).
Thanks for you interest.
From: Balbir Thomas @.> Sent: Sunday, March 13, 2022 9:33 AM To: analogdevicesinc/alice @.> Cc: Mercer, Doug @.>; Mention @.> Subject: Re: [analogdevicesinc/alice] Alice has high CPU usage even when stopped (Issue #18)
[External]
I did a bit of profiling using the cProfile module as in
python -m cProfile -o alice.log alice.py
alice.loghttps://urldefense.com/v3/__https:/github.com/analogdevicesinc/alice/files/8239580/alice.log__;!!A3Ni8CS0y2Y!rI_gfPM83ni1eyFm2LMXmOBwYXhPN9lE1b-my8rvrSDwweK8XOhzdKKIOOY6XuBdXw$ is attached. Then I used the pstats to summarize the results of the 1 minute run of alice without any acquisition as in
import pstats
from pstats import SortKey
p = pstats.Stats('alice.log')
p.strip_dirs().sort_stats(-1).print_stats()
From the attached summary stats.txthttps://urldefense.com/v3/__https:/github.com/analogdevicesinc/alice/files/8239584/stats.txt__;!!A3Ni8CS0y2Y!rI_gfPM83ni1eyFm2LMXmOBwYXhPN9lE1b-my8rvrSDwweK8XOhzdKKIOOYIWc8v_g$, given my limited knowledge of Alice's internals, the best I can infer is that the load seems to be generated by the Analog_In() method's call to root.update() and root.update_idletasks(). Perhaps this is what you may have referred to when you mentioned the "tight" event loop. Though I am a bit surprised that Analog_In() would still call update methods in the absence of any acquisition.
PS: Is there any internals or developer documentation for Alice ? If I understood it a bit better I could do a deeper dive.
— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/analogdevicesinc/alice/issues/18*issuecomment-1066103427__;Iw!!A3Ni8CS0y2Y!rI_gfPM83ni1eyFm2LMXmOBwYXhPN9lE1b-my8rvrSDwweK8XOhzdKKIOOaZVyqu8Q$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ACZAX2QZCUQP5XPFLW5KPODU7XVBPANCNFSM5QBMUNMA__;!!A3Ni8CS0y2Y!rI_gfPM83ni1eyFm2LMXmOBwYXhPN9lE1b-my8rvrSDwweK8XOhzdKKIOObyVGeMhg$. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.com/v3/__https:/apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!A3Ni8CS0y2Y!rI_gfPM83ni1eyFm2LMXmOBwYXhPN9lE1b-my8rvrSDwweK8XOhzdKKIOOaU_SfCWQ$ or Androidhttps://urldefense.com/v3/__https:/play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!A3Ni8CS0y2Y!rI_gfPM83ni1eyFm2LMXmOBwYXhPN9lE1b-my8rvrSDwweK8XOhzdKKIOOYvepTtKA$. You are receiving this because you were mentioned.Message ID: @.***>
Using Alice Desktop Version 1.3.14 Dec 7 2022 I am no longer seeing high CPU usage and am hence closing this issue. Thank you very much.
Issue
Alice desktop (python script) when launched has high CPU usage even when no acquisition is being done (i.e. "stop" button has be pressed). CPU usage is about 80-90% on the core that Alice is running on.
Version-1.3
branch.