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

CPU utilisation is very high #392

Open
jagan-pm opened this issue Jun 26, 2024 · 3 comments
Open

CPU utilisation is very high #392

jagan-pm opened this issue Jun 26, 2024 · 3 comments

Comments

@jagan-pm
Copy link

I am running Python code to extract Roll, Pitch, and Yaw from a Microstrain 3DM-GX5-AHRS and store the data with timestamps. However, running this code consumes more than 90% of the CPU. How can I optimize and reduce the CPU utilization?
my system details.
Operating System: Ubuntu Mint 20.04
Software: Python 3
Hardware: Intel Atom Dual Core Processor SBC
RAM: 8 GB
Storage: 64 GB SSD
optimised_v2.txt

@jagan-pm jagan-pm changed the title CPU utilisation very high CPU utilisation is very high Jun 26, 2024
@msclissa
Copy link
Member

msclissa commented Jul 1, 2024

Have you done any profiling to figure out what is causing the utilization to run high? Would you mind replacing node.getDataPackets() and the subsequent loop with

# look at how many packets node.getDataPackets() usually returns, probably averaged over a couple iterations
EXPECTED_PACKETS = 1

for i in range(EXPECTED_PACKETS):
    data_points.append(["0.0", "0.0", "0.0"])

Also, remove

node = DisplacementNode(connection)

to prevent continuous data collection and buffering.

Is CPU utilization still high when MSCL is removed from the equation?
Leaving the CSV open and just writing to it every loop instead of re-opening it every loop might also help?

A quick aside, I would recommend using InertialNode instead of DisplacementNode - it won't make a difference in this scenario because they use the same parser and getDataPackets() function, but InertialNode will have all the command interface functions your device supports.

@jagan-pm
Copy link
Author

jagan-pm commented Jul 2, 2024

Thank you for your response and guidelines. However, the problem still persists. I have edited the code as per your suggestions and provided the updated code below. Additionally, I checked the CPU utilization using 'htop' in a Linux environment. Here are the results of the CPU utilization before and during the execution is provided here
HBK_RPY_CSV.txt
Before_exicution
During_Exicution

@jagan-pm
Copy link
Author

jagan-pm commented Jul 24, 2024 via email

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