You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2005/12/23 20:18:27 UTC

[HttpComponents] Garbage and memory footprint optimization of HttpCore - aftermath

Folks,

As you know the HttpCore classes have been refactored heavily in an
attempt to reduce the amount of intermediate garbage generated when
parsing and transmitting HTTP messages and the overall memory
footprint. 

I have compared the performance of a snapshot dated 22/10/2005 against
the SVN trunk and found that the new code tends to perform better by
4-6% consistently across on all platforms and JREs I tested with. Not
really a lot but still an improvement

The memory consumption is a little harder to quantify, because the
benchmarking tool I have been using generates some garbage and thus
distorts the numbers. The hard fact is that the new code causes 2.5 - 3
times fewer GC runs executing the equal number of requests and tends to
consume 20% to 30% less heap memory. 

I do not claim these results being very accurate but they do seem to
support the general assumptions and conclusions

Merry Christmas to those who celebrate it, Happy Hacking to those who do
not

Oleg

====================================
WinXP SP2
====================================
> /data/src/apache.org/jakarta-httpcomponents/trunk/http-core
$ java -cp `cygpath -w -p
bin:/opt/libjava/apache.org/jakarta-commons/lib/commons-cli-1.0.jar`
org.apache.http.contrib.
benchmark.HttpBenchmark -n 50000 -k
http://localhost:8080/servlets-examples/servlet/RequestInfoExample
Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /servlets-examples/servlet/RequestInfoExample
Document Length:        689 bytes

Time taken for tests:   42.686 seconds
Complete requests:      50000
Failed requests:        0
Content transferred:    34450000 bytes
Requests per second:    1171.3442 [#/sec] (mean)
Time per request:       0.85372 [ms] (mean)

> /data/src/apache.org/jakarta-httpcomponents-22102005/trunk/http-core
$ java -cp `cygpath -w -p
bin:/opt/libjava/apache.org/jakarta-commons/lib/commons-cli-1.0.jar`
org.apache.http.contrib.
benchmark.HttpBenchmark -n 50000 -k
http://localhost:8080/servlets-examples/servlet/RequestInfoExample
Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /servlets-examples/servlet/RequestInfoExample
Document Length:        689 bytes

Time taken for tests:   45.14 seconds
Complete requests:      50000
Failed requests:        0
Content transferred:    34450000 bytes
Requests per second:    1107.665 [#/sec] (mean)
Time per request:       0.9028 [ms] (mean)

> /data/src/apache.org/jakarta-httpcomponents/trunk/http-core
$ java -verbose:gc -cp `cygpath -w -p
bin:/opt/libjava/apache.org/jakarta-commons/lib/commons-cli-1.0.jar`
org.apache.h
ttp.contrib.benchmark.HttpBenchmark -n 1000 -k
http://localhost:8080/servlets-examples/servlet/RequestInfoExample
[GC 511K->106K(1984K), 0.0042888 secs]
[GC 618K->203K(1984K), 0.0037913 secs]
[GC 715K->200K(1984K), 0.0016407 secs]
[GC 712K->200K(1984K), 0.0002877 secs]
[GC 712K->199K(1984K), 0.0002794 secs]
[GC 711K->199K(1984K), 0.0004637 secs]
Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /servlets-examples/servlet/RequestInfoExample
Document Length:        689 bytes

Time taken for tests:   1.234 seconds
Complete requests:      1000
Failed requests:        0
Content transferred:    689000 bytes
Requests per second:    810.3728 [#/sec] (mean)
Time per request:       1.234 [ms] (mean)

> /data/src/apache.org/jakarta-httpcomponents-22102005/trunk/http-core
$ java -verbose:gc -cp `cygpath -w -p
bin:/opt/libjava/apache.org/jakarta-commons/lib/commons-cli-1.0.jar`
org.apache.h
ttp.contrib.benchmark.HttpBenchmark -n 1000 -k
http://localhost:8080/servlets-examples/servlet/RequestInfoExample
[GC 511K->135K(1984K), 0.0047470 secs]
[GC 645K->244K(1984K), 0.0042450 secs]
[GC 756K->354K(1984K), 0.0040740 secs]
[GC 866K->436K(1984K), 0.0026956 secs]
[GC 948K->527K(1984K), 0.0026637 secs]
[GC 1039K->523K(1984K), 0.0005124 secs]
[GC 1035K->523K(1984K), 0.0004587 secs]
[GC 1035K->522K(1984K), 0.0006627 secs]
[GC 1034K->522K(1984K), 0.0006671 secs]
[GC 1034K->522K(1984K), 0.0005649 secs]
[GC 1033K->522K(1984K), 0.0003959 secs]
[GC 1034K->524K(1984K), 0.0003808 secs]
[GC 1036K->523K(1984K), 0.0003405 secs]
[GC 1035K->523K(1984K), 0.0003369 secs]
[GC 1035K->522K(1984K), 0.0003389 secs]
[GC 1034K->522K(1984K), 0.0003931 secs]
[GC 1034K->522K(1984K), 0.0003671 secs]
[GC 1033K->522K(1984K), 0.0003319 secs]
Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /servlets-examples/servlet/RequestInfoExample
Document Length:        689 bytes

Time taken for tests:   1.281 seconds
Complete requests:      1000
Failed requests:        0
Content transferred:    689000 bytes
Requests per second:    780.64014 [#/sec] (mean)
Time per request:       1.281 [ms] (mean)

====================================
Fedora Core 4 Linux 
====================================
> /home/oleg/src/apache.org/jakarta-httpcomponents/http-core

[oleg@localhost http-core]$ /opt/sun-jdk-1.5.0/bin/java -cp
bin:/usr/share/java/commons-cli.jar
org.apache.http.contrib.benchmark.HttpBenchmark -k -n 50000
http://localhost/docs/mod/quickreference.html
Server Software:        Apache/2.0.54 (Fedora)
Server Hostname:        localhost
Server Port:            80

Document Path:          /docs/mod/quickreference.html
Document Length:        96353 bytes

Time taken for tests:   40.714 seconds
Complete requests:      50000
Failed requests:        0
Content transferred:    4817650000 bytes
Requests per second:    1228.0787 [#/sec] (mean)
Time per request:       0.81428 [ms] (mean)

> /home/oleg/src/apache.org/jakarta-httpcomponents-20051022/http-core
[oleg@localhost http-core]$ /opt/sun-jdk-1.5.0/bin/java -cp
bin:/usr/share/java/commons-cli.jar
org.apache.http.contrib.benchmark.HttpBenchmark -k -n 50000
http://localhost/docs/mod/quickreference.html
Server Software:        Apache/2.0.54 (Fedora)
Server Hostname:        localhost
Server Port:            80

Document Path:          /docs/mod/quickreference.html
Document Length:        96353 bytes

Time taken for tests:   42.359 seconds
Complete requests:      50000
Failed requests:        0
Content transferred:    4817650000 bytes
Requests per second:    1180.3867 [#/sec] (mean)
Time per request:       0.84718 [ms] (mean)

> /home/oleg/src/apache.org/jakarta-httpcomponents/http-core

[oleg@localhost http-core]$ /opt/sun-jdk-1.5.0/bin/java -verbose:gc -cp
bin:/usr/share/java/commons-cli.jar
org.apache.http.contrib.benchmark.HttpBenchmark -k -n 1000
http://localhost/docs/mod/quickreference.html
[GC 512K->136K(1984K), 0.0028660 secs]
[GC 643K->161K(1984K), 0.0029380 secs]
[GC 673K->268K(1984K), 0.0014830 secs]
[GC 780K->338K(1984K), 0.0007430 secs]
[GC 850K->404K(1984K), 0.0005600 secs]
[GC 916K->474K(1984K), 0.0004010 secs]
[GC 963K->539K(1984K), 0.0004950 secs]
[GC 1051K->584K(1984K), 0.0003700 secs]
[GC 1096K->696K(1984K), 0.0006680 secs]
[GC 1208K->762K(1984K), 0.0003860 secs]
[GC 1274K->832K(1984K), 0.0004240 secs]
[GC 1344K->897K(1984K), 0.0003880 secs]
[GC 1409K->964K(1984K), 0.0004290 secs]
Server Software:        Apache/2.0.54 (Fedora)
Server Hostname:        localhost
Server Port:            80

Document Path:          /docs/mod/quickreference.html
Document Length:        96353 bytes

Time taken for tests:   1.166 seconds
Complete requests:      1000
Failed requests:        0
Content transferred:    96353000 bytes
Requests per second:    857.63293 [#/sec] (mean)
Time per request:       1.166 [ms] (mean)

> /home/oleg/src/apache.org/jakarta-httpcomponents-20051022/http-core

[oleg@localhost http-core]$ /opt/sun-jdk-1.5.0/bin/java -verbose:gc -cp
bin:/usr/share/java/commons-cli.jar
org.apache.http.contrib.benchmark.HttpBenchmark -k -n 1000
http://localhost/docs/mod/quickreference.html
[GC 512K->138K(1984K), 0.0026370 secs]
[GC 650K->156K(1984K), 0.0022690 secs]
[GC 668K->269K(1984K), 0.0014760 secs]
[GC 781K->270K(1984K), 0.0007390 secs]
[GC 782K->381K(1984K), 0.0004650 secs]
[GC 893K->381K(1984K), 0.0004980 secs]
[GC 885K->446K(1984K), 0.0004090 secs]
[GC 958K->490K(1984K), 0.0003590 secs]
[GC 1002K->492K(1984K), 0.0002890 secs]
[GC 1004K->604K(1984K), 0.0004220 secs]
[GC 1115K->600K(1984K), 0.0005070 secs]
[GC 1112K->711K(1984K), 0.0004780 secs]
[GC 1223K->713K(1984K), 0.0003360 secs]
[GC 1225K->821K(1984K), 0.0005660 secs]
[GC 1333K->826K(1984K), 0.0003070 secs]
[GC 1337K->821K(1984K), 0.0002870 secs]
[GC 1332K->907K(1984K), 0.0004040 secs]
[GC 1419K->907K(1984K), 0.0002740 secs]
[GC 1419K->995K(1984K), 0.0005550 secs]
[GC 1507K->992K(1984K), 0.0003420 secs]
[GC 1504K->1103K(1984K), 0.0004020 secs]
[GC 1615K->1103K(1984K), 0.0002620 secs]
[GC 1615K->1193K(1984K), 0.0004040 secs]
[GC 1705K->1189K(1984K), 0.0003120 secs]
Server Software:        Apache/2.0.54 (Fedora)
Server Hostname:        localhost
Server Port:            80

Document Path:          /docs/mod/quickreference.html
Document Length:        96353 bytes

Time taken for tests:   1.36 seconds
Complete requests:      1000
Failed requests:        0
Content transferred:    96353000 bytes
Requests per second:    735.2941 [#/sec] (mean)
Time per request:       1.36 [ms] (mean)



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: [HttpComponents] Garbage and memory footprint optimization of HttpCore - aftermath

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, Dec 28, 2005 at 05:15:01PM +0100, Roland Weber wrote:
> Hi Oleg,
> 
> thanks for putting in all that effort. 2.5 to 3 times less GC
> sounds like a big improvement to me. Getting that with a speed-up
> is even better!
> 

Small thing. More work is still needed. We can't expect the users to
migrate off HttpClient 3.0 only because of supposedly better API. I
believe a better performance and a significantly smaller memory 
footprint can be a fairly strong incentive to consider
HttpComponents/HttpClient 4.0

> cheers,
>   Roland
> 
> PS: I hope you'll also celebrate some kind of year-end festivity,
>     or else christmas scheduled by the Julian calendar ;-)
> 

I am not really into celebrating Christmas neither on Dec. 25th nor on Jan
7th, but I usually enjoy drinking myself senseless on Dec 31st ;-)

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: [HttpComponents] Garbage and memory footprint optimization of HttpCore - aftermath

Posted by Roland Weber <ht...@dubioso.net>.
Hi Oleg,

thanks for putting in all that effort. 2.5 to 3 times less GC
sounds like a big improvement to me. Getting that with a speed-up
is even better!

cheers,
  Roland

PS: I hope you'll also celebrate some kind of year-end festivity,
    or else christmas scheduled by the Julian calendar ;-)

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org