Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

uv_link_t: initial #32

Closed
wants to merge 7 commits into from
Closed

Conversation

indutny
Copy link
Member

@indutny indutny commented Jun 3, 2016

cc @nodejs/ctc @trevnorris @nodejs/collaborators @saghul

@eljefedelrodeodeljefe
Copy link

As far as I can see, this would tremendously help native addons writers also, since StreamBase is indeed very bulky. Decreasing boilerplate one has to implement to hook in C programs into js-streams is definitely worth an addition like this. Awesome work, btw.

@Qard
Copy link
Member

Qard commented Jun 3, 2016

Indeed, this looks great! The more we can leverage libuv to do the heavy lifting generically, the better. 😸


The fast HTTP and TLS protocol implementation in Node core depends on so called
`StreamBase` C++ class. This class is an analog of JavaScript streams in C++.
The main ideas behind `StreamBase` is to:

Choose a reason for hiding this comment

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

nit: are to

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.

@jasnell
Copy link
Member

jasnell commented Jun 3, 2016

oooo... yes please. this definitely looks promising.

## 1. Proposal

I propose to replace `StreamBase` with [`uv_link_t`][0], and port existing
classes that inherit from `StreamBase`.
Copy link
Contributor

Choose a reason for hiding this comment

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

We had a conflict in StreamBase that lead to the method GetAsyncWrap() and GetObject(). Will this play nicely with AsyncWrap, and allow the class to propagate like it does with JSStream?

Copy link
Member Author

Choose a reason for hiding this comment

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

The conflict was due to the use of vtable and virtual methods in StreamBase. uv_link_t is a C project, there won't be any such conflict.

In fact, I believe that exposing an External getter for the pointer to internal uv_link_t is enough to get things running. This getter can be a per-class, or could be shared, but the inheritance won't be a roadblock for this.

@indutny
Copy link
Member Author

indutny commented Jun 3, 2016

Added note about observability and data events. This is very important too.


Given that [`uv_link_t`][0] depends only on [libuv][1], it is very easy to
envision how it will be used in Node.js addons. Even core modules will no longer
be required to be distributed with core, since they could be built without core
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a hint of a concern that people will take this as meaning core modules will be distributed without core. Possibly change the wording to simply say that it'd be easier to write alternative implementations of core modules (e.g. alternative http implementations). Only suggest this to keep the proposal closer to core today (as an easier way for this EP to get accepted).

note: i'm not suggesting that i wouldn't like to distribute the core modules separately in the future. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack, PTAL.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I'm wondering about the idea of prototyping this in userland, since uv_link_t, uv_http_t, and uv_ssl_t are all fully separate from libuv itself currently. Can we make totally separate modules for those three parts and have them interact cleanly? That'd be a great proof of modularity. It could be very interesting to see lots of little uv extensions like this exposed as userland modules, a uv_websocket_t link comes to mind. 😸

Copy link
Member Author

Choose a reason for hiding this comment

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

This sounds lovely, @Qard . Though, we will still need to have access to the uv_stream_t which is currently hidden in core.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could add an internal/undocumented function somewhere to return a v8::External containing the uv_stream_t to experiment with the idea?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Qard do you think this should be a part of this proposal?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure yet. It's more just an idea in my head at this point.

It might make acceptance of this EPS a little smoother though. We could just start with a single hidden function and iterate in userland for a bit. It'd provide the opportunity to develop a more practical understanding of the potential implementation than just bikeshedding a bunch in here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @indutny. This is an idea that has a lot of potential and lots of ways we can be extended. Think it will be good to be strict about not allowing these things to creep so the initial implementation can land. At that point I think it'll be much easier to begin prototyping new ways of doing things.

@trevnorris
Copy link
Contributor

Overall I dig it. Would like @bnoordhuis' opinion.

@indutny
Copy link
Member Author

indutny commented Jun 3, 2016

@trevnorris thank you!

envision how it will be used in Node.js addons. Even core modules will no longer
be required to be distributed with core, since they could be built without core
dependencies.
envision how it will be used in Node.js addons. Even core modules will could
Copy link
Contributor

Choose a reason for hiding this comment

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

"will could" -> "could". Other than that minor thing, reads great. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.

@indutny
Copy link
Member Author

indutny commented Jun 4, 2016

Thank you for review @trevnorris !


`uv_link_t` aims to solve complexity problem that quickly escalates once
using multiple layers of protocols in [libuv][1] by providing a way to
implement protocols separately and chain them together in easy and
Copy link
Member

Choose a reason for hiding this comment

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

"in an easy and..."

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack.

@bnoordhuis
Copy link
Member

The document should provide some detail on how uv_link_t is supposed to work. It currently just, ah, links to https://github.com/indutny/uv_link_t without further explanation.

@indutny
Copy link
Member Author

indutny commented Jun 6, 2016

@bnoordhuis I can copy-paste "How?" from https://github.com/indutny/uv_link_t#how , will it suffice?

@bnoordhuis
Copy link
Member

Yes, but it should probably also say a few words about how it's going to be hooked up in node.js.

@indutny
Copy link
Member Author

indutny commented Jun 16, 2016

@bnoordhuis sorry for delay, pushed update.

@indutny
Copy link
Member Author

indutny commented Sep 14, 2016

Should I land this? Its been awhile since the last review, and I believe that there is a general agreement about this feature.

@Trott
Copy link
Member

Trott commented Sep 14, 2016

Should I land this?

Since it says status is DRAFT, and the README says all EPs regardless of status should be landed...I'd say yes. Landing it as DRAFT status especially should be uncontroversial.

@indutny
Copy link
Member Author

indutny commented Sep 14, 2016

Alright, landing!

indutny added a commit that referenced this pull request Sep 14, 2016
@indutny
Copy link
Member Author

indutny commented Sep 14, 2016

Landed in 2c45bf0, thank you!

@indutny indutny closed this Sep 14, 2016
@indutny indutny deleted the feature/uv_link_t branch September 14, 2016 20:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants