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

Add performance test for handle.py / BinaryValue #3413

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aubindetrez
Copy link

These tests are measuring how long it takes to read signals, read one specific bit, write signals in cocotb.

This is part of the "Replace BinaryValue with LogicArray" effort #3244, these tests will help us better compare different implementations and their pros/cons.

Example of output:

100025000.00ns INFO     cocotb.dff8                        Little Endian, setting input signal: 3.1270687309988716s
200035000.00ns INFO     cocotb.dff8                        Big Endian, setting input signal: 3.1491839480004273s
300045000.00ns INFO     cocotb.dff8                        Little Endian, reading the output signal: 2.52074205900135
400055000.00ns INFO     cocotb.dff8                        Big Endian, reading the output signal: 2.66596318899974
500065000.00ns INFO     cocotb.dff8                        Little Endian, reading part of the output signal: 2.780234088000725
600075000.00ns INFO     cocotb.dff8                        Big Endian Endian, reading part of the output sign: 2.776298863000193
700085000.00ns INFO     cocotb.dff8                        Little Endian, reading single bit from the output signal: 2.6840617939997173
800095000.00ns INFO     cocotb.dff8                        Big Endian, reading single bit from the output signal: 2.7572237929998664
800115000.00ns INFO     cocotb.dff8                        Little Endian, setting part of the input signal: Unsupported
800125000.00ns INFO     cocotb.dff8                        Big Endian, setting part of the input signal: Unsupported
900125000.00ns INFO     cocotb.dff8                        Little Endian, setting single bit of the input signal: 3.229350190000332
1000135000.00ns INFO     cocotb.dff8                       Big Endian, setting single bit of the input signal: 3.3048068640000565
1100155000.00ns INFO     cocotb.dff8                       Little Endian, read + write signals: 3.469675129999814
1200175000.00ns INFO     cocotb.dff8                       Big Endian, read + write signals: 3.5726902460010024

This test let us compare different implementation of handle.py, like using BinaryValue vs LogicArray
@aubindetrez aubindetrez changed the title Add Performance test for handle.py / BinaryValue Add performance test for handle.py / BinaryValue Sep 16, 2023
@ktbarrett
Copy link
Member

It's probably easier to gather performance metrics using pytest-benchmark and the test_binary_value.py in the pytest directory.

@aubindetrez
Copy link
Author

The benchmark introduced by this PR is meant to be implementation independent.
test_binary_value.py only tests BinaryValue, however I would like an end-to-end test that does not depend on any specific implementation.
I would use it to check how different implementations of LogicArray perform as a replacement for BinaryValue.

What alternative do we have (that would ideally not require a simulator to run)?
I considered a pytest for handle.py, but how much of handle.py require a simulator to run anyway?

@marlonjames marlonjames added the category:performance performance topics label Oct 12, 2023
@themperek
Copy link
Contributor

Example benchmark code is here: https://github.com/cocotb/cocotb/blob/master/tests/benchmark.py
It is running in CI: https://github.com/cocotb/cocotb/actions/workflows/benchmark.yml

It needs fixing (authentication settings) to actually export and make plots.

@aubindetrez
Copy link
Author

aubindetrez commented Oct 28, 2023

Thanks, I have already been using this matrix multiplier benchmark for my BinaryValue vs LogicArray comparison.

But I would also need to benchmark other aspects of the BinaryValue/LogicArray API, like what if a signal contains X or Z, or if we only access a few bits?
Dedicated benchmarks would be very helpful to compare different implementations and optimization as we are doing refactoring...

@themperek
Copy link
Contributor

But I would also need to benchmark other aspects of the BinaryValue/LogicArray API, like what if a signal contains X or Z, or if we only access a few bits?

Feel free to add.

I will try to figure out how to get plotting/authentication working.

@themperek
Copy link
Contributor

@aubindetrez https://cocotb.github.io/cocotb-benchmark-results/dev/bench/

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

Successfully merging this pull request may close these issues.

None yet

4 participants