From 76d60b87dda0b4fb1693fc1693e88d4582a584b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Tue, 7 May 2019 14:30:29 +0200 Subject: [PATCH 1/4] Reduce the memory usage of go-ipfs Lower the number of connections, change the routing mode to dhtclient, and disable bandwidth metrics. This is hardcoded for now --- recipes/default.rb | 23 ++++++++++++++++++++++ templates/default/ipfs.systemd.service.erb | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/recipes/default.rb b/recipes/default.rb index ab5652b..91dd18f 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -83,3 +83,26 @@ end ipfs_config 'Swarm.AddrFilters' do value node['ipfs']['config']['swarm']['addr_filter'] end + +# Do not keep track of bandwidth metrics. Disabling bandwidth metrics can +# lead to a slight performance improvement, as well as a reduction in memory +# usage. +ipfs_config 'Swarm.DisableBandwidthMetrics' do + value true +end + +# Disable the p2p-circuit relay transport +ipfs_config 'Swarm.DisableRelay' do + value true +end + +# Number of connections that, when exceeded, will trigger a connection GC +# operation +ipfs_config 'Swarm.ConnMgr.HighWater' do + value 10 +end + +# Minimum number of connections to maintain +ipfs_config 'Swarm.ConnMgr.LowWater' do + value 1 +end diff --git a/templates/default/ipfs.systemd.service.erb b/templates/default/ipfs.systemd.service.erb index 69eaf4e..a15ae81 100644 --- a/templates/default/ipfs.systemd.service.erb +++ b/templates/default/ipfs.systemd.service.erb @@ -2,12 +2,14 @@ Description=Start ipfs [Service] -ExecStart=/usr/local/bin/ipfs daemon --migrate +ExecStart=/usr/local/bin/ipfs daemon --migrate --routing=dhtclient User=ipfs Group=ipfs Restart=always # Raise the ulimit (max number of open files) LimitNOFILE=64000 +# Limit the memory usage to 256MB +MemoryMax=256M [Install] WantedBy=multi-user.target From 5303612854159bd1e37690d6408a1d8a3f2597a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Tue, 7 May 2019 14:41:06 +0200 Subject: [PATCH 2/4] Turn integers into strings for now --- recipes/default.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index 91dd18f..e0993b6 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -99,10 +99,10 @@ end # Number of connections that, when exceeded, will trigger a connection GC # operation ipfs_config 'Swarm.ConnMgr.HighWater' do - value 10 + value '10' end # Minimum number of connections to maintain ipfs_config 'Swarm.ConnMgr.LowWater' do - value 1 + value '1' end From f22b7d9b1f1973f420270b1e212d2e9519c53c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Tue, 7 May 2019 14:55:29 +0200 Subject: [PATCH 3/4] Update the Berksfile.lock file --- Berksfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Berksfile.lock b/Berksfile.lock index 6bea0a7..7266f30 100644 --- a/Berksfile.lock +++ b/Berksfile.lock @@ -10,7 +10,7 @@ GRAPH build-essential (8.1.1) mingw (>= 1.1) seven_zip (>= 0.0.0) - ipfs (0.1.0) + ipfs (0.1.3) ark (>= 0.0.0) mingw (2.1.0) seven_zip (>= 0.0.0) From 5aa50ecc7eca5c7f113492057ca3bc8158e5154c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Tue, 7 May 2019 14:55:41 +0200 Subject: [PATCH 4/4] Fix the ipfs_config resource to handle integers too --- recipes/default.rb | 4 ++-- resources/config.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index e0993b6..91dd18f 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -99,10 +99,10 @@ end # Number of connections that, when exceeded, will trigger a connection GC # operation ipfs_config 'Swarm.ConnMgr.HighWater' do - value '10' + value 10 end # Minimum number of connections to maintain ipfs_config 'Swarm.ConnMgr.LowWater' do - value '1' + value 1 end diff --git a/resources/config.rb b/resources/config.rb index 67d4756..3051a47 100644 --- a/resources/config.rb +++ b/resources/config.rb @@ -2,7 +2,7 @@ require 'json' require 'mixlib/shellout' property :key, String, name_property: true -property :value, [String, Hash, Array, TrueClass, FalseClass], required: true +property :value, [String, Hash, Array, TrueClass, FalseClass, Integer], required: true action :create do include_recipe 'ipfs'