We have various complex models in our project. For these models, the validation code is queried via the endpoint
“#{@dataServicesCoreProperties.server.contextPath}/v2/models/{model-id}/validationCode”.
For most models, this happens in an acceptable time. However, there is one model (the main model) for which the first query takes more than 15 seconds.
Each subsequent query then runs quickly.
My questions:
- what exactly happens here in the background?
- what is the duration of the validation code generation dependent on?
- when is the code newly generated and when is already generated code only delivered (cache)
Hello,
validation is kernel’s feature, so I’d suggest to ask kernel team.
Or, you can profile your app and check what takes most of the time.
Thanks and alright, I’ll ask the kernel team as well.
But from a user perspective, the request is to the dataservice endpoint, so I would expect to get an idea here as well.
And yes, I can do the profiling, but I would prefer a conceptual answer here.
I’m sorry, everything that DS does is to call kernel code, so as I mentioned, it’s a question to the kernel team.
The only thing happening on the DS side is to check for model read permissions.
I forgot to mention the caching, so as soon as the validation code is computed per a particular model, it’s cached, so the next call for the code should be returned from the cache.
Model read permission check happens every time.
(short note: Kernel team is already involved and will head back to you here soon, @torsten-blazing-hash)
Thanks, do you know if and when the cache will be evicted?
It’s evicted when a model is changed. Eviction is triggered by ModelsAfterImportEvent, ModelAfterUpdateEvent and ModelAfterDeleteEvent.
TTL is set to one hour and eviction is set to occupy max 20 MB of the heap by default.
@torsten-blazing-hash from kernel’s point of view, code generation and compilation is a rather expensive operation that is meant to be executed infrequently.
For large models, 15s might simply be the normal codegen + compile time (I don’t know any details about your model and hardware, so I can’t tell for sure). If you believe that it is unusually slow for your particular model, we’d need the model in order to check in more detail.
=> I think the most likely recommendation would be to optimize cache retention for your use case.