Skip to content

unix/moduselect: Implement ipoll() method with no-allocation policy. - #2841

Closed
pfalcon wants to merge 1 commit into
micropython:masterfrom
pfalcon:ipoll
Closed

pfalcon wants to merge 1 commit into
micropython:masterfrom
pfalcon:ipoll

Conversation

@pfalcon

@pfalcon pfalcon commented Feb 6, 2017

Copy link
Copy Markdown
Contributor

ipoll() allows to poll streams without allocating any memory: this method
returns an iterator (a poll object itself), and the iterator yields
preallocated "callee-owned tuple" with polling results for each active
stream. The only operation a caller is allowed to do with this tuple is
extracting values from it (storing the tuple as a whole somewhere is
not allowed).

ipoll() allows to poll streams without allocating any memory: this method
returns an iterator (a poll object itself), and the iterator yields
preallocated "callee-owned tuple" with polling results for each active
stream. The only operation a caller is allowed to do with this tuple is
extracting values from it (storing the tuple as a whole somewhere is
not allowed).
@pfalcon

pfalcon commented Feb 6, 2017

Copy link
Copy Markdown
Contributor Author

Implementation of #1550 (comment) . Not fully tested.

@dpgeorge dpgeorge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks ok.

But what's the plan with implementing it for baremetal in extmod/moduselect? Will this unix version serve as a reference and then the extmod version can follow, or will they eventually be merged into 1 implementation?

Comment thread unix/moduselect.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could be inlined here (ie mp_obj_tuple_t) to reduce fragmentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was bit by inlining once, so don't feel like practicing it again. Here's it's also an "optimization", if ipoll is not used, tuple is not allocated. And overall, before playing with inlining and stuff, and I'd like to see a compacting GC implemented, that would require tightening up object refs vs object ptrs matters in many places, no need to complicate it more with adhoc optimizations IMHO.

@pfalcon

pfalcon commented Feb 7, 2017

Copy link
Copy Markdown
Contributor Author

But what's the plan with implementing it for baremetal in extmod/moduselect? Will this unix version serve as a reference and then the extmod version can follow, or will they eventually be merged into 1 implementation?

Yes, extmod/moduselect will follow once this is well tested. As discussed previously, they use very different mechanism underlyingly, so I don't see a way to factor out anything (well, much enough to bother) common from them.

@pfalcon

pfalcon commented Feb 7, 2017

Copy link
Copy Markdown
Contributor Author

Also, once moduselect's are updated, uasyncio will need to be updated, which will make it incompatible with the current uPy release. So, we'd need to make a new release, and probably can start planning it.

@dpgeorge

dpgeorge commented Feb 7, 2017

Copy link
Copy Markdown
Member

Ok. Feel free to merge when it's ready.

@pfalcon

pfalcon commented Feb 12, 2017

Copy link
Copy Markdown
Contributor Author

Merged.

xobs pushed a commit to xobs/micropython that referenced this pull request May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants