Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] initial rewrite to use native async_hooks #19

Merged
merged 6 commits into from
May 30, 2017

Conversation

Fishrock123
Copy link
Collaborator

Includes lots of debug statements.

We should probably wait to merge this until nodejs/node#8531 is merged.

cc @AndreasMadsen

@@ -56,7 +56,7 @@
section#info #stats {
float: right;
width: 155px;
height: 119px;
height: 135px;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needs a better way to fit the info on the screen. My CSS is very rusty but Ideally we'd place the dprof version and whatnot to the left or right of the other info.

dprof.js Outdated

// Ignore our nextTick for the root duration
// TODO(Fishrock123): detect this better.
if (uid === 2) return
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

highlighting this

dprof.js Outdated
this.name = handle.constructor.name;
function Node(handle, id, name, stack) {
this.name = name;
this._id = id;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should maybe be this._uid = uid

dprof.js Outdated
}

function asyncBefore(uid) {
// Ignore our nextTick for the root duration
// TODO(Fishrock123): detect this better.
Copy link
Owner

Choose a reason for hiding this comment

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

why is asyncHook.disable() not enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@AndreasMadsen disable/enable are no longer tree based, and so you will still get the before/after/destroy.

Copy link
Owner

@AndreasMadsen AndreasMadsen Sep 20, 2016

Choose a reason for hiding this comment

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

Ah yes, forgot about that. However stateMap can be used as a set of all seen init events. That should allow us to ignore all before, after, and destroy events where the init event was "disabled" away.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@AndreasMadsen so if state === undefined skip?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes. I was originally thinking stateMap.has(uid), but I guess your version is a little faster.

@Fishrock123
Copy link
Collaborator Author

Rebased on master.

@AndreasMadsen
Copy link
Owner

Great! It would be awesome if you could fix #10 simultaneously. That would also give us a change to evaluate asyncHooks.currentId().

@Fishrock123
Copy link
Collaborator Author

@AndreasMadsen are you looking for the conceptual parent or technical one?

As I understand it the parentId passed in init will be the conceptual one.

@AndreasMadsen
Copy link
Owner

@Fishrock123 the conceptual one, that is at least the current behaviour. It's almost what is implemented here, but I would like to avoid using currState. Maybe something like:

const source = parentUid === 1 ? asyncHooks.currentId() : parentUid;

By the way, do you have a good source for the parentUid === 1 detail? From what I can see, it is not documented in the EP, just in some code comments that I don't fully understand.

@trevnorris
Copy link

@AndreasMadsen

By the way, do you have a good source for the parentUid === 1 detail?

Think I put it in there as a "note". Not as an actual section. Will improve that. Short of it is there are two reserved id's. 0 and 1.

  • 0: The "void". The currentId is always set to zero after leaving the JS stack. If parentId or currentId() are ever 0 then there's a bug.
  • 1: "root". This id is assigned to startup or bootstrap execution. If all id's are mapped out properly all of them should lead back to 1.

The code you have there is basically the same as changes I'm currently hammering out. parentId should always be the id of the handle that originated the constructor. Sometimes it will be the same as currentId(). Though after I get done with my most current set of changes you should always be able to rely on parentId.

dprof.js Outdated
const root = new Node(
0, { 'constructor': { name: 'root' } },
0,
Copy link
Owner

@AndreasMadsen AndreasMadsen Oct 6, 2016

Choose a reason for hiding this comment

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

According to what @trevnorris said about the parentId, this should be 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm, true.

@AndreasMadsen AndreasMadsen merged commit 4471e62 into master May 30, 2017
@AndreasMadsen AndreasMadsen deleted the native-async_hooks branch May 30, 2017 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants