castable as performance
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
- Matthias Brantner: Approve
- Paul J. Lucas: Approve
-
Diff: 2283 lines (+490/-300)3 files modifiedChangeLog (+1/-0)
src/types/casting.cpp (+476/-292)
src/types/casting.h (+13/-8)
Changed in zorba: | |
status: | Confirmed → In Progress |
Changed in zorba: | |
status: | In Progress → Fix Committed |
Can you give a specific example of such a query?