You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Chris Feldhacker <fe...@mchsi.com> on 2003/08/07 05:30:11 UTC

[lang] FastStringBuffer?

Maybe I'm missing something, or maybe this has been discussed before, but...

Is there a replacement for StringBuffer someplace, perhaps a
"FastStringBuffer" class?

I only ask because StringBuffers are used everywhere, even internally by the
JVM.  However, all of the methods on the StringBuffer class are
synchronized.  In my experience (and in looking through most of the lang
code), 99% of the time StringBuffer is only used as a method variable to
compose a message String; therefore, it is not possible for multiple threads
to access the same StringBuffer.  So, why not eliminate the synchronized
method calls and increase performance?



Re: [lang] FastStringBuffer?

Posted by Brian S O'Neill <br...@earthlink.net>.
The big advantage that the StringBuffer has is that it's defined in the
java.lang package. As a result, it has access to package private members of
the String class. Calling toString on StringBuffer does not allocate a copy
of the characters, but rather passes the reference to it's char[]. With any
FastStringBuffer class, a copy will be created. This will likely hurt
performance much more than removing synchronization.

----- Original Message ----- 
From: "Chris Feldhacker" <fe...@mchsi.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, August 06, 2003 08:30 P
Subject: [lang] FastStringBuffer?


> Maybe I'm missing something, or maybe this has been discussed before,
but...
>
> Is there a replacement for StringBuffer someplace, perhaps a
> "FastStringBuffer" class?
>
> I only ask because StringBuffers are used everywhere, even internally by
the
> JVM.  However, all of the methods on the StringBuffer class are
> synchronized.  In my experience (and in looking through most of the lang
> code), 99% of the time StringBuffer is only used as a method variable to
> compose a message String; therefore, it is not possible for multiple
threads
> to access the same StringBuffer.  So, why not eliminate the synchronized
> method calls and increase performance?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


Re: [lang] FastStringBuffer?

Posted by Brian S O'Neill <br...@earthlink.net>.
The big advantage that the StringBuffer has is that it's defined in the
java.lang package. As a result, it has access to package private members of
the String class. Calling toString on StringBuffer does not allocate a copy
of the characters, but rather passes the reference to it's char[]. With any
FastStringBuffer class, a copy will be created. This will likely hurt
performance much more than removing synchronization.

----- Original Message ----- 
From: "Chris Feldhacker" <fe...@mchsi.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, August 06, 2003 08:30 P
Subject: [lang] FastStringBuffer?


> Maybe I'm missing something, or maybe this has been discussed before,
but...
>
> Is there a replacement for StringBuffer someplace, perhaps a
> "FastStringBuffer" class?
>
> I only ask because StringBuffers are used everywhere, even internally by
the
> JVM.  However, all of the methods on the StringBuffer class are
> synchronized.  In my experience (and in looking through most of the lang
> code), 99% of the time StringBuffer is only used as a method variable to
> compose a message String; therefore, it is not possible for multiple
threads
> to access the same StringBuffer.  So, why not eliminate the synchronized
> method calls and increase performance?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


Re: [lang] FastStringBuffer?

Posted by Chris Feldhacker <fe...@mchsi.com>.
I'll certainly start coding something and do some testing.
I'll wait for some more opinions before I begin...


----- Original Message ----- 
From: "Henri Yandell" <ba...@generationjava.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, August 06, 2003 10:31 PM
Subject: Re: [lang] FastStringBuffer?



Sounds like a good idea to me. Worth knocking the code out, performing
some benchmarks and submitting. If you're offering to create such a thing
:)

As far as I know, it's not been discussed before.

Hen

On Wed, 6 Aug 2003, Chris Feldhacker wrote:

> Maybe I'm missing something, or maybe this has been discussed before,
but...
>
> Is there a replacement for StringBuffer someplace, perhaps a
> "FastStringBuffer" class?
>
> I only ask because StringBuffers are used everywhere, even internally by
the
> JVM.  However, all of the methods on the StringBuffer class are
> synchronized.  In my experience (and in looking through most of the lang
> code), 99% of the time StringBuffer is only used as a method variable to
> compose a message String; therefore, it is not possible for multiple
threads
> to access the same StringBuffer.  So, why not eliminate the synchronized
> method calls and increase performance?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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




Re: [lang] FastStringBuffer?

Posted by Chris Feldhacker <fe...@mchsi.com>.
I'll certainly start coding something and do some testing.
I'll wait for some more opinions before I begin...


----- Original Message ----- 
From: "Henri Yandell" <ba...@generationjava.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, August 06, 2003 10:31 PM
Subject: Re: [lang] FastStringBuffer?



Sounds like a good idea to me. Worth knocking the code out, performing
some benchmarks and submitting. If you're offering to create such a thing
:)

As far as I know, it's not been discussed before.

Hen

On Wed, 6 Aug 2003, Chris Feldhacker wrote:

> Maybe I'm missing something, or maybe this has been discussed before,
but...
>
> Is there a replacement for StringBuffer someplace, perhaps a
> "FastStringBuffer" class?
>
> I only ask because StringBuffers are used everywhere, even internally by
the
> JVM.  However, all of the methods on the StringBuffer class are
> synchronized.  In my experience (and in looking through most of the lang
> code), 99% of the time StringBuffer is only used as a method variable to
> compose a message String; therefore, it is not possible for multiple
threads
> to access the same StringBuffer.  So, why not eliminate the synchronized
> method calls and increase performance?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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




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


Re: [lang] FastStringBuffer?

Posted by Henri Yandell <ba...@generationjava.com>.
Sounds like a good idea to me. Worth knocking the code out, performing
some benchmarks and submitting. If you're offering to create such a thing
:)

As far as I know, it's not been discussed before.

Hen

On Wed, 6 Aug 2003, Chris Feldhacker wrote:

> Maybe I'm missing something, or maybe this has been discussed before, but...
>
> Is there a replacement for StringBuffer someplace, perhaps a
> "FastStringBuffer" class?
>
> I only ask because StringBuffers are used everywhere, even internally by the
> JVM.  However, all of the methods on the StringBuffer class are
> synchronized.  In my experience (and in looking through most of the lang
> code), 99% of the time StringBuffer is only used as a method variable to
> compose a message String; therefore, it is not possible for multiple threads
> to access the same StringBuffer.  So, why not eliminate the synchronized
> method calls and increase performance?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


Re: [lang] FastStringBuffer?

Posted by Henri Yandell <ba...@generationjava.com>.
Sounds like a good idea to me. Worth knocking the code out, performing
some benchmarks and submitting. If you're offering to create such a thing
:)

As far as I know, it's not been discussed before.

Hen

On Wed, 6 Aug 2003, Chris Feldhacker wrote:

> Maybe I'm missing something, or maybe this has been discussed before, but...
>
> Is there a replacement for StringBuffer someplace, perhaps a
> "FastStringBuffer" class?
>
> I only ask because StringBuffers are used everywhere, even internally by the
> JVM.  However, all of the methods on the StringBuffer class are
> synchronized.  In my experience (and in looking through most of the lang
> code), 99% of the time StringBuffer is only used as a method variable to
> compose a message String; therefore, it is not possible for multiple threads
> to access the same StringBuffer.  So, why not eliminate the synchronized
> method calls and increase performance?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>