Navigation Menu

Skip to content

Commit

Permalink
reduce chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 19, 2011
1 parent 2bdbc77 commit 43f43b3
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Asset/File.pm
Expand Up @@ -168,7 +168,7 @@ sub slurp {

# Slurp
my $content = '';
while ($self->handle->sysread(my $buffer, 256000)) { $content .= $buffer }
while ($self->handle->sysread(my $buffer, 131072)) { $content .= $buffer }

return $content;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Asset/Memory.pm
Expand Up @@ -33,7 +33,7 @@ sub contains {
sub get_chunk {
my ($self, $start) = @_;
$start += $self->start_range;
my $size = $ENV{MOJO_CHUNK_SIZE} || 256000;
my $size = $ENV{MOJO_CHUNK_SIZE} || 131072;
if (my $end = $self->end_range) {
$size = $end + 1 - $start if ($start + $size) > $end;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Content.pm
Expand Up @@ -4,7 +4,7 @@ use Mojo::Base -base;
use Carp 'croak';
use Mojo::Headers;

use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 256000;
use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 131072;

has [qw/auto_relax relaxed/] => 0;
has headers => sub { Mojo::Headers->new };
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Content/Single.pm
Expand Up @@ -60,7 +60,7 @@ sub parse {
if ($asset->isa('Mojo::Asset::Memory')) {

# Upgrade to file based storage on demand
if ($asset->size > ($ENV{MOJO_MAX_MEMORY_SIZE} || 256000)) {
if ($asset->size > ($ENV{MOJO_MAX_MEMORY_SIZE} || 262144)) {
$self->asset(Mojo::Asset::File->new->add_chunk($asset->slurp));
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/IOLoop.pm
Expand Up @@ -1494,7 +1494,7 @@ sub _read {
return unless defined(my $handle = $c->{handle});

# Read as much as possible
my $read = $handle->sysread(my $buffer, 256000, 0);
my $read = $handle->sysread(my $buffer, 131072, 0);

# Error
unless (defined $read) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Message.pm
Expand Up @@ -9,7 +9,7 @@ use Mojo::Parameters;
use Mojo::Upload;
use Mojo::Util qw/decode url_unescape/;

use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 256000;
use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 131072;

has content => sub { Mojo::Content::Single->new };
has default_charset => 'UTF-8';
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Server/CGI.pm
@@ -1,7 +1,7 @@
package Mojo::Server::CGI;
use Mojo::Base 'Mojo::Server';

use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 256000;
use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 131072;

has nph => 0;

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Server/PSGI.pm
@@ -1,7 +1,7 @@
package Mojo::Server::PSGI;
use Mojo::Base 'Mojo::Server';

use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 256000;
use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 131072;

# "Things aren't as happy as they used to be down here at the unemployment
# office.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Template.pm
Expand Up @@ -7,7 +7,7 @@ use IO::File;
use Mojo::ByteStream;
use Mojo::Exception;

use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 256000;
use constant CHUNK_SIZE => $ENV{MOJO_CHUNK_SIZE} || 131072;

has [qw/auto_escape compiled/];
has [qw/append code prepend/] => '';
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Guides/Cheatsheet.pod
Expand Up @@ -165,7 +165,7 @@ Note that L<IO::Socket::SSL> must be installed for TLS support.
=head2 C<MOJO_CHUNK_SIZE>

Chunk size used for IO operations in bytes, a bigger chunk size speeds up IO
operations but will also use more memory, defaults to C<256000>.
operations but will also use more memory, defaults to C<131072>.

MOJO_CHUNK_SIZE=1024

Expand Down Expand Up @@ -215,7 +215,7 @@ to C<10240>.
=head2 C<MOJO_MAX_MEMORY_SIZE>

Maximum size in bytes for HTTP content to keep in memory, bigger content will
be written to temporary files, defaults to C<256000>.
be written to temporary files, defaults to C<262144>.

MOJO_MAX_MEMORY_SIZE=2048

Expand Down
2 changes: 1 addition & 1 deletion t/mojo/apache_fastcgi.t
Expand Up @@ -7,7 +7,7 @@ use warnings;
BEGIN { $ENV{MOJO_NO_IPV6} = $ENV{MOJO_POLL} = 1 }

# mod_fastcgi doesn't like small chunks
BEGIN { $ENV{MOJO_CHUNK_SIZE} = 256000 }
BEGIN { $ENV{MOJO_CHUNK_SIZE} = 131072 }

use Test::More;

Expand Down

0 comments on commit 43f43b3

Please sign in to comment.