nodejs / abi-stable-node

Repository used by the Node-API team to manage work related to Node-API and node-addon-api
239 stars 47 forks source link

Workshop #367

Closed NickNaso closed 4 years ago

NickNaso commented 5 years ago

Hi everyone I'm opening this issue with the intention to collect materials and idea for a N-API workshop that we can propose at NodeConf EU, Node Summit and Node+JS Interactive.

Below I report all materials that we have from the workshop that we did last year:

List of candidate modules to port available at goo.gl/9bksyw

jschlight commented 5 years ago

Title

Next Generation N-API: A hands-on workshop

Description

The world of Node native add-on development continues to rapidly evolve. After widespread adoption of N-API starting last year, the Node native add-on ecosystem is gaining momentum as the underlying technology and tools continue to advance.

This workshop, offered by experts from the N-API team, describes important new features essential to the performance of your native add-on. These new features include asynchronous operations which permit you to safely and reliably spread your work across multiple threads. Context awareness permits your add-on to be loaded multiple times without the multiple copies interfering with each other. Finally, adopting thread-safe functions insures your functions run reliably regardless of the thread from which they are called or in which they run.

Whether you are just starting out with native add-ons or are an old pro looking for an update on N-API, bring your project or work through the workshop tutorials under the helpful guidance of the N-API experts. You’ll leave this workshop with a solid understanding of these important new technologies and how they apply to your own projects. And perhaps, with a bit of luck, working code!

New Tutorials

NickNaso commented 5 years ago

Maybe I prefer talking of asynchronous operations instead of AsyncWorker, because the AsyncWorker is not the only way to do this kind of task.

jschlight commented 5 years ago

Good point, @NickNaso. I've updated the Proposed Abstract comment.

mhdawson commented 5 years ago

So that we don't scare off people just starting out maybe add something like

Wether you just want to start out with native addons or are an old pro looking for an update on N-API, bring your project or work through ....

Otherwise looks great to me.

jschlight commented 5 years ago

2019 Conferences

jschlight commented 5 years ago

I've updated the comment above to reflect the responses we've received from the conference organizers.

mhdawson commented 5 years ago

Node+JS Interactive - Workshop was accepted ! NodeConfEU - Declined.

Jim will start working on the new ones this week.

NickNaso commented 5 years ago

Hi @jschlight, I post a little example that could be a base for a tutorial of how to use reference to Function or Object ref.zip

jschlight commented 5 years ago

Workshop Promotion

Proposed OpenJS Foundation Release

Are you working on a Node native add-on? Or are you planning to? You should be aware of significant improvements to the N-API infrastructure including asynchronous operations, thread-safe functions, and context awareness. Gabriel Schulhof has a good overview of these improvements here. These topics and more will be covered in the Next Generation N-API Hands-on Workshop being offered by the N-API team at Node+JS Interactive 2019 in Montreal, Canada (December 11-12, 2019). In the meantime, be sure to check out the N-API Resource for the current set of N-API tutorials and best practices.

mhdawson commented 5 years ago

@jschlight sounds good. If you want to tweet that out I can then ask the Node.js account to retweet

mhdawson commented 5 years ago

@jschlight, @gabrielschulhof I notice that the workshop only lists Nicola and myself in the title/speakers. Is that because you've not accepted the speaker role yet? I have other talks so we should make sure you are listed as speakers (even if that means removing me) so that you get the free ticket...

NickNaso commented 5 years ago

I sent the email to the organiser and I left them the email of @jschlight in case they need to ask you your bio and other things.

NickNaso commented 5 years ago

@mhdawson @jschlight Now the workshop lists me and @jschlight .

mhdawson commented 5 years ago

:) @jschlight hope that helps you being able to make it.

mhdawson commented 4 years ago

@NickNaso will create slides for the workshop, starting with those we used the last time.

mhdawson commented 4 years ago

Stuff to cover in intro deck:

Call to join/get involved.

mhdawson commented 4 years ago

@NickNaso will paste in link for new deck, Gabriel to add slide for Context awareness.

juanarbol commented 4 years ago

I have two suggestions while the workshop is happening:

  1. Explain that boilerplate required for running C/C++ code -it's more like and setup, no just boilerplate- (like binding.gyp, bindings package, etc) before jumping into Yeoman, It's good to have a context.

  2. Instead of recommending attatch debugger to see what is happening inside, you could do it and explain a little bit what is going on.

