Browse Source

Merge branch 'master' of https://github.com/TechEmpower/FrameworkBenchmarks

jamming 10 years ago
parent
commit
845ea975bc

+ 16 - 3
config/postgresql.conf

@@ -61,7 +61,7 @@ listen_addresses = '*'		# what IP address(es) to listen on;
 					# defaults to 'localhost', '*' = all
 					# defaults to 'localhost', '*' = all
 					# (change requires restart)
 					# (change requires restart)
 port = 5432				# (change requires restart)
 port = 5432				# (change requires restart)
-max_connections = 2000			# (change requires restart)
+max_connections = 5000			# (change requires restart)
 # Note:  Increasing max_connections costs ~400 bytes of shared memory per
 # Note:  Increasing max_connections costs ~400 bytes of shared memory per
 # connection slot, plus lock space (see max_locks_per_transaction).
 # connection slot, plus lock space (see max_locks_per_transaction).
 #superuser_reserved_connections = 3	# (change requires restart)
 #superuser_reserved_connections = 3	# (change requires restart)
@@ -105,8 +105,21 @@ ssl = false                             # (change requires restart)
 #------------------------------------------------------------------------------
 #------------------------------------------------------------------------------
 
 
 # - Memory -
 # - Memory -
-
-shared_buffers = 32MB			# min 128kB
+# values from: http://blog.pgaddict.com/posts/performance-since-postgresql-7-4-to-9-4-pgbench
+# details: http://www.postgresql.org/docs/9.4/static/runtime-config-resource.html
+# http://www.postgresql.org/docs/9.4/static/runtime-config-wal.html
+# http://www.postgresql.org/docs/9.4/static/runtime-config-query.html
+shared_buffers = 2GB                    # min 128kB
+work_mem = 64MB                                # min 64kB
+maintenance_work_mem = 512MB            # min 1MB
+checkpoint_segments = 64
+checkpoint_completion_target = 0.9
+effective_cache_size = 8GB
+
+# when executed on the SSD (otherwise 4)
+random_page_cost = 2
+
+#shared_buffers = 32MB			# min 128kB
 					# (change requires restart)
 					# (change requires restart)
 #temp_buffers = 8MB			# min 800kB
 #temp_buffers = 8MB			# min 800kB
 #max_prepared_transactions = 0		# zero disables the feature
 #max_prepared_transactions = 0		# zero disables the feature

+ 1 - 1
frameworks/PHP/hhvm/setup_hhvm.sh

@@ -8,5 +8,5 @@ sed -i 's|File = .*/error.log|File = '"${TROOT}"'/error.log|g' deploy/config.hdf
 sed -i "s|/usr/local/nginx/|${IROOT}/nginx/|g" deploy/nginx.conf
 sed -i "s|/usr/local/nginx/|${IROOT}/nginx/|g" deploy/nginx.conf
 sed -i "s|TEST_ROOT|${TROOT}|g" deploy/nginx.conf
 sed -i "s|TEST_ROOT|${TROOT}|g" deploy/nginx.conf
 
 
-hhvm --config $TROOT/deploy/config.hdf -m daemon
+hhvm --config $TROOT/deploy/config.hdf --user $(whoami) -m daemon
 $NGINX_HOME/sbin/nginx -c $TROOT/deploy/nginx.conf
 $NGINX_HOME/sbin/nginx -c $TROOT/deploy/nginx.conf

+ 15 - 36
frameworks/Perl/mojolicious/app.pl

@@ -1,5 +1,5 @@
 use Mojolicious::Lite;
 use Mojolicious::Lite;
-use Mango;
+use Mojo::Pg;
 
 
 use JSON::XS 'encode_json';
 use JSON::XS 'encode_json';
 use Scalar::Util 'looks_like_number';
 use Scalar::Util 'looks_like_number';
@@ -23,14 +23,8 @@ plugin Config => {
   @{app->config->{hypnotoad}}{keys %$merge} = values %$merge;
   @{app->config->{hypnotoad}}{keys %$merge} = values %$merge;
 }
 }
 
 
