Skip to content

cache board model during initialization #196

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

Closed
pdp7 opened this issue Nov 17, 2017 · 1 comment
Closed

cache board model during initialization #196

pdp7 opened this issue Nov 17, 2017 · 1 comment
Assignees

Comments

@pdp7
Copy link
Collaborator

pdp7 commented Nov 17, 2017

While investigating #190, I realized it is very inefficient to check for board type inside gpio_set_value():
https://github.com./adafruit/adafruit-beaglebone-io-python/blob/master/source/event_gpio.c#L405

The function beaglebone_blue() executes popen() to run grep:
https://github.com./adafruit/adafruit-beaglebone-io-python/blob/master/source/common.c#L602

This should be cached so that it only needs to be done once when Adafruit_BBIO is initialized.

@pdp7 pdp7 self-assigned this Nov 17, 2017
@pdp7 pdp7 changed the title cache board module during initialization cache board model during initialization Nov 17, 2017
pdp7 added a commit that referenced this issue Nov 19, 2017
cache board type to avoid poor performance
in functions that are called frequently like
gpio_set_value() in source/event_gpio.c

Signed-off-by: Drew Fustini <[email protected]>
@pdp7
Copy link
Collaborator Author

pdp7 commented Nov 19, 2017

Timing test shows large performance improvement after commit 3281479

debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ python3 ~/time-test.py 
time to complete 100 sets =  0.006628266011830419

debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ python ~/time-test.py 
('time to complete 100 sets = ', 0.0067021846771240234)

Results before commit 3281479 with performance regression:

debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ python ~/time-test.py 
('time to complete 100 sets = ', 1.5183091163635254)

debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ python3 ~/time-test.py 
time to complete 100 sets =  1.3909540939785074

time-test.py

import Adafruit_BBIO.GPIO as GPIO
import timeit

pin = 'P9_14'

GPIO.setup(pin, GPIO.OUT)

def setoutput():
  for x in range(1, 10):
    GPIO.output(pin, True)
    GPIO.output(pin, False)
    #run 5 times, 10 x 2 x 5 = 100 outputs

result = timeit.Timer(setoutput).timeit(5)
print('time to complete 100 sets = ', result)
GPIO.cleanup()

/opt/scripts/tools/version.sh

git:/opt/scripts/:[6c2688b0be448b7bb9ca18849b430d496a84acb4]
eeprom:[A335BNLT000C3014BBBK1316]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2017-10-17]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2017.09-00002-g0f3f1c7907]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.09-rc2-00002-g84a7f2]
kernel:[4.14.0-rc7-ti-r6]
nodejs:[v6.11.5]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg:[bb-cape-overlays]:[4.4.20171027.1-0rcnee1~stretch+20171027]
pkg:[bb-wl18xx-firmware]:[1.20170829-0rcnee1~stretch+20170829]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee0~stretch+20170830]

@pdp7 pdp7 closed this as completed Nov 19, 2017
pdp7 added a commit that referenced this issue Nov 19, 2017
Release 1.0.8:
==============
Fixes:
  Issue #196: cache board type to avoid poor performance
  Issue #192: fix PocketBeagle PWM pin typo
  Issue #191: turn off RotaryEncoder's debug output by default
  Issue #188: GPIO is extremely slow (20ms to toggle)
  Issue #186: problems with UART

shortlog:

David Planella (12):
  Copy Encoder module comments to README.md
  Formatted Encoder README in markdown
  Fixed Encoder README formatting
  Removed QEP instructions from Encoder module
  Fixes to Encoder README
  Updated Encoder README
  Encoder README: added info on dedicated overlays
  Encoder README: updated info on pre-requisites
  Encoder README update
  Encoder README update
  Add logging support, turn off unconditional debug output
  Encoder: remove unused logging code

Drew Fustini (3):
  Merge pull request #195 from dplanella/master
  Fix PocketBeagle PWM pin typo (#192)
  cache board type to avoid poor performance (#196)

Signed-off-by: Drew Fustini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant