Node.js increase Memory

120 views
Skip to first unread message

Juan Sebastian

unread,
Aug 2, 2014, 3:34:26 PM8/2/14
to nod...@googlegroups.com
Hi All

I'm Coding some trees in NodeJS
and after creating 1,000,000 elements and looping to get the top10 elements 
the process ends with these stats:

TOP 10 Products by ID:
{ Id: 31229, numSold: 99999741 }
{ Id: 724109, numSold: 99999702 }
{ Id: 228470, numSold: 99999663 }
{ Id: 252501, numSold: 99999630 }
{ Id: 764570, numSold: 99999462 }
{ Id: 525615, numSold: 99999414 }
{ Id: 789503, numSold: 99999379 }
{ Id: 428851, numSold: 99999260 }
{ Id: 533397, numSold: 99999244 }
{ Id: 202426, numSold: 99999146 }
Max Quantity Item : id: 31229 Quantity: 99,999,741
Min Quantity Item: id: 691832  Quantity: 76
Process: 4547ms

is there any way to improve the performance from the V8 side?

I've tried the following line but makes no significant difference
./node --max_executable_size=3048 --stack_size=102400 test.js
./node --max_old_space_size=3048 --stack_size=102400 test.js

I coded the same in Java and
by modifying the arguments to the JVM (increase the memory)
JRE Arguments -> -Xms1024m -Xmx2048m
the performance was significant faster: for 1,000,000 elements-> Time: 1730 ms

Any advice/trick will be welcomed

Best Regards

Juan S.

Andrey

unread,
Aug 4, 2014, 2:04:51 AM8/4/14
to nod...@googlegroups.com
If you are using same algorithm then 2x difference Java vs JS is not something surprising, I would expect this.

How do you compute top 10? With built-in Array.search + slice(0,10) I get ~2500ms and if I use binary heap tree ( 
https://github.com/tjfontaine/node-binaryheap ) (push every element and pop if tree length > 10) running time is down to 950ms

Also, try to benchmark your code after multiple runs as first run might use non-optimised code
Reply all
Reply to author
Forward
0 new messages