You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2005/12/04 14:59:38 UTC

svn commit: r353848 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/io/ java/org/apache/http/util/ test/org/apache/http/util/

Author: olegk
Date: Sun Dec  4 05:59:25 2005
New Revision: 353848

URL: http://svn.apache.org/viewcvs?rev=353848&view=rev
Log:
Provided a utility class to parse unsigned integers from a char array buffer without creating intermediate objects (garbage)

Added:
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java   (with props)
    jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java   (with props)
Modified:
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/ChunkedInputStream.java
    jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestAllUtil.java

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java?rev=353848&r1=353847&r2=353848&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java Sun Dec  4 05:59:25 2005
@@ -30,6 +30,7 @@
 package org.apache.http;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.util.NumUtils;
 
 /**
  *  <p>HTTP version, as specified in RFC 2616.</p>
@@ -255,13 +256,13 @@
                         buffer.substring(indexFrom, indexTo));
             }
             try {
-                major = Integer.parseInt(buffer.substringTrimmed(i, period)); 
+                major = NumUtils.parseUnsignedInt(buffer, i, period); 
             } catch (NumberFormatException e) {
                 throw new ProtocolException("Invalid HTTP major version number: " + 
                         buffer.substring(indexFrom, indexTo));
             }
             try {
-                minor = Integer.parseInt(buffer.substringTrimmed(period + 1, indexTo)); 
+                minor = NumUtils.parseUnsignedInt(buffer, period + 1, indexTo); 
             } catch (NumberFormatException e) {
                 throw new ProtocolException("Invalid HTTP minor version number: " + 
                         buffer.substring(indexFrom, indexTo));

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/ChunkedInputStream.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/ChunkedInputStream.java?rev=353848&r1=353847&r2=353848&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/ChunkedInputStream.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/ChunkedInputStream.java Sun Dec  4 05:59:25 2005
@@ -35,6 +35,7 @@
 import org.apache.http.Header;
 import org.apache.http.HttpException;
 import org.apache.http.util.ExceptionUtils;
+import org.apache.http.util.NumUtils;
 
 /**
  * <p>This class implements chunked transfer coding as described in the 
@@ -274,9 +275,8 @@
         if (separator < 0) {
             separator = this.buffer.length();
         }
-        String s = this.buffer.substringTrimmed(0, separator);
         try {
-            return Integer.parseInt(s, 16);
+            return NumUtils.parseUnsignedHexInt(this.buffer, 0, separator);
         } catch (NumberFormatException e) {
             throw new MalformedChunkCodingException("Bad chunk header");
         }

Added: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java?rev=353848&view=auto
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java (added)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java Sun Dec  4 05:59:25 2005
@@ -0,0 +1,83 @@
+package org.apache.http.util;
+
+import org.apache.http.io.CharArrayBuffer;
+
+public class NumUtils {
+
+    private NumUtils() {
+    }
+    
+    public static int parseUnsignedInt(
+            final CharArrayBuffer buffer, final int indexFrom, final int indexTo,
+            int radix) 
+            throws NumberFormatException {
+        if (buffer == null) {
+            throw new IllegalArgumentException("Char array buffer may not be null");
+        }
+        if (indexFrom < 0) {
+            throw new IndexOutOfBoundsException();
+        }
+        if (indexTo > buffer.length()) {
+            throw new IndexOutOfBoundsException();
+        }
+        if (indexFrom > indexTo) {
+            throw new IndexOutOfBoundsException();
+        }
+        if (radix < Character.MIN_RADIX) {
+            throw new IllegalArgumentException ("Radix may not be less than Character.MIN_RADIX");
+        }
+        if (radix > Character.MAX_RADIX) {
+            throw new IllegalArgumentException ("Radix may not be greater than Character.MAX_RADIX");
+        }
+        int i1 = indexFrom;
+        int i2 = indexTo;
+        while (i1 < indexTo && Character.isWhitespace(buffer.charAt(i1))) {
+            i1++;
+        }
+        while (i2 > i1 && Character.isWhitespace(buffer.charAt(i2 - 1))) {
+            i2--;
+        }
+        if (i1 == i2) {
+            throw new NumberFormatException("Empty input");
+        }
+        int digit = Character.digit(buffer.charAt(i1++), radix);        
+        if (digit < 0) {
+            throw new NumberFormatException("Invalid unsigned integer: " + 
+                    buffer.substring(indexFrom, indexTo));
+        }
+        int num = digit;
+        while (i1 < i2) {
+            digit = Character.digit(buffer.charAt(i1++), radix);        
+            if (digit < 0) {
+                throw new NumberFormatException("Invalid unsigned integer: " + 
+                        buffer.substring(indexFrom, indexTo));
+            }
+            num *= radix;
+            num += digit;
+            if (num < 0) {
+                throw new NumberFormatException("Unsigned integer too large: " + 
+                        buffer.substring(indexFrom, indexTo));
+            }
+        }
+        return num;
+    }
+
+    public static int parseUnsignedInt(
+            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) 
+            throws NumberFormatException {
+        return parseUnsignedInt(buffer, indexFrom, indexTo, 10);
+    }
+    
+    public static int parseUnsignedHexInt(
+            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) 
+            throws NumberFormatException {
+        return parseUnsignedInt(buffer, indexFrom, indexTo, 16);
+    }
+    
+    public static int parseUnsignedBinInt(
+            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) 
+            throws NumberFormatException {
+        return parseUnsignedInt(buffer, indexFrom, indexTo, 2);
+    }
+    
+}

Propchange: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestAllUtil.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestAllUtil.java?rev=353848&r1=353847&r2=353848&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestAllUtil.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestAllUtil.java Sun Dec  4 05:59:25 2005
@@ -43,6 +43,7 @@
         suite.addTest(TestEncodingUtils.suite());
         suite.addTest(TestDateUtils.suite());
         suite.addTest(TestEntityUtils.suite());
+        suite.addTest(TestNumUtils.suite());
         return suite;
     }
 

Added: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java?rev=353848&view=auto
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java (added)
+++ jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java Sun Dec  4 05:59:25 2005
@@ -0,0 +1,218 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.util;
+
+import org.apache.http.io.CharArrayBuffer;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit tests for {@link ParameterFormatter}.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public class TestNumUtils extends TestCase {
+
+    // ------------------------------------------------------------ Constructor
+    public TestNumUtils(String testName) {
+        super(testName);
+    }
+
+    // ------------------------------------------------------------------- Main
+    public static void main(String args[]) {
+        String[] testCaseName = { TestNumUtils.class.getName() };
+        junit.textui.TestRunner.main(testCaseName);
+    }
+
+    // ------------------------------------------------------- TestCase Methods
+
+    public static Test suite() {
+        return new TestSuite(TestNumUtils.class);
+    }
+
+    public void testBasicParseUnsignedInt() throws Exception {
+        CharArrayBuffer buffer = new CharArrayBuffer(16);
+        buffer.append("  100 ");
+        int num = NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+        assertEquals(100, num);
+
+        buffer.clear();
+        buffer.append("132");
+        num = NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+        assertEquals(132, num);
+
+        buffer.clear();
+        buffer.append("010101  ");
+        num = NumUtils.parseUnsignedBinInt(buffer, 0, buffer.length());
+        assertEquals(21, num);
+
+        buffer.clear();
+        buffer.append("FFFF");
+        num = NumUtils.parseUnsignedHexInt(buffer, 0, buffer.length());
+        assertEquals(65535, num);
+
+        buffer.clear();
+        buffer.append("aAaA");
+        num = NumUtils.parseUnsignedHexInt(buffer, 0, buffer.length());
+        assertEquals(43690, num);
+
+        buffer.clear();
+        buffer.append("0");
+        num = NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+        assertEquals(0, num);
+    }
+
+    public void testInvalidInputParseUnsignedInt() throws Exception {
+        CharArrayBuffer buffer = new CharArrayBuffer(16);
+        buffer.append("   ");
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+            fail("NumberFormatException should have been thrown");
+        } catch (NumberFormatException ex) {
+            // expected
+        }
+        buffer.clear();
+        buffer.append("");
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+            fail("NumberFormatException should have been thrown");
+        } catch (NumberFormatException ex) {
+            // expected
+        }
+        buffer.clear();
+        buffer.append("1000");
+        try {
+            NumUtils.parseUnsignedInt(null, 0, 0);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        try {
+            NumUtils.parseUnsignedInt(buffer, -1, 0);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IndexOutOfBoundsException ex) {
+            // expected
+        }
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, 1000);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IndexOutOfBoundsException ex) {
+            // expected
+        }
+        try {
+            NumUtils.parseUnsignedInt(buffer, 2, 1);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IndexOutOfBoundsException ex) {
+            // expected
+        }
+    }
+
+    public void testInvalidRadixParseUnsignedInt() throws Exception {
+        CharArrayBuffer buffer = new CharArrayBuffer(16);
+        buffer.append("10000");
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length(), 1);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length(),
+                    Character.MAX_RADIX + 1);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
+    
+    public void testInvalidNumberParseUnsignedInt() throws Exception {
+        CharArrayBuffer buffer = new CharArrayBuffer(16);
+        buffer.append("aa");
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+            fail("NumberFormatException should have been thrown");
+        } catch (NumberFormatException ex) {
+            // expected
+        }
+        buffer.clear();
+        buffer.append("3");
+        try {
+            NumUtils.parseUnsignedBinInt(buffer, 0, buffer.length());
+            fail("NumberFormatException should have been thrown");
+        } catch (NumberFormatException ex) {
+            // expected
+        }
+        buffer.clear();
+        buffer.append("-3");
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+            fail("NumberFormatException should have been thrown");
+        } catch (NumberFormatException ex) {
+            // expected
+        }
+        buffer.clear();
+        buffer.append("3 3");
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+            fail("NumberFormatException should have been thrown");
+        } catch (NumberFormatException ex) {
+            // expected
+        }
+    }
+
+    public void testParseUnsignedIntLargeNumbers() throws Exception {
+        CharArrayBuffer buffer = new CharArrayBuffer(16);
+        buffer.append(Integer.toString(Integer.MAX_VALUE));
+        int num = NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+        assertEquals(Integer.MAX_VALUE, num);
+
+        buffer.clear();
+        buffer.append(Integer.toBinaryString(Integer.MAX_VALUE));
+        num = NumUtils.parseUnsignedBinInt(buffer, 0, buffer.length());
+        assertEquals(Integer.MAX_VALUE, num);
+        
+        buffer.clear();
+        buffer.append(Integer.toHexString(Integer.MAX_VALUE));
+        num = NumUtils.parseUnsignedHexInt(buffer, 0, buffer.length());
+        assertEquals(Integer.MAX_VALUE, num);
+    }
+    
+    public void testParseUnsignedIntLargeNumberOverflow() throws Exception {
+        CharArrayBuffer buffer = new CharArrayBuffer(16);
+        buffer.append(Long.toString((long)Integer.MAX_VALUE + 1));
+        try {
+            NumUtils.parseUnsignedInt(buffer, 0, buffer.length());
+            fail("NumberFormatException should have been thrown");
+        } catch (NumberFormatException ex) {
+            // expected
+        }
+    }
+}

Propchange: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/trunk/http-core/src/test/org/apache/http/util/TestNumUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Re: svn commit: r353848 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/io/ java/org/apache/http/util/ test/org/apache/http/util/

Posted by Ortwin Glück <od...@odi.ch>.

Oleg Kalnichevski wrote:
> Odi et al,
> 
> I rolled back the changes and reverted to standard Integer#parseInt for
> parsing numbers in HTTP messages
> 
> Oleg

:-)

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


Re: svn commit: r353848 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/io/ java/org/apache/http/util/ test/org/apache/http/util/

Posted by Oleg Kalnichevski <ol...@apache.org>.
Odi et al,

I rolled back the changes and reverted to standard Integer#parseInt for
parsing numbers in HTTP messages

Oleg


On Mon, 2005-12-05 at 10:39 +0100, Oleg Kalnichevski wrote:
> On Mon, Dec 05, 2005 at 10:33:50AM +0100, Ortwin Gl?ck wr
>
> ote:
> > Oleg,
> > 
> > All right. I am glad you are not doing this unconciously. It will be 
> > interesting to see benchmark results. My guess is that you should not 
> > see a significant performance gain (I expect less than 5%). The modern 
> > GC algorithms in the Sun VMs are very good for short-lived Objects. To 
> > see a difference you probably have to run HttpClient with multiple 
> > threads under a high load for a long time, so that enough garbage is 
> > produced and the GC actually has to run. The number of CPUs will have an 
> > effect as well.
> > 
> > Odi
> > 
> 
> Odi,
> I am planning to write a report on the code refactoring I have done in
> the past two weeks. Anyways, those changes were not made completely out
> of the blue. However, I do admit some of them can be seen as
> controversial. Give me some time to write it all up and and let us talk
> things over
> 
> Oleg
> 
> > Oleg Kalnichevski wrote:
> > >Odi,
> > >
> > >I am aware this is a questionable decision. The primary motivating
> > >factor was to implement zero (or almost zero) garbage HTTP request
> > >parsing and see if that results in any significant performance gains. 
> > >
> > >I have run a few tests yesterday and so far the impact of reduced
> > >generation of intermediate objects when parsing HTTP requests seems
> > >minimal for JRE 1.5. So, I am fully prepared to revert this change if 
> > >there are no tangble performance gains for older JREs. I would like 
> > >to experiment a little further before such a decision is made
> > >
> > >Oleg
> > 
> > 
> > ---------------------------------------------------------------------
> > 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
> 
> 


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


Re: svn commit: r353848 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/io/ java/org/apache/http/util/ test/org/apache/http/util/

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, Dec 05, 2005 at 10:33:50AM +0100, Ortwin Gl?ck wrote:
> Oleg,
> 
> All right. I am glad you are not doing this unconciously. It will be 
> interesting to see benchmark results. My guess is that you should not 
> see a significant performance gain (I expect less than 5%). The modern 
> GC algorithms in the Sun VMs are very good for short-lived Objects. To 
> see a difference you probably have to run HttpClient with multiple 
> threads under a high load for a long time, so that enough garbage is 
> produced and the GC actually has to run. The number of CPUs will have an 
> effect as well.
> 
> Odi
> 

Odi,
I am planning to write a report on the code refactoring I have done in
the past two weeks. Anyways, those changes were not made completely out
of the blue. However, I do admit some of them can be seen as
controversial. Give me some time to write it all up and and let us talk
things over

Oleg

> Oleg Kalnichevski wrote:
> >Odi,
> >
> >I am aware this is a questionable decision. The primary motivating
> >factor was to implement zero (or almost zero) garbage HTTP request
> >parsing and see if that results in any significant performance gains. 
> >
> >I have run a few tests yesterday and so far the impact of reduced
> >generation of intermediate objects when parsing HTTP requests seems
> >minimal for JRE 1.5. So, I am fully prepared to revert this change if 
> >there are no tangble performance gains for older JREs. I would like 
> >to experiment a little further before such a decision is made
> >
> >Oleg
> 
> 
> ---------------------------------------------------------------------
> 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: svn commit: r353848 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/io/ java/org/apache/http/util/ test/org/apache/http/util/

Posted by Ortwin Glück <od...@odi.ch>.
Oleg,

All right. I am glad you are not doing this unconciously. It will be 
interesting to see benchmark results. My guess is that you should not 
see a significant performance gain (I expect less than 5%). The modern 
GC algorithms in the Sun VMs are very good for short-lived Objects. To 
see a difference you probably have to run HttpClient with multiple 
threads under a high load for a long time, so that enough garbage is 
produced and the GC actually has to run. The number of CPUs will have an 
effect as well.

Odi

Oleg Kalnichevski wrote:
> Odi,
> 
> I am aware this is a questionable decision. The primary motivating
> factor was to implement zero (or almost zero) garbage HTTP request
> parsing and see if that results in any significant performance gains. 
> 
> I have run a few tests yesterday and so far the impact of reduced
> generation of intermediate objects when parsing HTTP requests seems
> minimal for JRE 1.5. So, I am fully prepared to revert this change if 
> there are no tangble performance gains for older JREs. I would like 
> to experiment a little further before such a decision is made
> 
> Oleg


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


Re: svn commit: r353848 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/io/ java/org/apache/http/util/ test/org/apache/http/util/

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, Dec 05, 2005 at 09:43:01AM +0100, Ortwin Gl??ck wrote:
> Oleg,
> 
> Is it really worth implementing your own number parsing? I don't think 
> Integer.parseInt will kill us, honestly.
> 
> Odi
> 

Odi,

I am aware this is a questionable decision. The primary motivating
factor was to implement zero (or almost zero) garbage HTTP request
parsing and see if that results in any significant performance gains. 

I have run a few tests yesterday and so far the impact of reduced
generation of intermediate objects when parsing HTTP requests seems
minimal for JRE 1.5. So, I am fully prepared to revert this change if 
there are no tangble performance gains for older JREs. I would like 
to experiment a little further before such a decision is made

Oleg


> olegk@apache.org wrote:
> >Provided a utility class to parse unsigned integers from a char array
> >buffer without creating intermediate objects (garbage)
> 
> 
> ---------------------------------------------------------------------
> 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: svn commit: r353848 - in /jakarta/httpcomponents/trunk/http-core/src: java/org/apache/http/ java/org/apache/http/io/ java/org/apache/http/util/ test/org/apache/http/util/

Posted by Ortwin Glück <od...@odi.ch>.
Oleg,

Is it really worth implementing your own number parsing? I don't think 
Integer.parseInt will kill us, honestly.

Odi

olegk@apache.org wrote:
> Provided a utility class to parse unsigned integers from a char array
> buffer without creating intermediate objects (garbage)


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