NickNaso commented 4 years ago

Hi everyone, I started working on the slides the work is not complete, but I provide to post the link here: https://docs.google.com/presentation/d/1NNKhULBFOqJspy_VMZKP2W-kJTpw4DGsoOTKOEkKQts I have question that I want to discuss today:

juanarbol commented 4 years ago

@NickNaso I think both are very nice ideas, I think also would be nice to explain binding.gyp file, explain all of that before jumping to Yeoman generator.

jschlight commented 4 years ago

@NickNaso We should keep the information you include for https://github.com/nodejs/abi-stable-node/issues/367#issuecomment-544584301 in sync with https://napi.inspiredware.com/getting-started/first.html#Project-structure which is how the Yeoman generator creates a project.

I can add an introductory part explaining what is a native add-on to this page: https://napi.inspiredware.com/about/what.html#Node

NickNaso commented 4 years ago

@NickNaso We should keep the information you include for #367 (comment) in sync with https://napi.inspiredware.com/getting-started/first.html#Project-structure which is how the Yeoman generator creates a project.

I can add an introductory part explaining what is a native add-on to this page: https://napi.inspiredware.com/about/what.html#Node

I added slide n. 9 where I reported what native add-on is and in slide n. 10 I want explain how the all the things work in high level way. It's a good idea to write something about native add-on on the tutorial.

I will adapt slides n. 29 and 30 to be consistent with the output produced by the generator.

NickNaso commented 4 years ago

Hi everyone, I provided to update the information about the list of native add-ons to use in the workshop. I underlined in red the add-ons that already have a porting to N-API. Here the link: https://docs.google.com/spreadsheets/d/1HopFSLMs5gj3G6_eBEZM2ET7oXKdokAF7VU2XZnzYGk Feel free to add other add-ons to the list.

rolftimmermans commented 4 years ago

FYI regarding https://github.com/zeromq/zeromq.js, there is a pull request (by me) that implements the library in N-API. https://github.com/zeromq/zeromq.js/pull/343

NickNaso commented 4 years ago

FYI regarding https://github.com/zeromq/zeromq.js, there is a pull request (by me) that implements the library in N-API. zeromq/zeromq.js#343

Thanks to report I missed it, sorry. I updated now.

jschlight commented 4 years ago

@NickNaso and others. Could I please get clarification on what topics should be included in the new Asynchronous Operations section that differ from those in the existing AsyncWorker section?

NickNaso commented 4 years ago

@NickNaso and others. Could I please get clarification on what topics should be included in the new Asynchronous Operations section that differ from those in the existing AsyncWorker section?

My idea was to create an example for the AsyncContext .

jschlight commented 4 years ago

New Workshop Sections

Section Status
node-gyp Ready for review.
CMake.js Ready for review.
prebuild Ready for review.
Object and function references Ready for review.
Thread-safe functions Ready for review.
Context awareness Ready for review.

The links above take you directly to the preview site.

Besides reviews of the completed content, I can use help with the outlines of the remaining sections. Specifically, what topics should be covered along with a brief explanation. If I can get some guidance, I can take it from there.

It’s probably best to post comments here for everyone to see.

NickNaso commented 4 years ago

@jschlight I try to give you some opinions:

node-gyp

Older versions of node-gyp require Python 2.7. More recent verisons of node-gyp can also use Python 3.5+. The specifics can be found here.

It's not only Python 2.7 or 3.5+ that is requested to work with node-gyp, all depends on which operating system you are so I want be more generic and say that to use node-gyp developer needs to satisfy some requirements and link to the official documentation.

CMake.js

In addition to the entries required for any CMake build, additional entries are required when building natove modules.

Typo natove should be native.

When building a native module based on N-API, it is important to decalre the miniumen N-API version against which your modeule is designed to work. For CMake.js, this is accomplished by adding a line like this to the CMakeLists.txt file:

Typo modeule should be module.

Here is a complete CMakeLists.txt file for an N-API native module built on node-addon-api.:

I think that you need to remove the dot before the final colon.

NickNaso commented 4 years ago

Hi @jschlight, I read the new section about the object reference and maybe it seems good. I want change the Weak section https://preview.napi.inspiredware.com/special-topics/object-function-refs.html#Weak-Reference in something like this:

@gabrielschulhof I'm not sure about the second point.

