[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13142358#comment-13142358
 ] 

Jon Moore commented on HTTPCLIENT-1137:
---------------------------------------

Hi Vasile,

Sorry to just be getting around to this now. Can you explain the reason for 
breaking out a ViaHeaderCache as a separate class? Why not just a HashMap? 
Since this is a true function (given a ProtocolVersion I always generate the 
same Via header), there's no need to put locks around this, as once the cache 
is populated it won't be modified, and even if there is a race condition 
between two threads trying to populate the cache, they'll both arrive at the 
same answer.

Would you like to revise your patch just to use a plain-old HashMap for this?

Jon
                
> The values for the Via header are created by httpclient-cache for each cached 
> and backend request
> -------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1137
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1137
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: Cache
>    Affects Versions: 4.1.2
>            Reporter: Alin Vasile
>            Priority: Trivial
>             Fix For: 4.2 Alpha2
>
>         Attachments: cached_via_header_vals.patch
>
>
> The Via header that gets generated and inserted by the caching layer is done 
> repeatedly in the HTTP conversation, even if the constructed string is 
> constant for each protocol version that is involved.
> The proposed patch constructs a map of generated values held in memory with 
> the associated ProtocolVersion as a key and uses read/write locks to access 
> the data. This  solution minimizes the time to generate such a value from 
> several milliseconds to 40-50 microseconds.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to