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

Use faster-fifo for queues & more performance improvements #99

Merged
merged 31 commits into from
Jan 8, 2025

Conversation

harshil21
Copy link
Member

@harshil21 harshil21 commented Nov 21, 2024

Switches to the faster-fifo library to bring about massive performance improvements to the mock sim and to the pi, even in real time.

Also optimizes logger buffer logic a little bit and a bunch of small things to improve performance.

  • Get things working
  • Windows support?

Part of #85.

@harshil21 harshil21 added the enhancement New feature or request label Nov 21, 2024
@harshil21
Copy link
Member Author

Tested this on the Pi extensively today. It works very well with no practical downsides. We no longer get any "spikes" in fetched packets. Actual queue size is also <2 when run in real time.

@harshil21
Copy link
Member Author

@JacksonElia how badly do you want Windows support? I think it's trivial to keep windows support but it might hurt readability just a little bit

@harshil21 harshil21 marked this pull request as ready for review November 22, 2024 04:53
@harshil21 harshil21 mentioned this pull request Nov 22, 2024
4 tasks
@JacksonElia
Copy link
Member

probably at the top of the files that use the queues we have an if statement that checks which os you're on, and depending on that imports the queue that we want with a common alias

@harshil21
Copy link
Member Author

probably at the top of the files that use the queues we have an if statement that checks which os you're on, and depending on that imports the queue that we want with a common alias

Yes that's what I was thinking. So you do want Windows support?

@JacksonElia
Copy link
Member

Yeah, when doing development it is so important/crucial to be able to run the mock

@harshil21
Copy link
Member Author

Alright just added Windows support. @JacksonElia can you confirm if it works?

Need to test this one last time on the pi before merging.

Provides about ~60% speedup, from 8.5us to 5.4us
Improves performance by about ~9%, 142k ns -> 129k ns
Default dtype is np.float64 anyway. About ~20-25% speedup
… deque

It's an improvement because we don't have to convert the deque to a list when sending it to the apogee prediction process. Saves about 0.14s (100k iterations)
@harshil21 harshil21 changed the title Use faster-fifo for queues Use faster-fifo for queues & more performance improvements Dec 7, 2024
airbrakes/airbrakes.py Show resolved Hide resolved
airbrakes/airbrakes.py Show resolved Hide resolved
airbrakes/data_handling/apogee_predictor.py Show resolved Hide resolved
airbrakes/data_handling/data_processor.py Show resolved Hide resolved
airbrakes/data_handling/data_processor.py Outdated Show resolved Hide resolved
airbrakes/data_handling/logger.py Outdated Show resolved Hide resolved
airbrakes/data_handling/logger.py Outdated Show resolved Hide resolved
airbrakes/hardware/imu.py Outdated Show resolved Hide resolved
airbrakes/mock/mock_imu.py Show resolved Hide resolved
constants.py Outdated Show resolved Hide resolved
airbrakes/hardware/imu.py Outdated Show resolved Hide resolved
@harshil21
Copy link
Member Author

Latest commit adds a couple of tests which I believe are robust enough that I don't need to test this PR on the Pi before merging.

If one of you can confirm that this works on Windows within 24 hours, I can merge (still need an approving review). Otherwise, I have a Windows machine nearby I can quickly test on.

@harshil21 harshil21 mentioned this pull request Jan 1, 2025
@harshil21
Copy link
Member Author

Alright I was able to test and fix the Windows runtime myself. Also added the integration test for Windows here in the CI. Getting the unit tests to work on Windows is not worth it imo. Windows is going to be a 2nd class citizen as long as we're using multiprocessing.

Copy link
Contributor

@wlsanderson wlsanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked over everything. Code runs on my system, and you said you tested on the Pi. Tests look good too. I added that one comment for the imu test but seems fine to merge. Maybe an issue for another time, but I feel like it might be less repetitive to handle a lot of the if/else sys.platform checks in a utils function that can create all of the multiprocessing queues and related things itself. Not a big concern for the moment though, this is already a lot lmao

tests/test_imu.py Outdated Show resolved Hide resolved
@wlsanderson
Copy link
Contributor

oh yeah I guess that unit test needs to be fixed. idk why thats failing though

@harshil21 harshil21 merged commit d54a995 into main Jan 8, 2025
3 of 4 checks passed
@harshil21 harshil21 deleted the adjust-queue-fetching branch January 8, 2025 22:25
harshil21 added a commit that referenced this pull request Jan 13, 2025
There would've been an exception in the apogee prediction and logger process after 100 seconds of just sitting on the pad. This was an oversight from #99. Tests have been added to detect this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants