Describe the bug
We noticed an extreme slowdown of resource validation in our project when switching to HAPI 7.4.0. Instead of minutes the validation takes hours. We profiled the application and found out that almost 100% of the time was spent in VersionSpecificWorkerContextWrapper#isPrimitiveType(String). The code is always traversing all StructureDefinitions to check if any type that is primitive has a matching name.
To Reproduce
Validate a resource with lots of StructureDefinitions available to the ValidationContext, triggering isPrimitive call. The simplest is a CodeSystem, since constraint csd-1 triggers a lot of those calls when evaluating the isDistinct function.
Expected behavior
The expected behavior would be a reasonable evaluation time of isPrimitive(String).
We would suggest to add a field of type Set<String> of names of primitive types to VersionSpecificWorkerContextWrapper to cache the names of all primitive types, similar to how it is done for all known StructureDefinitions already.
If it is wanted, we can work on a PR implementing the suggested solution.
Environment (please complete the following information):
Describe the bug We noticed an extreme slowdown of resource validation in our project when switching to HAPI 7.4.0. Instead of minutes the validation takes hours. We profiled the application and found out that almost 100% of the time was spent in
VersionSpecificWorkerContextWrapper#isPrimitiveType(String)
. The code is always traversing allStructureDefinition
s to check if any type that is primitive has a matching name.To Reproduce Validate a resource with lots of
StructureDefinition
s available to the ValidationContext, triggeringisPrimitive
call. The simplest is a CodeSystem, since constraintcsd-1
triggers a lot of those calls when evaluating theisDistinct
function.Expected behavior The expected behavior would be a reasonable evaluation time of
isPrimitive(String)
.We would suggest to add a field of type
Set<String>
of names of primitive types toVersionSpecificWorkerContextWrapper
to cache the names of all primitive types, similar to how it is done for all knownStructureDefinition
s already.If it is wanted, we can work on a PR implementing the suggested solution.
Environment (please complete the following information):