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

perf hit from NanFromV8String #3

Closed
trevnorris opened this issue Jul 24, 2013 · 8 comments
Closed

perf hit from NanFromV8String #3

trevnorris opened this issue Jul 24, 2013 · 8 comments

Comments

@trevnorris
Copy link
Collaborator

Two things are going to kick you:

  1. Always expecting the string to be utf8 is going to kill performance. I might allow users to pass enum encoding in node.h to allow a specific encoding output.
  2. If the string is external one or two byte then all you'll need is a memcpy.

A lot of this is properly addressed in node::StringBytes::Encode. But since that doesn't exist pre v0.11, maybe just use it for a reference.

@rvagg
Copy link
Member

rvagg commented Jul 25, 2013

@trevnorris would you mind if I added you as a collaborator to this repo? I'd love to have your contributions since you know the node internals much better than I.

@trevnorris
Copy link
Collaborator Author

Sure.

Ironically I started to throw together some convenience stuff and threw it
into a package called njsutil on npm. If you want, take a look an let me
know if there's anything you'd like me to port over.

@rvagg
Copy link
Member

rvagg commented Jul 25, 2013

OK, I've added you. Since this is a download-from-github project, we'd better do everything off-master until stuff is ready for "release". I have an 0.2.0 branch on the go already. pull-request for additions and major fixes would be appreciated so there can be discussion too.

Will have a look at njsutil. Thanks!

@kkoopa
Copy link
Collaborator

kkoopa commented Jul 28, 2013

Any updates on this? I just started reimplementing node::StringBytes, but it seems necessary to add most of it, which create a fair amount of clutter -- assuming we want to stick to a single file. I assume the same issue will arise when backporting node::Cached.

@rvagg
Copy link
Member

rvagg commented Jul 28, 2013

I'd prefer a single header file if possible, but if we need to add a compiled unit then it could be added as an optional extra perhaps? With some instructions on what to put in your .gyp file, or just export a full .gyp with instructions on how to depend on it in your own .gyp. But if possible, lets try and cram it all in to a header.

if it's a matter of just making the header file too big.. well, I'm not sure I'm too concerned about that, as long as we can try and keep it relatively well organised. It'll compact nicely enough in the .tgz published packages.

@kkoopa
Copy link
Collaborator

kkoopa commented Jul 28, 2013

Yes, sounds reasonable. Might want to wrap parts in #ifdefs if they may or may not be wanted. On closer inspection of this particular issue, it seems like I can get by with a lot less code. I might have a semi-working draft done in an hour or two.

@kkoopa
Copy link
Collaborator

kkoopa commented Jul 28, 2013

970421b contains a work in progress. It still requires some fixing and I am not sure on e.g. when zero terminators need to be added, e.g. should buffers get an extra terminating zero?

This was referenced Jul 28, 2013
@kkoopa
Copy link
Collaborator

kkoopa commented Aug 19, 2013

I think this one is finally sorted out. Closing.

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

No branches or pull requests

3 participants