[xquery-talk] Matrix Multiplication (JSONiq)

Hermann Stamm-Wilbrandt STAMMW at de.ibm.com
Mon Feb 3 07:24:41 PST 2014


as other I do see neither JSONiq nor XQuery being able to compete with eg.
native C implemenation of matrix multiplication.

Your 200x200 example is interesting as it shows that JSONiq(JSON,
PT10.838593S) is now slower than XQuery(XML, PT9.03348S):

Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Level 3 support for XML Compiler team and Fixpack team lead
WebSphere DataPower SOA Appliances
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

  From:       jean-marc Mercier <jeanmarc.mercier at gmail.com>                                                                                    
  To:         David Carlisle <davidc at nag.co.uk>,                                                                                                
  Cc:         Hermann Stamm-Wilbrandt/Germany/IBM at IBMDE, "talk at x-query.com Talk" <talk at x-query.com>                                             
  Date:       02/03/2014 12:30 PM                                                                                                               
  Subject:    Re: [xquery-talk] Matrix Multiplication (JSONiq)                                                                                  

Hi all,

I've tried the following JSON query with zorba, mimicking a NxN, with
N=200, matrix multiplications. Time is 10 sec on http://try.zorba.io/,
behaving with a cubic N^3 complexitity.
Do you really want to know what are the performances of standard linear
algebra library for such matrix multiplications ?

import module namespace datetime = "

declare variable $size := 200;

declare variable $A := [ for $i in 1 to $size return
        for $j in 1 to $size return $i*$size+$j

let $R := ( datetime:current-time(),
    for $i in 1 to count(jn:members($A)) return
      for $k in 1 to count(jn:members($A)) return
          for $j in 1 to count(jn:members($A)) return
            $A($i)($j) * $A($j)($k)
, datetime:current-time() )

return $R[count($R)] - $R[1]

2014-02-03 David Carlisle <davidc at nag.co.uk>:
  On 03/02/2014 10:56, Hermann Stamm-Wilbrandt wrote:
   PT1.713634S (JSONiq) versus PT9.77805S (XQuery)

  ooh interesting , I wonder where the bottleneck in the xquery is.
  Probably as Michael commented at some point earlier in the thread, the
  time to access the ith element of a sequence $a[$i].

  But the language doesn't _need_ to change, just if more people did it
  the xquery compilers would perhaps look out for sequences that are
  exclusively accessed via numeric filters and implement them in a way
  that gives constant time access. Having a separate array type does give
  them a big hint though:-)


  The Numerical Algorithms Group Ltd is a company registered in England
  and Wales with company number 1249803. The registered office is:
  Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

  This e-mail has been scanned for all viruses by Star. The service is
  powered by MessageLabs.
  talk at x-query.com

More information about the talk mailing list