From 5973ec8de25d9753b7dba1486e5243e3a2329b38 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 14 Oct 2014 17:19:36 +1100 Subject: [PATCH] Add support for large memory pages --- README.md | 1 + manifests/init.pp | 3 ++- spec/classes/memcached_spec.rb | 9 +++++++-- templates/memcached.conf.erb | 7 ++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b552f7677..5e7511b0e 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,4 @@ If you find this module useful, send some bitcoins to 1Na3YFUmdxKxJLiuRXQYJU2kiN * $processorcount = $::processorcount * $service_restart = true (restart service after configuration changes, false to prevent restarts) * $use_sasl = false (start memcached with SASL support) +* $large_mem_pages = false (try to use large memory pages) diff --git a/manifests/init.pp b/manifests/init.pp index 19f825f31..f469c7554 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,7 +20,8 @@ $processorcount = $::processorcount, $service_restart = true, $auto_removal = false, - $use_sasl = false + $use_sasl = false, + $large_mem_pages = false, ) inherits memcached::params { # validate type and convert string to boolean if necessary diff --git a/spec/classes/memcached_spec.rb b/spec/classes/memcached_spec.rb index b40599f5d..11b1defa4 100644 --- a/spec/classes/memcached_spec.rb +++ b/spec/classes/memcached_spec.rb @@ -60,7 +60,8 @@ :max_connections => '8192', :install_dev => false, :processorcount => 1, - :use_sasl => false + :use_sasl => false, + :large_mem_pages => false, } end @@ -78,7 +79,8 @@ :max_connections => '8193', :verbosity => 'vvv', :processorcount => 3, - :use_sasl => true + :use_sasl => true, + :large_mem_pages => true, }, { :package_ensure => 'present', @@ -189,6 +191,9 @@ if(param_hash[:use_sasl]) expected_lines.push("-S") end + if(param_hash[:large_mem_pages]) + expected_lines.push("-L") + end (content.split("\n") & expected_lines).should =~ expected_lines end end diff --git a/templates/memcached.conf.erb b/templates/memcached.conf.erb index ede73d064..0ecc7d7d6 100644 --- a/templates/memcached.conf.erb +++ b/templates/memcached.conf.erb @@ -45,6 +45,11 @@ logfile <%= @logfile -%> # Run daemon as user -u <%= @user %> +<% if @large_mem_pages -%> +# Try to use large memory pages (if available) +-L +<% end -%> + # Limit the number of simultaneous incoming connections. -c <%= @max_connections %> @@ -59,4 +64,4 @@ logfile <%= @logfile -%> <% if @auto_removal -%> # Disable automatic removal of items from the cache when out of memory -M -<% end -%> \ No newline at end of file +<% end -%>