-# Database connections
 
 
-helper mango   => sub { state $mango = Mango->new('mongodb://'. shift->config->{database_host}) };
-helper db      => sub { state $db = shift->mango->db('hello_world') };
-helper world   => sub { state $world = shift->db->collection('world') };
-helper fortune => sub { state $fortune = shift->db->collection('fortune') };
-
-# JSON::XS renderer
+helper pg => sub { state $pg = Mojo::Pg->new('postgresql://benchmarkdbuser:benchmarkdbpass@' . shift->config->{database_host} . '/hello_world') };
 
 
 helper render_json => sub { shift->render( data => encode_json(shift), format => 'json' ) }; 
 helper render_json => sub { shift->render( data => encode_json(shift), format => 'json' ) }; 
 
 
@@ -46,13 +40,10 @@ get '/queries' => sub {
 };
 };
 
 
 get '/fortunes' => sub {
 get '/fortunes' => sub {
-  my $c = shift->render_later;
-  my $tx = $c->tx;
-  $c->helpers->fortune->find->all(sub{
-    my ($cursor, $err, $docs) = @_;
-    push @$docs, { _id => 0, message => 'Additional fortune added at request time.' };
-    $c->render( fortunes => docs => $docs ) unless $tx->is_finished;
-  });
+  my $c = shift;
+  my $docs = $c->helpers->pg->db->query('SELECT id, message FROM Fortune')->arrays;
+  push @$docs, [0, 'Additional fortune added at request time.'];
+  $c->render( fortunes => docs => $docs->sort(sub{ $a->[1] cmp $b->[1] }) );
 };
 };
 
 
 get '/updates' => sub {
 get '/updates' => sub {
@@ -69,8 +60,6 @@ helper 'render_query' => sub {
   $args ||= {};
   $args ||= {};
   my $update = $args->{update};
   my $update = $args->{update};
 
 
-  $self->render_later;
-
   $q = 1 unless looks_like_number($q);
   $q = 1 unless looks_like_number($q);
   $q = 1   if $q < 1;
   $q = 1   if $q < 1;
   $q = 500 if $q > 500;
   $q = 500 if $q > 500;
@@ -78,27 +67,17 @@ helper 'render_query' => sub {
   my $r  = [];
   my $r  = [];
   my $tx = $self->tx;
   my $tx = $self->tx;
 
 
-  my $delay = Mojo::IOLoop->delay;
-  $delay->on(finish => sub{
-    $r = $r->[0] if $args->{single};
-    $self->helpers->render_json($r) unless $tx->is_finished;
-  });
-
-  my $world = $self->helpers->world;
+  my $db = $self->helpers->pg->db;
 
 
   foreach (1 .. $q) {
   foreach (1 .. $q) {
     my $id = int rand 10_000;
     my $id = int rand 10_000;
-    my $end = $delay->begin;
-    $world->find_one({_id => $id} => sub {
-      my ($world, $err, $doc) = @_;
-      if ($update) { $doc->{randomNumber} = 1 + int rand 10_000 };
-      push @$r, { id => $id, randomNumber => $doc->{randomNumber} };
-      $update ? $world->save($doc, $end) : $end->();
-    });
+    my $randomNumber = $db->query('SELECT randomnumber FROM World WHERE id=?', $id)->array->[0];
+    $db->query('UPDATE World SET randomnumber=? WHERE id=?', ($randomNumber = 1 + int rand 10_000), $id) if $update; 
+    push @$r, { id => $id, randomNumber => $randomNumber };
   }
   }
 
 
-  # use this line if not running under a Mojolicious server
-  # $delay->wait unless $delay->ioloop->is_running;
+  $r = $r->[0] if $args->{single};
+  $self->helpers->render_json($r);
 };
 };
 
 
 app->start;
 app->start;
@@ -112,10 +91,10 @@ __DATA__
   <body>
   <body>
     <table>
     <table>
       <tr><th>id</th><th>message</th></tr>
       <tr><th>id</th><th>message</th></tr>
-      % foreach my $doc (sort { $a->{message} cmp $b->{message} } @$docs) {
+      % foreach my $doc (@$docs) {
         <tr>
         <tr>
-          <td><%= $doc->{_id}     %></td>
-          <td><%= $doc->{message} %></td>
+          <td><%= $doc->[0] %></td>
+          <td><%= $doc->[1] %></td>
         </tr>
         </tr>
       % }
       % }
     </table>
     </table>

+ 1 - 1
frameworks/Perl/mojolicious/benchmark_config

@@ -12,7 +12,7 @@
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",
       "classification": "Fullstack",
       "classification": "Fullstack",
-      "database": "MongoDB",
+      "database": "Postgres",
       "framework": "mojolicious",
       "framework": "mojolicious",
       "language": "Perl",
       "language": "Perl",
       "orm": "Raw",
       "orm": "Raw",

+ 2 - 2
frameworks/Perl/mojolicious/cpanfile

@@ -1,5 +1,5 @@
-requires 'Mojolicious', '>= 5.29';
-requires 'Mango', '>= 1.0';
+requires 'Mojolicious', '>= 6.02';
+requires 'Mojo::Pg', '>= 1.14';
 requires 'JSON::XS';
 requires 'JSON::XS';
 requires 'EV';
 requires 'EV';
 
 

+ 120 - 25
frameworks/Perl/mojolicious/cpanfile.snapshot

@@ -1,5 +1,112 @@
 # carton snapshot format: version 1.0
 # carton snapshot format: version 1.0
 DISTRIBUTIONS
 DISTRIBUTIONS
+  DBD-Pg-3.5.1
+    pathname: T/TU/TURNSTEP/DBD-Pg-3.5.1.tar.gz
+    provides:
+      Bundle::DBD::Pg v3.5.1
+      DBD::Pg v3.5.1
+    requirements:
+      DBI 1.614
+      ExtUtils::MakeMaker 6.11
+      Test::More 0.88
+      Time::HiRes 0
+      version 0
+  DBI-1.633
+    pathname: T/TI/TIMB/DBI-1.633.tar.gz
+    provides:
+      Bundle::DBI 12.008696
+      DBD::DBM 0.08
+      DBD::DBM::Statement 0.08
+      DBD::DBM::Table 0.08
+      DBD::DBM::db 0.08
+      DBD::DBM::dr 0.08
+      DBD::DBM::st 0.08
+      DBD::ExampleP 12.014311
+      DBD::ExampleP::db 12.014311
+      DBD::ExampleP::dr 12.014311
+      DBD::ExampleP::st 12.014311
+      DBD::File 0.44
+      DBD::File::DataSource::File 0.44
+      DBD::File::DataSource::Stream 0.44
+      DBD::File::Statement 0.44
+      DBD::File::Table 0.44
+      DBD::File::TableSource::FileSystem 0.44
+      DBD::File::db 0.44
+      DBD::File::dr 0.44
+      DBD::File::st 0.44
+      DBD::Gofer 0.015327
+      DBD::Gofer::Policy::Base 0.010088
+      DBD::Gofer::Policy::classic 0.010088
+      DBD::Gofer::Policy::pedantic 0.010088
+      DBD::Gofer::Policy::rush 0.010088
+      DBD::Gofer::Transport::Base 0.014121
+      DBD::Gofer::Transport::corostream undef
+      DBD::Gofer::Transport::null 0.010088
+      DBD::Gofer::Transport::pipeone 0.010088
+      DBD::Gofer::Transport::stream 0.014599
+      DBD::Gofer::db 0.015327
+      DBD::Gofer::dr 0.015327
+      DBD::Gofer::st 0.015327
+      DBD::NullP 12.014715
+      DBD::NullP::db 12.014715
+      DBD::NullP::dr 12.014715
+      DBD::NullP::st 12.014715
+      DBD::Proxy 0.2004
+      DBD::Proxy::RPC::PlClient 0.2004
+      DBD::Proxy::db 0.2004
+      DBD::Proxy::dr 0.2004
+      DBD::Proxy::st 0.2004
+      DBD::Sponge 12.010003
+      DBD::Sponge::db 12.010003
+      DBD::Sponge::dr 12.010003
+      DBD::Sponge::st 12.010003
+      DBDI 12.015129
+      DBI 1.633
+      DBI::Const::GetInfo::ANSI 2.008697
+      DBI::Const::GetInfo::ODBC 2.011374
+      DBI::Const::GetInfoReturn 2.008697
+      DBI::Const::GetInfoType 2.008697
+      DBI::DBD 12.015129
+      DBI::DBD::Metadata 2.014214
+      DBI::DBD::SqlEngine 0.06
+      DBI::DBD::SqlEngine::DataSource 0.06
+      DBI::DBD::SqlEngine::Statement 0.06
+      DBI::DBD::SqlEngine::Table 0.06
+      DBI::DBD::SqlEngine::TableSource 0.06
+      DBI::DBD::SqlEngine::TieMeta 0.06
+      DBI::DBD::SqlEngine::TieTables 0.06
+      DBI::DBD::SqlEngine::db 0.06
+      DBI::DBD::SqlEngine::dr 0.06
+      DBI::DBD::SqlEngine::st 0.06
+      DBI::FAQ 1.014935
+      DBI::Gofer::Execute 0.014283
+      DBI::Gofer::Request 0.012537
+      DBI::Gofer::Response 0.011566
+      DBI::Gofer::Serializer::Base 0.009950
+      DBI::Gofer::Serializer::DataDumper 0.009950
+      DBI::Gofer::Serializer::Storable 0.015586
+      DBI::Gofer::Transport::Base 0.012537
+      DBI::Gofer::Transport::pipeone 0.012537
+      DBI::Gofer::Transport::stream 0.012537
+      DBI::Profile 2.015065
+      DBI::ProfileData 2.010008
+      DBI::ProfileDumper 2.015325
+      DBI::ProfileDumper::Apache 2.014121
+      DBI::ProfileSubs 0.009396
+      DBI::ProxyServer 0.3005
+      DBI::ProxyServer::db 0.3005
+      DBI::ProxyServer::dr 0.3005
+      DBI::ProxyServer::st 0.3005
+      DBI::SQL::Nano 1.015544
+      DBI::SQL::Nano::Statement_ 1.015544
+      DBI::SQL::Nano::Table_ 1.015544
+      DBI::Util::CacheMemory 0.010315
+      DBI::Util::_accessor 0.009479
+      DBI::common 1.633
+    requirements:
+      ExtUtils::MakeMaker 6.48
+      Test::Simple 0.90
+      perl 5.008
   EV-4.18
   EV-4.18
     pathname: M/ML/MLEHMANN/EV-4.18.tar.gz
     pathname: M/ML/MLEHMANN/EV-4.18.tar.gz
     provides:
     provides:
@@ -24,34 +131,22 @@ DISTRIBUTIONS
       ExtUtils::MakeMaker 0
       ExtUtils::MakeMaker 0
       Types::Serialiser 0
       Types::Serialiser 0
       common::sense 0
       common::sense 0
-  Mango-1.16
-    pathname: O/OD/ODC/Mango-1.16.tar.gz
+  Mojo-Pg-1.14
+    pathname: S/SR/SRI/Mojo-Pg-1.14.tar.gz
     provides:
     provides:
-      Mango 1.16
-      Mango::BSON undef
-      Mango::BSON::Binary undef
-      Mango::BSON::Code undef
-      Mango::BSON::Document undef
-      Mango::BSON::ObjectID undef
-      Mango::BSON::Time undef
-      Mango::BSON::Timestamp undef
-      Mango::BSON::_MaxKey undef
-      Mango::BSON::_MinKey undef
-      Mango::Bulk undef
-      Mango::Collection undef
-      Mango::Cursor undef
-      Mango::Cursor::Query undef
-      Mango::Database undef
-      Mango::GridFS undef
-      Mango::GridFS::Reader undef
-      Mango::GridFS::Writer undef
-      Mango::Protocol undef
+      Mojo::Pg 1.14
+      Mojo::Pg::Database undef
+      Mojo::Pg::Migrations undef
+      Mojo::Pg::PubSub undef
+      Mojo::Pg::Results undef
+      Mojo::Pg::Transaction undef
     requirements:
     requirements:
+      DBD::Pg 0
       ExtUtils::MakeMaker 0
       ExtUtils::MakeMaker 0
-      Mojolicious 5.40
+      Mojolicious 6.0
       perl 5.010001
       perl 5.010001
-  Mojolicious-5.81
-    pathname: S/SR/SRI/Mojolicious-5.81.tar.gz
+  Mojolicious-6.02
+    pathname: S/SR/SRI/Mojolicious-6.02.tar.gz
     provides:
     provides:
       Mojo undef
       Mojo undef
       Mojo::Asset undef
       Mojo::Asset undef
@@ -114,7 +209,7 @@ DISTRIBUTIONS
       Mojo::UserAgent::Server undef
       Mojo::UserAgent::Server undef
       Mojo::UserAgent::Transactor undef
       Mojo::UserAgent::Transactor undef
       Mojo::Util undef
       Mojo::Util undef
-      Mojolicious 5.81
+      Mojolicious 6.02
       Mojolicious::Command undef
       Mojolicious::Command undef
       Mojolicious::Command::cgi undef
       Mojolicious::Command::cgi undef
       Mojolicious::Command::cpanify undef
       Mojolicious::Command::cpanify undef

+ 1 - 0
frameworks/Perl/mojolicious/setup.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
+export LIBEV_FLAGS=7
 HYPNOTOAD=$(${PERL_HOME}/bin/carton exec which hypnotoad)
 HYPNOTOAD=$(${PERL_HOME}/bin/carton exec which hypnotoad)
 ${PERL_HOME}/bin/carton exec ${PERL_HOME}/bin/perl ${HYPNOTOAD} ${TROOT}/app.pl
 ${PERL_HOME}/bin/carton exec ${PERL_HOME}/bin/perl ${HYPNOTOAD} ${TROOT}/app.pl

+ 9 - 0
toolset/benchmark/benchmarker.py

@@ -376,12 +376,21 @@ class Benchmarker:
     p.communicate("""
     p.communicate("""
       sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535
       sudo sysctl -w net.ipv4.tcp_max_syn_backlog=65535
       sudo sysctl -w net.core.somaxconn=65535
       sudo sysctl -w net.core.somaxconn=65535
+      sudo sysctl -w kernel.sched_autogroup_enabled=0
       sudo -s ulimit -n 65535
       sudo -s ulimit -n 65535
       sudo sysctl net.ipv4.tcp_tw_reuse=1
       sudo sysctl net.ipv4.tcp_tw_reuse=1
       sudo sysctl net.ipv4.tcp_tw_recycle=1
       sudo sysctl net.ipv4.tcp_tw_recycle=1
       sudo sysctl -w kernel.shmmax=2147483648
       sudo sysctl -w kernel.shmmax=2147483648
       sudo sysctl -w kernel.shmall=2097152
       sudo sysctl -w kernel.shmall=2097152
+      sudo sysctl -w kernel.sem="250 32000 256 512"
+      echo "Printing kernel configuration:" && sudo sysctl -a
     """)
     """)
+        # Explanations:
+        # net.ipv4.tcp_max_syn_backlog, net.core.somaxconn, kernel.sched_autogroup_enabled: http://tweaked.io/guide/kernel/
+        # ulimit -n: http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
+        # net.ipv4.tcp_tw_*: http://www.linuxbrigade.com/reduce-time_wait-socket-connections/
+        # kernel.shm*: http://seriousbirder.com/blogs/linux-understanding-shmmax-and-shmall-settings/
+        # For kernel.sem: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/chap-Oracle_9i_and_10g_Tuning_Guide-Setting_Semaphores.html
   ############################################################
   ############################################################
   # End __setup_database
   # End __setup_database
   ############################################################
   ############################################################