[
https://issues.apache.org/jira/browse/SLING-4112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stefan Seifert updated SLING-4112:
----------------------------------
Attachment: 141030_jprofiler_without_models_tuning_total_grouped.gif
141030_jprofiler_without_models_tuning_models.gif
141030_jprofiler_with_models_tuning_total_grouped.gif
141030_jprofiler_with_models_tuning_models.gif
141030_jmeter_without_models_tuning.gif
141030_jmeter_with_models_tuning.gif
in the branch i implemented a performance optimization concerning inspecting
the sling models via reflection - most of what was possible without breaking
the SPI interfaces is implemented. the code got even a bit cleaner factoring a
lot of the reflection-related stuff out of the big ModelAdapterFactory class
into separate classes.
according to my measurements (of course a bit difficult to measure because it
runs always mixed up with repository, rendering and other stuff) this changes
result in:
* increasing sling models implementation performance by roughly 30%
* increasing overall performance of my sample application by roughly 5-7%
some charts:
* before tuning: [^141030_jmeter_without_models_tuning.gif],
[^141030_jprofiler_without_models_tuning_models.gif],
[^141030_jprofiler_without_models_tuning_total_grouped.gif]
* after tuning: [^141030_jmeter_with_models_tuning.gif],
[^141030_jprofiler_with_models_tuning_models.gif],
[^141030_jprofiler_with_models_tuning_total_grouped.gif]
in rev. 1635314-1635488 the optimization are implemented that ware possible
without any SPI changes.
in rev. 1635517 i introduced a new SPI Interface
{{StaticInjectAnnotationProcessorFactory}}, because
{{InjectAnnotationProcessorFactory}} could not be applied statically to class
only, but always in conjunction with an adaptable. but this features was used
only in very rare occasions (only by the value map injector and by the child
resource injector, and there only for a convenience default for the via
property). those two injectors still use {{InjectAnnotationProcessorFactory}}
and are a bit less performant, the others switched to
{{StaticInjectAnnotationProcessorFactory}}. it's backwards compatible, although
i would be happy to remove the {{InjectAnnotationProcessorFactory}} altogether,
this would clean up the code even more. but it's existing functionality. it
should be possible to think about another way to support this via convenience
feature.
a lot of stuff had to be changed and refactored for this optimizations. but the
unit tests are completely untouched (besides some syntax changes) and still
pass, so i hope that i have not broken anything.
currently it's still in the branch and not yet in the trunk. feedback welcome.
> Sling Models: Optimize performance when read sling models annotations
> ---------------------------------------------------------------------
>
> Key: SLING-4112
> URL: https://issues.apache.org/jira/browse/SLING-4112
> Project: Sling
> Issue Type: Improvement
> Components: Extensions
> Affects Versions: Sling Models Implementation 1.1.0
> Reporter: Stefan Seifert
> Assignee: Stefan Seifert
> Priority: Minor
> Labels: models
> Fix For: Sling Models Impl 1.2.0
>
> Attachments: 141028_adaptto_jprofiler_slingmodels.gif,
> 141028_adaptto_jprofiler_slingmodels_getannotation.gif,
> 141030_jmeter_with_models_tuning.gif,
> 141030_jmeter_without_models_tuning.gif,
> 141030_jprofiler_with_models_tuning_models.gif,
> 141030_jprofiler_with_models_tuning_total_grouped.gif,
> 141030_jprofiler_without_models_tuning_models.gif,
> 141030_jprofiler_without_models_tuning_total_grouped.gif
>
>
> i did some first performance tests with a sling application that makes
> intensive usage of sling models to see where potential hotspots are that cost
> performance, esp. in area of sling models.
> attached is a filtered view of a jprofile session showing only the method
> calls inside sling models implementation:
> [^141028_adaptto_jprofiler_slingmodels.gif]
> a good part of performance is spent on inspection the annotations of the
> sling models classes, a call graph of the first method:
> [^141028_adaptto_jprofiler_slingmodels_getannotation.gif]
> i think this is especially the case because this inspection takes place on
> each adaptTo() call, although the underlying model class never changes when
> the OSGi bundle stays in place.
> it should be possible to come up with an optimization caching the inspection
> results (which annotations exist on which fields/methods/types with which
> parameters), and doing only the injection part on each adaptTo() invocation.
> if the bundle changes the cache has to be cleared.
> i will think about it the next days and perhaps come up with an
> implementation proposal.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)