Skip to content

RFC: Optimized heap queue implementation for uasyncio #2219

Closed

Description

@pfalcon

Switch uasyncio to wrap-around time source like utime.ticks_ms(), as required for baremetal ports, requires changing to the comparison done in uheapq module - it should use partial ordering definable for modular arithmetic (ring math object). So, that requires changing uheapq anyway, and I currently have adhoc changes for that coded.

Besides this must-have feature, there're also change to optimize:

  1. Pre-allocate queue of some size.
  2. Avoid constant packing and unpacking of tuples as done now.

So, that actually calls for introduction of adhoc heap queue class implementation for uasyncio. The main question is how to implement it - I consider turning current moduheapq.c into header with poor-man's templating implementation to teach it working with different data structures. Any objections?

After this changes, there will be (in a common case) the only remaining source of memory traffic for uasyncio usage - constant generator creation from yield from.

Activity

  1. pfalcon commented on Jul 3, 2016

    @pfalcon
    ContributorAuthor

    and I currently have adhoc changes for that coded.

    For reference: pfalcon/pycopy@75de07a

  2. pfalcon commented on Nov 10, 2016

    @pfalcon
    ContributorAuthor

    @dpgeorge : So, considering current situation and backlog, I'd rather proceed with step by step changes, and merge change in the previous comment largely as is (after required clean up of course). This will allow to switch unix implementation and test it well, and uasyncio.core (I/O-less) can be used on esp8266 for testing too. Let me know if there're any objections.

  3. dpgeorge commented on Nov 11, 2016

    @dpgeorge
    Member

    I'd rather proceed with step by step changes, and merge change in the previous comment largely as is (after required clean up of course).

    From inspection of that patch it seems that it adds extra args to existing heapq methods, and so retains backwards compatibility. If so then +1 to merge.

  4. pfalcon commented on Nov 11, 2016

    @pfalcon
    ContributorAuthor

    @dpgeorge : Yes, sure, backwards compatibility is retained. The only concern is that later it may need to changed again, then again, and again. But as it involves many moving parts, we'd better really do it like that, step by step, without trying to arrive at a final destination right away. So, some churn would be expected.

  5. pfalcon commented on Nov 11, 2016

    @pfalcon
    ContributorAuthor

    Refactored and merged as 0cbc072.

  6. added a commit that references this issue on Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions