Performance Issue UrlMapping.getPatternParser()

Splash Forums PrettyFaces Users Performance Issue UrlMapping.getPatternParser()

Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  Christian Kaltepoth 6 years, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17995

    Frank Caputo
    Participant

    Hi,

    I’ve found a performance issue:

    UrlMapping.getPatternParser() is called quite often. This should be no problem if the pattern parser was cached. But the dirty-flag is never set to false, so a new pattern parser will be created for every call to UrlMapping.getPatternParser().

    If I had an idea, when to set the dirty flag to false, I could fix it.

    Ciao Frank

    #21170

    Hey Frank!

    Thank you very much for pointing us to this issue. This is definitively a bug. A just committed a fix for it:

    https://github.com/ocpsoft/prettyfaces/commit/3c42041816f275db556a611aad03f2ffb8dbe324

    Could you perhaps give the latest snapshots a try (3.3.1-SNAPSHOT)? They should be automatically deployed to our repository in about 20 minutes. You will find all the details you need to include the snapshots in your project here:

    https://github.com/ocpsoft/prettyfaces/wiki/Snapshots

    And thanks again for bringing this up! We are always happy to get any kind of feedback! :)

    Christian

    #21171

    Frank Caputo
    Participant

    I will check it tomorrow or next week. I will do further performance measuring, since we are building a high performance website.

    Ciao Frank

    #21172

    Awesome! It would be great if you could tell us about the results! :)

    #21173

    Frank Caputo
    Participant

    It is much better now, but URLPatternParser still seems to be created to often:

    com.ocpsoft.pretty.faces.beans.ExtractedValuesURLBuilder#buildURL

    com.ocpsoft.pretty.faces.util.PrettyURLBuilder#build

    URLPatternParser seems to be threadsafe, so you could simply call com.ocpsoft.pretty.faces.config.mapping.UrlMapping#getPatternParser()

    Another point is the use of String.split, matches etc.:

    com.ocpsoft.pretty.faces.url.URL#URL

    com.ocpsoft.pretty.faces.url.QueryString#addParameters

    com.ocpsoft.pretty.PrettyContext#PrettyContext

    com.ocpsoft.pretty.PrettyFilter#doFilter

    These methods always create new Pattern instances. If you have a regex, try to compile it and reuse it. If you don’t have a regex, just use one of the org.apache.commons.lang.StringUtils methods. Or simply String.indexOf(…).

    Hope this helps.

    Ciao Frank

    PS: to check if the sessionid is in the url, just use javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL

    #21174

    Thanks for this analysis and your feedback. I really appreciate this.

    I’ll try to find some time to take a deeper look at this.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Comments are closed.