You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by sebb <se...@gmail.com> on 2008/02/22 15:39:58 UTC
Re: svn commit: r630209 - /httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
On 22/02/2008, olegk@apache.org <ol...@apache.org> wrote:
> Author: olegk
> Date: Fri Feb 22 05:57:51 2008
> New Revision: 630209
>
> URL: http://svn.apache.org/viewvc?rev=630209&view=rev
> Log:
> HTTPCORE-148: Transfer as many bytes as possible at a time. This fix improves performance significantly (up to 5x)
>
What if the user wants to limit the memory that is used?
Is there a way to override this? If not, perhaps there should be?
> Modified:
> httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
>
> Modified: httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java?rev=630209&r1=630208&r2=630209&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java (original)
> +++ httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java Fri Feb 22 05:57:51 2008
> @@ -95,9 +95,11 @@
>
> long transferred;
> if(useFileChannels && encoder instanceof FileContentEncoder) {
> - transferred = ((FileContentEncoder)encoder).transfer(fileChannel, idx, 100);
> + transferred = ((FileContentEncoder)encoder)
> + .transfer(fileChannel, idx, Long.MAX_VALUE);
> } else {
> - transferred = fileChannel.transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> + transferred = fileChannel.
> + transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> }
>
> if(transferred > 0)
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: svn commit: r630209
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2008-02-22 at 10:02 -0500, Sam Berlin wrote:
> I don't think increasing the amount transferred actually increases the
> memory used -- the data's transferred directly from disk to socket,
> with what should be no temporary buffer in-between. The '100' value
> left there (as opposed to MAX_VALUE) was a holdover from while I was
> testing to make sure chunked encoding worked (and I forgot to fully
> revert the changes).
>
> Sam
>
I agree. As there is no intermediate memory buffer involved, I
personally do not see a single legitimate reason for using any other
value but maximum possible. In case one really wants to transfer data in
smaller chunks, one can always provide a custom ProducingNHttpEntity
impl.
Oleg
> On Fri, Feb 22, 2008 at 9:39 AM, sebb <se...@gmail.com> wrote:
> > On 22/02/2008, olegk@apache.org <ol...@apache.org> wrote:
> > > Author: olegk
> > > Date: Fri Feb 22 05:57:51 2008
> > > New Revision: 630209
> > >
> > > URL: http://svn.apache.org/viewvc?rev=630209&view=rev
> > > Log:
> > > HTTPCORE-148: Transfer as many bytes as possible at a time. This fix improves performance significantly (up to 5x)
> > >
> >
> > What if the user wants to limit the memory that is used?
> >
> > Is there a way to override this? If not, perhaps there should be?
> >
> > > Modified:
> > > httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
> > >
> > > Modified: httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
> > > URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java?rev=630209&r1=630208&r2=630209&view=diff
> > > ==============================================================================
> > > --- httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java (original)
> > > +++ httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java Fri Feb 22 05:57:51 2008
> > > @@ -95,9 +95,11 @@
> > >
> > > long transferred;
> > > if(useFileChannels && encoder instanceof FileContentEncoder) {
> > > - transferred = ((FileContentEncoder)encoder).transfer(fileChannel, idx, 100);
> > > + transferred = ((FileContentEncoder)encoder)
> > > + .transfer(fileChannel, idx, Long.MAX_VALUE);
> > > } else {
> > > - transferred = fileChannel.transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> > > + transferred = fileChannel.
> > > + transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> > > }
> > >
> > > if(transferred > 0)
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> > For additional commands, e-mail: dev-help@hc.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: svn commit: r630209 - /httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
Posted by sebb <se...@gmail.com>.
On 22/02/2008, Sam Berlin <sb...@gmail.com> wrote:
> I don't think increasing the amount transferred actually increases the
> memory used -- the data's transferred directly from disk to socket,
> with what should be no temporary buffer in-between. The '100' value
OK, understood.
> left there (as opposed to MAX_VALUE) was a holdover from while I was
> testing to make sure chunked encoding worked (and I forgot to fully
> revert the changes).
There should probably be a checkstyle rule that finds raw numbers and
warns about them ;-)
> Sam
>
>
> On Fri, Feb 22, 2008 at 9:39 AM, sebb <se...@gmail.com> wrote:
> > On 22/02/2008, olegk@apache.org <ol...@apache.org> wrote:
> > > Author: olegk
> > > Date: Fri Feb 22 05:57:51 2008
> > > New Revision: 630209
> > >
> > > URL: http://svn.apache.org/viewvc?rev=630209&view=rev
> > > Log:
> > > HTTPCORE-148: Transfer as many bytes as possible at a time. This fix improves performance significantly (up to 5x)
> > >
> >
> > What if the user wants to limit the memory that is used?
> >
> > Is there a way to override this? If not, perhaps there should be?
> >
> > > Modified:
> > > httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
> > >
> > > Modified: httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
> > > URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java?rev=630209&r1=630208&r2=630209&view=diff
> > > ==============================================================================
> > > --- httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java (original)
> > > +++ httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java Fri Feb 22 05:57:51 2008
> > > @@ -95,9 +95,11 @@
> > >
> > > long transferred;
> > > if(useFileChannels && encoder instanceof FileContentEncoder) {
> > > - transferred = ((FileContentEncoder)encoder).transfer(fileChannel, idx, 100);
> > > + transferred = ((FileContentEncoder)encoder)
> > > + .transfer(fileChannel, idx, Long.MAX_VALUE);
> > > } else {
> > > - transferred = fileChannel.transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> > > + transferred = fileChannel.
> > > + transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> > > }
> > >
> > > if(transferred > 0)
> > >
> > >
> > >
> >
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> > For additional commands, e-mail: dev-help@hc.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: svn commit: r630209 - /httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
Posted by Sam Berlin <sb...@gmail.com>.
I don't think increasing the amount transferred actually increases the
memory used -- the data's transferred directly from disk to socket,
with what should be no temporary buffer in-between. The '100' value
left there (as opposed to MAX_VALUE) was a holdover from while I was
testing to make sure chunked encoding worked (and I forgot to fully
revert the changes).
Sam
On Fri, Feb 22, 2008 at 9:39 AM, sebb <se...@gmail.com> wrote:
> On 22/02/2008, olegk@apache.org <ol...@apache.org> wrote:
> > Author: olegk
> > Date: Fri Feb 22 05:57:51 2008
> > New Revision: 630209
> >
> > URL: http://svn.apache.org/viewvc?rev=630209&view=rev
> > Log:
> > HTTPCORE-148: Transfer as many bytes as possible at a time. This fix improves performance significantly (up to 5x)
> >
>
> What if the user wants to limit the memory that is used?
>
> Is there a way to override this? If not, perhaps there should be?
>
> > Modified:
> > httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
> >
> > Modified: httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
> > URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java?rev=630209&r1=630208&r2=630209&view=diff
> > ==============================================================================
> > --- httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java (original)
> > +++ httpcomponents/httpcore/branches/limewire_contrib/module-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java Fri Feb 22 05:57:51 2008
> > @@ -95,9 +95,11 @@
> >
> > long transferred;
> > if(useFileChannels && encoder instanceof FileContentEncoder) {
> > - transferred = ((FileContentEncoder)encoder).transfer(fileChannel, idx, 100);
> > + transferred = ((FileContentEncoder)encoder)
> > + .transfer(fileChannel, idx, Long.MAX_VALUE);
> > } else {
> > - transferred = fileChannel.transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> > + transferred = fileChannel.
> > + transferTo(idx, Long.MAX_VALUE, new ContentEncoderChannel(encoder));
> > }
> >
> > if(transferred > 0)
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org