Freezerburn / node_quadtree

A native QuadTree implementation for Node.JS
MIT License
4 stars 0 forks source link

New node.js versions support #2

Open baryshev opened 8 years ago

baryshev commented 8 years ago

This is a fastest node.js Quadtree implementation, but unfortunately it can't be compiled with new node.js versions because of v8 API changes. Is any plans to port it to new native api using Nan?

Freezerburn commented 8 years ago

What version of node support are you looking for? I think the latest is 5.x? What is "Nan"? (I know NaN is "Not a Number", is that what you mean? what support for NaN are you looking for?)

I can look into making this compatible with more recent node versions. Though if you have any experience with writing node FFI code, I would appreciate a pull request with the basic updates. I can't imagine much needs to actually be done, and the only parts that should need to be touched are the actual bindings at the bottom of the only source file. (Unless Persistent was removed, in which case a little of the quadtree code needs to be changed)

baryshev commented 8 years ago

I have no C/C++ background but I tried to do some research about compilation errors. All native modules have broken after update from node.js 0.10 to 0.11 (unstable) and newer. I found many examples of porting native modules (with the same compilation errors) to new node.js versions. And they all uses Nan. This is abstraction layer to new native API's as far as I understand. But i'm still not sure is it required or not.

Here is several examples of porting native modules to new native API: https://github.com/peterbraden/node-opencv/pull/177/commits/8db4e0ed2d39379e91ba8e775d9eef48a24667c6 https://github.com/tugrul/node-mcrypt/commit/1feff1cba254d945b4a8da0dbf136730ea60fa0e https://github.com/ncb000gt/node.bcrypt.js/commit/a2b28e76508b111558bfa193cd35a984f6dd6fa5

I'm tried to do the same things to port this module, but unfortunately without C/C++ background I have no success.

Freezerburn commented 8 years ago

Those links are very helpful! I did not know about Nan, and would have likely slogged through V8's API to update the module, so that should help get things working again quickly. I'll see if I can take a look at getting this working again this evening.

baryshev commented 8 years ago

Thank you. I really appreciate it.

Freezerburn commented 8 years ago

Commit 87732f0 allows the code to compile again, but a memory leak exists somewhere. Running test.js will eventually end up consuming >1300MB of RAM and then eventually crash. I'm still trying to figure out where it is. Also I don't remember the original performance statistics, but add/remove might have had their performance characteristics changed somewhat due to the different way the code interacts with the Nan API vs the old V8 API.

Freezerburn commented 8 years ago

Also as a slightly off-topic thing: What do you use the quadtree for? I kind of assumed nobody used it and never would, so it's a pleasant surprise to hear someone uses it :)

baryshev commented 8 years ago

Thank you for the update. I just tested the performance and unfortunately new version works slower. Previous version compiled for node 0.10 works 2-5 times faster than pure JS implementation. New version works as slow as pure JS version and it's crashed to segmentation fault on large trees (previous version not crashed at the same tree size).

I'm tried to use this library to improve the performance of our game that we are working now. I found it after testing many pure js libraries and I was impressed with the performance.

Nazariglez commented 8 years ago

Same here!, a native implementation of the quadtree for node sounds a good idea to use in my games!