You may have to use a trick like this:

http://www.xqueryhacker.com/2012/01/marklogic-xquery-performance-tuning-computing-facets-concurrently/

Basically, you would need to make the call and then to not use the result until 
much later.

I don't think this would work for xdmp:invoke() or xdmp:eval(), but it might 
work for xdmp:http-post().  It'll definitely work for any lexicon calls that 
has the "concurrent" option.

Hsiao "Shao" Su
Senior Performance Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 650 287 2545
www.marklogic.com<http://www.marklogic.com/>

This e-mail and any accompanying attachments are confidential. The information 
is intended solely for the use of the individual to whom it is addressed. Any 
review, disclosure, copying, distribution, or use of this e-mail communication 
by others is strictly prohibited. If you are not the intended recipient, please 
notify us immediately by returning this message to the sender and delete all 
copies. Thank you for your cooperation.


From: [email protected] 
[mailto:[email protected]] On Behalf Of Geert Josten
Sent: Wednesday, May 23, 2012 10:56 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] getting MarkLogic to execute functions in 
parallel

Hi Ryan,

>From the top of my head I can think only of one other option, which I haven't 
>tried myself yet. I recently noticed this <result> option 
>(http://community.marklogic.com/pubs/5.0/apidocs/Ext-6.html#xdmp:eval), which 
>should be used in combination with xdmp:spawn if I understand correctly.

Kind regards,
Geert

Van: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 Namens [email protected]<mailto:[email protected]>
Verzonden: woensdag 23 mei 2012 18:59
Aan: [email protected]<mailto:[email protected]>
Onderwerp: [MarkLogic Dev General] getting MarkLogic to execute functions in 
parallel

I have a search function that calls other search functions that are independent 
of each other. The master search function takes the results of these sub-search 
functions and compiles and processes them according to some rules.

I would like the sub-search functions to all execute in parallel at the same 
time to reduce the response time of the call to the master search function.

I tried using xdmp:http-post and xdmp:invoke both in for loops and also without 
for loops.

for example:

*xdmp:http-post (for loop) does not execute in parallel:

let $sub-search-results :=
    for $sub-search in $sub-searches
    return xdmp:http-post($endpoint....)

let $subsearch-results :=
    <subsearch-results>
        {$sub-search-results}
    </subsearch-results>

return $sub-search-results


*xdmp:http-post (no for loop) DOES execute in parallel:

let $sub-search-result-1 := xdmp:http-post($endpoint....)
let $sub-search-result-2 := xdmp:http-post($endpoint....)
let $sub-search-result-3 := xdmp:http-post($endpoint....)
let $sub-search-result-4 := xdmp:http-post($endpoint....)

let $subsearch-results :=
    <subsearch-results>
        {$sub-search-result-1}
        {$sub-search-result-2}
        {$sub-search-result-3}
        {$sub-search-result-4}
    </subsearch-results>

return $sub-search-results


I tried similar approaches using xdmp:invoke (both with and without a for loop) 
but neither would execute in parallel.

Does this sound right? I was expecting to be able to get parallel execution in 
a for loop using xdmp:http-post (I even tried fn:unordered but it had not 
effect). and I was expecting to get parallel execution using xdmp:invoke 
somehow but I couldn't.

The http-post approach isn't too bad for my situation but it feels like a 
little bit of a hack just to get parallel execution. Are there any other ways?

thanks,
Ryan
_______________________________________________
General mailing list
[email protected]
http://community.marklogic.com/mailman/listinfo/general

Reply via email to