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

Improve VIRTSER performance #7528

Merged
merged 1 commit into from
Jan 31, 2020
Merged

Improve VIRTSER performance #7528

merged 1 commit into from
Jan 31, 2020

Conversation

xyzz
Copy link
Contributor

@xyzz xyzz commented Dec 2, 2019

Description

Improve performance of virtser. Currently it consumes 1 byte at a time, which took for me over 30ms when sending 49 bytes. With a simple change, it can send 10x that in 30ms.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@drashna
Copy link
Member

drashna commented Dec 2, 2019

This does affect steno, as it uses VIRTSER.

Are you using this with Steno? Eg, has it been tested and verified that it doesn't break the steno implementation?

@xyzz
Copy link
Contributor Author

xyzz commented Dec 2, 2019

No, I'm using it with a custom virtser_recv handler. I cannot check steno since I don't have the hardware. However, the chibios implementation of virtser does call it in a loop here:

virtser_recv(buffer[i]);

@yanfali
Copy link
Contributor

yanfali commented Dec 3, 2019

@germ can you verify this PR does not break steno, this would affect your boards more than others.

@germ
Copy link
Contributor

germ commented Dec 3, 2019

I can test in about a week or so, I'm out of the country and didn't bring a laptop with me. I'll dump it in the Plover discord and see if someone can verify nothing breaks.

@drashna
Copy link
Member

drashna commented Dec 4, 2019

Awesome, thanks, @germ.

@yanfali
Copy link
Contributor

yanfali commented Dec 4, 2019

I can test in about a week or so, I'm out of the country and didn't bring a laptop with me. I'll dump it in the Plover discord and see if someone can verify nothing breaks.

Wait, they let you out of Canada?

@germ
Copy link
Contributor

germ commented Dec 4, 2019

Hey! I'm not Australian or anything, don't get us confused :P

@antoniusf
Copy link

Hey! 👋 (I'm from the plover discord)

I just tested this with the georgi's default firmware, and everything seemed to work okay. I should say that I don't normally use a virtser-based protocol for steno, but I checked the behavior of this PR against master and didn't find any differences. As far as I know, the georgi uses the Gemini protocol, which means that TX Bolt is still untested, so if you want, I could try that as well. (On the other hand, the steno implementation doesn't even seem to use virtser_recv, only virtser_send, so it's probably fine anyway?)

@drashna drashna requested a review from a team January 13, 2020 19:39
Copy link
Member

@tzarc tzarc left a comment

Choose a reason for hiding this comment

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

Looks okay to me, ChibiOS's implementation does something similar already.
There's no CDC_Device_ReceiveByte equivalent for a buffer in LUFA, so normalising the implementations to match the ChibiOS one isn't really possible. Seems like this is as close as we're going to get.

@@ -869,7 +869,7 @@ void virtser_recv(uint8_t c) {
void virtser_task(void) {
uint16_t count = CDC_Device_BytesReceived(&cdc_device);
uint8_t ch;
if (count) {
for (; count; --count) {
ch = CDC_Device_ReceiveByte(&cdc_device);
Copy link
Member

@fauxpark fauxpark Jan 31, 2020

Choose a reason for hiding this comment

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

Hm, possibly a small bug here: the return type of CDC_Device_ReceiveByte() is int16 and will return -1 if no data was received.
https://www.fourwalledcubicle.com/files/LUFA/Doc/170418/html/group___group___u_s_b_class_c_d_c_device.html#gaf02a74dffdcde55f4e522989e2ed49c1

It's probably fine, due to the for loop on count - when 0, ReceiveByte() will not be called.

@fauxpark fauxpark merged commit eb309be into qmk:master Jan 31, 2020
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Feb 12, 2020
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Feb 14, 2020
HokieGeek pushed a commit to HokieGeek/qmk_firmware that referenced this pull request Feb 21, 2020
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Feb 26, 2020
c0psrul3 pushed a commit to c0psrul3/qmk_firmware that referenced this pull request Mar 23, 2020
kylekuj pushed a commit to kylekuj/qmk_firmware that referenced this pull request Apr 21, 2020
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
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.

9 participants