HTTPCLIENT-895: Log object lookups by short lived components impair performance

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@885900 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2009-12-01 20:01:44 +00:00
parent 900c9c0966
commit 9f580578d9
4 changed files with 21 additions and 11 deletions

View File

@ -15,6 +15,9 @@ functionality improvements and new features.
encoding is not enabled per default in order to avoid conflicts with
already existing custom content encoding solutions.
* 5 to 10% performance increase due to elimination of unnecessary Log object
lookups by short-lived components.
Please note all methods and classes added in this release and marked as
4.1 are API unstable and can change in the future 4.1 ALPHA releases.
@ -69,9 +72,16 @@ This is a bug fix release that addresses a number of issues discovered since
the previous stable release. None of the fixed bugs is considered critical.
Most notably this release eliminates eliminates dependency on JCIP annotations.
This release is also expected to improve performance by 5 to 10% due to
elimination of unnecessary Log object lookups by short-lived components.
Changelog
-------------------
* [HTTPCLIENT-895] Eliminated Log lookups in short lived objects impairing
performance.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-885] URLEncodedUtils now correctly parses form-url-encoded
entities that specify a charset.
Contributed by Oleg Kalnichevski <olegk at apache.org>

View File

@ -738,6 +738,7 @@ public abstract class AbstractHttpClient implements HttpClient {
final UserTokenHandler stateHandler,
final HttpParams params) {
return new DefaultRequestDirector(
log,
requestExec,
conman,
reustrat,

View File

@ -29,8 +29,6 @@ package org.apache.http.impl.client;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.params.HttpParams;
import org.apache.http.params.AbstractHttpParams;
@ -73,8 +71,6 @@ import org.apache.http.params.AbstractHttpParams;
@NotThreadSafe
public class ClientParamsStack extends AbstractHttpParams {
private final Log log = LogFactory.getLog(getClass());
/** The application parameter collection, or <code>null</code>. */
protected final HttpParams applicationParams;
@ -211,10 +207,6 @@ public class ClientParamsStack extends AbstractHttpParams {
if ((result == null) && (applicationParams != null)) {
result = applicationParams.getParameter(name);
}
if (this.log.isDebugEnabled() && result != null) {
this.log.debug("'" + name + "': " + result);
}
return result;
}

View File

@ -135,7 +135,7 @@ import org.apache.http.protocol.HttpRequestExecutor;
@NotThreadSafe // e.g. managedConn
public class DefaultRequestDirector implements RequestDirector {
private final Log log = LogFactory.getLog(getClass());
private final Log log;
/** The connection manager. */
protected final ClientConnectionManager connManager;
@ -204,7 +204,8 @@ public class DefaultRequestDirector implements RequestDirector {
final AuthenticationHandler proxyAuthHandler,
final UserTokenHandler userTokenHandler,
final HttpParams params) {
this(requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
this(LogFactory.getLog(DefaultRequestDirector.class),
requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
new DefaultRedirectStrategyAdaptor(redirectHandler),
targetAuthHandler, proxyAuthHandler, userTokenHandler, params);
}
@ -214,6 +215,7 @@ public class DefaultRequestDirector implements RequestDirector {
* @since 4.1
*/
public DefaultRequestDirector(
final Log log,
final HttpRequestExecutor requestExec,
final ClientConnectionManager conman,
final ConnectionReuseStrategy reustrat,
@ -227,6 +229,10 @@ public class DefaultRequestDirector implements RequestDirector {
final UserTokenHandler userTokenHandler,
final HttpParams params) {
if (log == null) {
throw new IllegalArgumentException
("Log may not be null.");
}
if (requestExec == null) {
throw new IllegalArgumentException
("Request executor may not be null.");
@ -275,6 +281,7 @@ public class DefaultRequestDirector implements RequestDirector {
throw new IllegalArgumentException
("HTTP parameters may not be null");
}
this.log = log;
this.requestExec = requestExec;
this.connManager = conman;
this.reuseStrategy = reustrat;