KevinEady commented 4 years ago

Hi @jschlight ,

I started working on the tsfn page. It is still in draft state... https://gist.github.com/KevinEady/112edab9a57e82bead0412a65a6c74ac Is there some way I can move this to some shared Markdown site we have / maybe edit that TSFN page directly?

Todo:

jschlight commented 4 years ago

Thank you @KevinEady.

I've posted the contents of your gist to the preview tutorial site which you can see here: https://preview.napi.inspiredware.com/special-topics/thread-safe-functions.html

If it works for you, you can continue your work inside your gist and I can transfer it to the tutorial site when it's ready.

Up to this point, I've been maintaining the tutorial site myself. It's based on hexo. But now that we have more collaborators I'd like to explore the possibility of transferring the contents of the tutorial site to the auspices of the Node.js Foundation.

Perhaps this is something we can discuss after the workshop.

mhdawson commented 4 years ago

@KevinEady from the discussion in the N-API team meeting today, we figured the best example we already have: https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function and the equivalent in node-addon-api (https://github.com/nodejs/node-addon-api/blob/master/test/threadsafe_function/threadsafe_function.cc).

We discussed that we should probably copy that test to create an example, but for now you can look at the test code (likely stripped down).

KevinEady commented 4 years ago

Hi @mhdawson ,

Sounds good! I'll work on that this week.

Kevin

mhdawson commented 4 years ago

@KevinEady thanks!

KevinEady commented 4 years ago

@mhdawson / @gabrielschulhof The provided examples use static data eg. https://github.com/nodejs/node-addon-api/blob/master/test/threadsafe_function/threadsafe_function.cc#L12-L13 ... Is this okay for the example? Otherwise I want to use ObjectWrap to encapsulate this data so it's no longer static.

mhdawson commented 4 years ago

It would probably be better to avoid static data unless it makes the result too complicated.

NickNaso commented 4 years ago

I ended to update the list of native modules to use for porting activities at workshop. Here the link: https://docs.google.com/spreadsheets/d/1HopFSLMs5gj3G6_eBEZM2ET7oXKdokAF7VU2XZnzYGk we have 45 add-ons.

KevinEady commented 4 years ago

Hi @jschlight I updated my gist with the example. Haven't touched the text yet though... Can the team review the example?

jschlight commented 4 years ago

Thank you @KevinEady.

I've posted your gist to the preview tutorial site.

Let's plan to ask for reviews during tomorrow's weekly call.

NickNaso commented 4 years ago

Preview of new design for the slides: presentazione-opt.pdf

mhdawson commented 4 years ago

I like the new design. I think we should add another page at the end which has the links for the workshop tutorials so that we can put that up to get people started.

Then maybe another page which has the link to the page where you have the modules that need to be ported so that we can put that up later on in the workshop?

NickNaso commented 4 years ago

@mhdawson Ok i will provide to do that. @jschlight will the final link for the workshop be https://napi.inspiredware.com/?

NickNaso commented 4 years ago

Hi everyone, I just shared the new format for the slides. @mhdawson I added the slides that you asked (slide number 50). @gabrielschulhof May I ask you to take a look at image on slide number 26, it could be good have the text in white. Let me know if you want change something or you can do by yourself.

jschlight commented 4 years ago

@mhdawson @gabrielschulhof @NickNaso @KevinEady

Hi all --

The last two remaining tutorials are now complete and ready for your review. Please post any suggestions here and we can discuss any remaining issues on Monday.

Here's a tweet that could go out Friday to get participants ready for the workshop:

Are you planning to attend the N-API Workshop at Node+JS Interactive next week? Ready to jump in now? Get a head start with the tutorials we'll be using: https://bit.ly/2PhWSz5 The workshop promises to be a good one with experts from the N-API team to guide you. See you there!

Heads up: The link points to the preview tutorials which I'll make live for the workshop after our review.

NickNaso commented 4 years ago

Hi @jschlight, I set the links and QR code on the slides number 50.

mhdawson commented 4 years ago

Latest version of the presentation for the workshop: https://docs.google.com/presentation/d/1kGzkj_4RqoE4YJ4I4XPdMLPcaiCHiJqLVL0nRBSUPhQ/edit

jschlight commented 4 years ago

The update tutorial pages are now live at https://napi.inspiredware.com/

mhdawson commented 4 years ago

Workshop delivered we can probably close the issue now.