Wow, you have many solutions to that one. I was under the impression that a
consistent asynchronous patterned was expected in NodeJs programming. I
think I understand how it works now. It just serves users with data when it
is time/ready to. I was thinking the wrong way about the whole thing. I did
find your solutions interesting however, and I thank you for them (except
setTimeout, jessh;).

Also, I posted the processed v8.log file here -->
http://dpaste.com/hold/1248901/
It does not seam like all of those 0%'s are a good thing but I still need
to go over some docs to grasp what it means.


On Mon, Jun 17, 2013 at 12:45 AM, Andrey <[email protected]> wrote:

> Do you have any numbers to proof that you need to optimise here? How much
> time does it usually take for makeXmlFromString to complete? Could you
> post first lines of processed v8.log after running with --profile?
>
> If you are sure that this function does block io loop for some significant
> amount of time (say, 10ms - how small this number should be really depend
> on what you expect from your application) then you have following options:
>  - write C++ addon, use libuv work queue (
> http://nikhilm.github.io/uvbook/threads.html#libuv-work-queue ). Measure
> again, note that it could be actually slower than JS only ( see
> http://kkaefer.github.io/node-cpp-modules/#benchmark-thread-pool )
>  - use threads via https://github.com/xk/node-threads-a-gogo
>  - as already suggested, you can try allow IO loop to run in parallel with
> your code by splitting in smaller functions wrapped in setTimeout
>  - move your code to separate node.js process, use some kind of RPC to
> send arguments/receive results (for example, fork/message -
> http://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options)
>
> On Monday, 17 June 2013 08:26:46 UTC+10, surgemcgee wrote:
>
>> So, how do I get the function to be asynchronous if I added other
>> functionality? Is there a module to import? I just do not get the threading
>> aspect of it all I guess.
>>
>>
>> On Sun, Jun 16, 2013 at 4:37 PM, Angel Java Lopez <[email protected]>wrote:
>>
>>> Hi!
>>>
>>> Ummm... makeXmlFromString, beginning at line 83, could directly return
>>> the value xmlFile instead of calling a callback. No I/O in its body, so you
>>> don't leverage the power of node.js to manage async I/O
>>>
>>> Maybe, at line 61, when req.on('data'....) you could start to create the
>>> xml, incrementally. But if it is hard, that's ok, for a first approach
>>>
>>> Any comments?
>>>
>>> Angel "Java" Lopez
>>> @ajlopez
>>>
>>>
>>>
>>> On Sun, Jun 16, 2013 at 5:27 PM, Robert Steckroth 
>>> <[email protected]>wrote:
>>>
>>>> I have a server which parses through a text file and creates a XML page.
>>>>
>>>> The XML creation can involve a lot of loops (up to ~8000).
>>>>
>>>> I am confused regarding the asynchronous nature of NodeJs.
>>>>
>>>> Would the below function benefit from a non-blocking call? Or does the 
>>>> createServer function maintain its own thread for each incoming request?
>>>>
>>>>
>>>> You can see this function call on line: 65 of the provided Node file.
>>>>
>>>> makeXmlFromString(textOutput, function(xmlText)
>>>>
>>>>
>>>> http://bazaar.launchpad.net/~**robertsteckroth/stock-ticker-**mobile-app/proxy/view/head:/**server/stock_proxy_server.js
>>>>  
>>>> <http://bazaar.launchpad.net/~robertsteckroth/stock-ticker-mobile-app/proxy/view/head:/server/stock_proxy_server.js>
>>>>
>>>>
>>>>
>>>> Or maybe this file is done correctly... I am having a lot of trouble 
>>>> getting the scoop on async in JavaScript :0
>>>>
>>>> --
>>>>
>>>> Bust0ut, Surgemcgee: Systems/Web/Software Engineer
>>>>
>>>> "Freedom is empowered by those without power" - Robert Edward Steckroth
>>>> II
>>>> "Injustice, regarding the internet, is fashioned through laws and
>>>> enforcement" - Robert Edward Steckroth II
>>>> "Reality is the fuel of the universe and the roadblock to human
>>>> understanding" - Robert Edward Steckroth II
>>>>
>>>>
>>>>  --
>>>> --
>>>> Job Board: http://jobs.nodejs.org/
>>>> Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-
>>>> **Posting-Guidelines<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To post to this group, send email to [email protected]
>>>>
>>>> To unsubscribe from this group, send email to
>>>> nodejs+un...@**googlegroups.com
>>>>
>>>> For more options, visit this group at
>>>> http://groups.google.com/**group/nodejs?hl=en?hl=en<http://groups.google.com/group/nodejs?hl=en?hl=en>
>>>>
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to nodejs+un...@**googlegroups.com.
>>>>
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>>
>>>>
>>>
>>>  --
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-*
>>> *Posting-Guidelines<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines>
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>>
>>> To unsubscribe from this group, send email to
>>> nodejs+un...@**googlegroups.com
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/**group/nodejs?hl=en?hl=en<http://groups.google.com/group/nodejs?hl=en?hl=en>
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to nodejs+un...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> Bust0ut, Surgemcgee: Systems/Web/Software Engineer
>>
>> "Freedom is empowered by those without power" - Robert Edward Steckroth II
>> "Injustice, regarding the internet, is fashioned through laws and
>> enforcement" - Robert Edward Steckroth II
>> "Reality is the fuel of the universe and the roadblock to human
>> understanding" - Robert Edward Steckroth II
>>
>>
>>   --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Bust0ut, Surgemcgee: Systems/Web/Software Engineer

"Freedom is empowered by those without power" - Robert Edward Steckroth II
"Injustice, regarding the internet, is fashioned through laws and
enforcement" - Robert Edward Steckroth II
"Reality is the fuel of the universe and the roadblock to human
understanding" - Robert Edward Steckroth II

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to