[richfaces-issues] [JBoss JIRA] Commented: (RF-11000) Hit miss for class loader cost performance problem in Richfaces 4.1.0.

Brian Leathem (JIRA) jira-events at lists.jboss.org
Mon Sep 26 14:21:26 EDT 2011


    [ https://issues.jboss.org/browse/RF-11000?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630546#comment-12630546 ] 

Brian Leathem commented on RF-11000:
------------------------------------

To summarize my understanding of the implications of this patch:

The code in question:
{code:title=ResourceFactoryImpl.java}
    protected Resource createDynamicResource(ResourceKey resourceKey, boolean useDependencyInjection) {
        Resource result = null;

        Map<String, String> params = null;

        MappedResourceData mappedResourceData = mappedResourceDataMap.get(resourceKey);
        ResourceKey actualKey;
        if (mappedResourceData != null) {
            actualKey = mappedResourceData.getResourceKey();
            if (useDependencyInjection) {
                params = mappedResourceData.getParams();
            }
        } else {
            actualKey = resourceKey;
            if (useDependencyInjection) {
                params = Collections.<String, String>emptyMap();
            }
        }

        if (Strings.isNullOrEmpty(resourceKey.getResourceName())) {
            return null;
        }

        if (actualKey.getResourceName().endsWith(".ecss")) {
            // TODO nick - params?
            result = createCompiledCSSResource(actualKey);
        } else {
            result = createHandlerDependentResource(actualKey, params);
        }

        if (result != null) {
            result.setLibraryName(resourceKey.getLibraryName());
            result.setResourceName(resourceKey.getResourceName());
        } else if (mappedResourceData == null) {
            result = defaultHandler.createResource(actualKey.getResourceName(), actualKey.getLibraryName());
        }

        return result;
    }
{code}

Secifically the line:
{code:title=ResourceFactoryImpl.java#L431-436}

if (actualKey.getResourceName().endsWith(".ecss")) {
    // TODO nick - params?
    result = createCompiledCSSResource(actualKey);
} else {
    result = createHandlerDependentResource(actualKey, params);
}
{code}
The proposed patch implies that _mappedResourceData == null_ implies that the resource is static.  This implication is important, because static resource should not be loaded via a call to _createHandlerDependentResource(...)_, but rather with a call to _defaultHandler.createResource(...)_.

Alternatively, as Lukas explains it:
{quote}
Dynamic resources are loaded via rfRes, and these have some base64 encoded parameter which turns into mappedResourceData.  When this parameter is not provided, no parametrization is done and it doesn't make sense to render dynamic resource (which is dynamic because of parametrization)
{quote}

> Hit miss for class loader cost performance problem in Richfaces 4.1.0.
> ----------------------------------------------------------------------
>
>                 Key: RF-11000
>                 URL: https://issues.jboss.org/browse/RF-11000
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: core
>    Affects Versions: 4.1.0.Milestone1
>         Environment: Linux, Java 6
>            Reporter: Pawel J.
>            Assignee: Brian Leathem
>            Priority: Trivial
>              Labels: patch_proposed
>             Fix For: 4.1.0.Milestone3
>
>         Attachments: ResourceFactoryImpl-patch.txt
>
>   Original Estimate: 1 hour
>  Remaining Estimate: 1 hour
>
> There are scenarios when resources are retrieved during no partial
> request processing:
> # JSF html renderer (such as ScriptRenderer from faces) require to
> know resources names to include them to html/head,
> # Resources content request.
> We have two types of resources: dynamic and static. Predefined dynamic
> resources (such as StateHolderResource) are read using class loader as
> they are java classes. Static resources are kept in resources folder
> as part of richfaces release jars (jquery.js, richfaces.js, etc).
> There is a special case with compiled css that is consider as dynamic
> resources but is not important in our case.
> The problem appears when we try to load static resources using dynamic
> loader. This make unnecessary lookup in java class loader space which
> cost time and of course we miss the call as static resources not
> exists there.
> Statistics that shows class loader hits for every richfaces/ajax4jsf no partial request that will be eliminated after patch:
> {code}
> Resource::jquery.js                  ::loading::timens:: 558000 ns::timems::0.558 ms::all::1.561496 sec
> Resource::richfaces.js               ::loading::timens:: 490000 ns::timems::0.490 ms::all::1.561986 sec
> Resource::richfaces-base-component.js::loading::timens:: 593000 ns::timems::0.593 ms::all::1.563672 sec
> Resource::richfaces-queue.js         ::loading::timens:: 672000 ns::timems::0.672 ms::all::1.564350 sec
> Resource::richfaces-event.js         ::loading::timens::3292000 ns::timems::3.292 ms::all::1.569386 sec
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the richfaces-issues mailing list