castable as performance

Bug #1194720 reported by Matthias Brantner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Committed
Medium
Paul J. Lucas

Bug Description

The "castable as" expression has a big performance bottleneck because its implementation uses cast as followed by catching a potential exception. Constructing the exception (including the parameter substitution for the error message) takes a lot of time and it's not needed.

A query to reproduce this is as follows:

jsoniq version "1.0";

for $value in
  (
    "true", "false", ((1 to 1000) ! ($$ cast as string))
  )
return
  if ($value castable as boolean)
  then $value cast as boolean
  else if ($value castable as double)
  then $value cast as double
  else if ($value castable as decimal)
  then $value cast as decimal
  else if ($value castable as integer)
  then $value cast as integer
  else $value

The attached screenshot shows the relevant part of a callgrind profile.

Related branches

Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Can you give a specific example of such a query?

Changed in zorba:
status: New → Incomplete
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

callgrind profile

description: updated
Changed in zorba:
status: Incomplete → Confirmed
Changed in zorba:
status: Confirmed → In Progress
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Try out this branch.

Changed in zorba:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.