Skip to content

Conversation

@acassis
Copy link
Contributor

@acassis acassis commented Dec 16, 2025

Summary

During the discussion about the impact of adding counter to TCB Mr anchao created a pthread mutex performance example: apache/nuttx#17468 (comment)

Because this example can exercise (not ideally) the pthread mutex I decided to add it to apps/testing/sched, the program name will be called "pmutexp" (because "pmp" is not a good name).

Impact

Another testing tool for NuttX

Testing

nsh> pmutexp
1: diff = 0.278248977 s | avg = 0.278248977 s
2: diff = 0.277865395 s | avg = 0.278057186 s
3: diff = 0.276913045 s | avg = 0.277675805 s
4: diff = 0.277897198 s | avg = 0.277731153 s
5: diff = 0.278829989 s | avg = 0.277950920 s
6: diff = 0.276655238 s | avg = 0.277734973 s
7: diff = 0.278417236 s | avg = 0.277832439 s
8: diff = 0.276738257 s | avg = 0.277695666 s
9: diff = 0.278345268 s | avg = 0.277767844 s
10: diff = 0.279812201 s | avg = 0.277972280 s

===== result =====
count: 10
total: 2.779722804 s
avg: 0.277972280 s
nsh>

During the discussion about the impact of adding counter to TCB
Mr anchao created a pthread mutex performance example:
apache/nuttx#17468 (comment)

Because this example can exercise (not ideally) the pthread mutex
I decided to add it to apps/testing/sched, the program name will
be called "pmutexp" (because "pmp" is not a good name).

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

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

Thank you @acassis and @anchao :-)

Can we add some documentation to explain what this standalone tool does and what the results mean - for instance this tool can be used to measure performance of different implementations of mutex in the RTOS, and impact of changes in the mutex related code, the numbers mean ... and the smaller the better :-)

Copy link
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I agree it needs docs too!

@acassis
Copy link
Contributor Author

acassis commented Dec 16, 2025

@cederom @linguini1 yes I will submit a Documentation/, basically it just try to get (lock) a mutex inside a busy-waiting loop and calculated the elapsed total and average time. This is a simple test for benchmarking specific use case, not a broader/real pthread mutex tester or profiler. There are other tests to mutex on ostest, but I think this is a simple test for validate impact in the kernel, like the TCB counter.

@cederom
Copy link
Contributor

cederom commented Dec 16, 2025

Maybe benchmarks would be better category then? :-)

@acassis acassis merged commit 8cb7dd0 into apache:master Dec 16, 2025
40 checks passed
@acassis
Copy link
Contributor Author

acassis commented Dec 17, 2025

Maybe benchmarks would be better category then? :-)

I thought it initially, but since it it more related to kernel scheduling performance I opted to add it to testing/sched

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants