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

Always inline fastPinGetPinmap to speed pin sets #2251

Merged

Conversation

tstellanova
Copy link
Contributor

@tstellanova tstellanova commented Dec 9, 2020

Always inline fastPinGetPinmap in order to speed pin set

Also add test to catch unintentional slowing of pin set in the future.

Problem

For some users, calling pinSetFast or pinResetFast was noticeably slower on 2.0.0-rc.4 or later than on earlier releases.

Solution

The 2.0.0 development line worked around an issue with initialization order by changing the way the HAL pin map was initialized and subsequently accessed. This introduced some overhead in each call to fastPinGetPinmap. We reduce that overhead here by always inlining fastPinGetPinmap().

References

  • Closes #2244

Steps to Test

Added a test to /user/tests/wiring/no_fixture/fastpin.cpp to set a limit to the allowable ticks. Tested on Electron 2g.

Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

user/tests/wiring/no_fixture/fastpin.cpp Outdated Show resolved Hide resolved
wiring/inc/fast_pin.h Outdated Show resolved Hide resolved
user/tests/wiring/no_fixture/fastpin.cpp Show resolved Hide resolved
Use separate pinSetFast benchmark for Gen3

Separate timing benchmarks for pinSet and pinReset
@tstellanova tstellanova force-pushed the bug/ch68808/low-level-input-output-slow-on-os-2-0-0-rc4 branch from 4c419c6 to 09c59f1 Compare December 9, 2020 17:14
@avtolstoy avtolstoy added this to the 2.0.1 milestone Dec 9, 2020
@avtolstoy avtolstoy merged commit fca6e98 into develop Dec 9, 2020
@avtolstoy avtolstoy deleted the bug/ch68808/low-level-input-output-slow-on-os-2-0-0-rc4 branch December 9, 2020 19:21
@avtolstoy
Copy link
Member

Some of the timing constraints are too tight on some Gen 3 platforms:

        Assertion failed: (duration=6236) <= (NUM_ITERATIONS*MAX_DURATION_PINRESET_TICKS=6000), file tests/integration/wiring/no_fixture/fastpin.cpp, line 64.

        2) FASTPIN_02_MaxDuration_PinReset

I'll relax them a bit in develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants