Hi Christian, > Your hint was helpful: If a function signature is not registered yet > when it is parsed, all kind of lookups are performed to locate the > function. This is e.g. the case if the function is recursive, or if > the invoked functions occurs after the currently parsed code. > > I have revised the code which is responsible for locating invoked > functions: In the JavaFunction class [1], the lookup will be avoided > if we can tell in advance that no Java class will be found.
I did some non-scientific testing, the results are quite awesome. This is with one of our regression test suites, in this case we create 600 databases with exactly one (small) file, run a few queries against it (typically 3), and our business logic interprets the results (the use case is to check if some business rules are violated in the xml). Here are the results, the numbers are seconds to execute the full test suite: | | BaseX 8.6.1 | BaseX 9.0.2 | BaseX 9.1 Snapshot | |-----+-------------+-------------+--------------------| | 1 | 42.5 | 44.5 | 20.3 | | 2 | 42.5 | 44.4 | 18.1 | | 3 | 42.9 | 44.6 | 18.1 | | 4 | 42.5 | 44.8 | 18.2 | | 5 | 42.5 | 43.8 | 18.6 | |-----+-------------+-------------+--------------------| | Avg | 42.6 | 44.4 | 18.7 | So our case is now more than twice as fast as before :) I did some profiling/sampling with JProfiler as well, the Class.forName call is now almost completely gone, while it was the most-hit method before. I guess that means that improving the caching of classes is not needed, since you fixed the core problem. Thanks a lot, this really helps us a lot! -tom