Skip to content
This repository was archived by the owner on May 18, 2022. It is now read-only.

Use bbqueue from crates.io #71

Closed
jonas-schievink opened this issue Aug 9, 2019 · 8 comments
Closed

Use bbqueue from crates.io #71

jonas-schievink opened this issue Aug 9, 2019 · 8 comments
Labels
status: blocked Blocked on other work (either another issue in this repo, or work in another repo) type: bug Something isn't behaving as intended

Comments

@jonas-schievink
Copy link
Owner

jonas-schievink commented Aug 9, 2019

As discovered in #64, bbqueue's grant_max doesn't work as documented (jamesmunns/bbqueue#29), so our usage of it is wrong and can lead to packet processing stalling.

This either needs a documentation fix and additional methods in bbqueue, or we should switch to a different queue. Ideally, that queue would also support thumbv6 while still having efficient batch operations.

@jonas-schievink jonas-schievink added type: bug Something isn't behaving as intended status: blocked Blocked on other work (either another issue in this repo, or work in another repo) labels Aug 9, 2019
jonas-schievink added a commit that referenced this issue Aug 30, 2019
Works around the issues in #71
@jonas-schievink
Copy link
Owner Author

8b62569 uses a fork that includes jamesmunns/bbqueue#33. We should move back to the upstream repo or a crates.io release as soon as we can.

@jonas-schievink jonas-schievink changed the title bbqueue is used incorrectly Use bbqueue from crates.io Aug 30, 2019
@jamesmunns
Copy link

@jonas-schievink is this something that would be fixed by jamesmunns/bbqueue#37?

Or do you need one of the proposed grants at jamesmunns/bbqueue#38, maybe grant_largest or grant_largest_max?

@jonas-schievink
Copy link
Owner Author

@jamesmunns Does grant_max_remaining now work as documented? If so then that's all I need.

@jamesmunns
Copy link

jamesmunns commented Nov 29, 2019

Ah no, good catch! It works as documented at the module level (see https://docs.rs/bbqueue/0.4.0-alpha5/bbqueue/atomic/struct.Producer.html), but it is a little vague at the function level, which I will be fixing. For reference:

  • grant_max_remaining(N):
    • User will receive a grant 0 < sz <= N (or receive an error)
    • This will only cause a wrap to the beginning of the ring if exactly
      zero bytes are available at the end of the ring.
    • Maximum possible waste due to skipping: 0 bytes

I think you actually want grant_largest_max(), which will cause a wraparound if the requested space is NOT available at the end, but IS available at the beginning.

@jamesmunns
Copy link

I need to come up with a consistent naming scheme, but in general:

  • remaining methods do NOT cause premature wraps
  • largest methods MAY cause premature wraps
  • max methods limit the upper bound of grantable size

@jonas-schievink
Copy link
Owner Author

I think you actually want grant_largest_max(), which will cause a wraparound if the requested space is NOT available at the end, but IS available at the beginning.

The only remaining use of bbqueue is in the logging utilities, which should be fine with getting a small buffer first, and then wrap around and get another buffer. It will only "fail" (it will consider data to be lost) if the function returns Err.

@jamesmunns
Copy link

I also plan to offer split grants in the future, which will give you the buf at the start and end, so you can decide at once if there is enough space, but I haven't put any detailed design or dev into that, planning on doing that post 0.4.0.

@jonas-schievink
Copy link
Owner Author

Fixed by #100

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: blocked Blocked on other work (either another issue in this repo, or work in another repo) type: bug Something isn't behaving as intended
Projects
None yet
Development

No branches or pull requests

2 participants