Free performance with symbol-fstring

A few months back @byroot released symbol-fstring

By adding gem 'symbol-fstring', require: 'fstring/all in your Gemfile you may benefit from some 100% free ™ performance.

I can confirm this now works with Discourse, earlier versions of pry had some issues.

From benchmarks I am not noticing any noticeable performance gains for Discourse. But it is clear from micro benches that some apps may benefit from this. We may repeat testing in production.

Discourse bench before


git pull https://github.com/discourse/discourse
ruby script/bench.rb

Iterations: 500, Best of: 1
Concurrency: 1

---
categories:
  50: 31
  75: 32
  90: 45
  99: 60
home:
  50: 39
  75: 41
  90: 54
  99: 91
topic:
  50: 31
  75: 32
  90: 45
  99: 58
categories_admin:
  50: 33
  75: 35
  90: 47
  99: 64
home_admin:
  50: 41
  75: 51
  90: 57
  99: 89
topic_admin:
  50: 31
  75: 33
  90: 46
  99: 58
timings:
  load_rails: 2399
ruby-version: 2.6.5-p114
rss_kb: 295192
pss_kb: 285883
architecture: x86_64
operatingsystem: Archlinux
processor0: Intel(R) Core(TM) i9-9900KF CPU @ 3.60GHz
virtual: physical
memorysize: 62.75 GB
kernelversion: 5.6.7
physicalprocessorcount: 1

Discourse bench after

Iterations: 500, Best of: 1
Concurrency: 1

---
categories:
  50: 32
  75: 33
  90: 46
  99: 69
home:
  50: 40
  75: 43
  90: 56
  99: 90
topic:
  50: 31
  75: 32
  90: 45
  99: 57
categories_admin:
  50: 32
  75: 34
  90: 47
  99: 60
home_admin:
  50: 39
  75: 41
  90: 55
  99: 85
topic_admin:
  50: 30
  75: 31
  90: 45
  99: 55
timings:
  load_rails: 2380
ruby-version: 2.6.5-p114
rss_kb: 302964
pss_kb: 293506
architecture: x86_64
operatingsystem: Archlinux
processor0: Intel(R) Core(TM) i9-9900KF CPU @ 3.60GHz
virtual: physical
memorysize: 62.75 GB
kernelversion: 5.6.7
physicalprocessorcount: 1

9 Likes

Thanks for publicizing this @samsaffron.

We’ve been running it on our main monolith for 5 months now. Overall the gains are fairly small. We measure that it reduced GC cycles by 10%, but that only translated to about 0.3ms on the average request time.

However on some specific outliers API endpoints that builds a lot of symbol keyed hashes and then serialize them to json, we saw as much as a 10% reduction of GC time.

So as you said don’t expect big gains, but it’s also super easy to setup.

Also I’d like to convince ruby-core to make this change in the next major version, it was initially scheduled for Ruby 2.7.0, but was reverted because a few popular gems were incompatible, but since them I got them fixed.

So if people read us and are willing to try this gem, at least on CI, let me know if you find incompatible gems.

9 Likes