A glitchy but lovable microblogging server
Go to file
David Yip 693c66dfde Use more idiomatic string concatentation. #164.
The intent of the previous concatenation was to minimize object
allocations, which can end up being a slow killer.  However, it turns
out that under MRI 2.4.x, the shove-strings-in-an-array-and-join method
is not only arguably more common but (in this particular case) actually
allocates *fewer* objects than the string concatenation.

Or, at least, that's what I gather by running this:

    words = %w(palmettoes nudged hibernation bullish stockade's tightened Hades
    Dixie's formalize superego's commissaries Zappa's viceroy's apothecaries
    tablespoonful's barons Chennai tollgate ticked expands)

    a = Account.first

    KeywordMute.transaction do
      words.each { |w| KeywordMute.create!(keyword: w, account: a) }

      GC.start

      s1 = GC.stat

      re = String.new.tap do |str|
        scoped = KeywordMute.where(account: a)
        keywords = scoped.select(:id, :keyword)
        count = scoped.count

        keywords.find_each.with_index do |kw, index|
          str << Regexp.escape(kw.keyword.strip)
          str << '|' if index < count - 1
        end
      end

      s2 = GC.stat

      puts s1.inspect, s2.inspect

      raise ActiveRecord::Rollback
    end

vs this:

    words = %w( palmettoes nudged hibernation bullish stockade's tightened Hades Dixie's
    formalize superego's commissaries Zappa's viceroy's apothecaries tablespoonful's
    barons Chennai tollgate ticked expands
    )

    a = Account.first

    KeywordMute.transaction do
      words.each { |w| KeywordMute.create!(keyword: w, account: a) }

      GC.start

      s1 = GC.stat

      re = [].tap do |arr|
        KeywordMute.where(account: a).select(:keyword, :id).find_each do |m|
          arr << Regexp.escape(m.keyword.strip)
        end
      end.join('|')

      s2 = GC.stat

      puts s1.inspect, s2.inspect

      raise ActiveRecord::Rollback
    end

Using rails r, here is a comparison of the total_allocated_objects and
malloc_increase_bytes GC stat data:

                 total_allocated_objects        malloc_increase_bytes
string concat    3200241 -> 3201428 (+1187)     1176 -> 45216 (44040)
array join       3200380 -> 3201299 (+919)      1176 -> 36448 (35272)
2017-10-21 14:54:36 -05:00
app Use more idiomatic string concatentation. #164. 2017-10-21 14:54:36 -05:00
bin Upgrade Webpacker to version 3.0.1 (#5122) 2017-09-27 14:41:54 +02:00
config Merge tag 'v2.0.0' into gs-master 2017-10-18 11:52:04 -05:00
db Add KeywordMute model. 2017-10-21 14:53:41 -05:00
docs
lib Merge tag 'v2.0.0' into gs-master 2017-10-18 11:52:04 -05:00
log Initial commit 2016-02-20 22:53:20 +01:00
nanobox
public Merge tag 'v2.0.0rc2' into gs-master 2017-10-12 04:22:59 -05:00
spec Fix case-insensitive match scenario; test some word ornamentation. #164. 2017-10-21 14:54:36 -05:00
streaming use-DB_NAME-in-development (#5430) 2017-10-17 11:45:37 +02:00
vendor/assets
.babelrc
.buildpacks
.codeclimate.yml
.dockerignore Remove Storybook (#4397) 2017-07-27 22:30:27 +02:00
.editorconfig
.env.nanobox
.env.production.sample Document REDIS_NAMESPACE (#5038) 2017-09-22 06:44:39 +02:00
.env.test
.env.vagrant
.eslintignore
.eslintrc.yml Enable ESLint rules import/* (#5414) 2017-10-16 11:12:09 +02:00
.foreman
.gitattributes
.gitignore Fix #5274 - Create symlink from public/500.html to public/assets/500.html (#5288) 2017-10-09 20:51:24 +02:00
.haml-lint.yml
.nanoignore Remove Storybook (#4397) 2017-07-27 22:30:27 +02:00
.nvmrc
.postcssrc.yml
.profile
.rspec
.rubocop.yml Add handling of Linked Data Signatures in payloads (#4687) 2017-08-26 13:47:38 +02:00
.ruby-version Bump ruby version to 2.4.2 (#4958) 2017-09-18 04:55:57 +02:00
.scss-lint.yml
.slugignore Remove Storybook (#4397) 2017-07-27 22:30:27 +02:00
.travis.yml Run i18n-tasks checked-normalized in Travis CI (#5443) 2017-10-18 11:57:02 +02:00
.yarnclean Reduce container size with clean yarn (#3506) 2017-09-30 22:05:24 +02:00
app.json Change logo URL for Heroku and Scalingo (#4476) 2017-08-01 05:59:11 +02:00
Aptfile Specify libicu explicitly in Aptfile (#4920) 2017-09-13 09:30:13 +02:00
boxfile.yml [nanobox] Minor tweaks for 1.5 (#4395) 2017-07-27 15:13:32 +02:00
Capfile
CODEOWNERS + me for Dutch (#5349) 2017-10-12 19:07:35 +09:00
config.ru
CONTRIBUTING.md
docker-compose.yml Specify middleware versions in docker-compose.yml (#5247) 2017-10-06 20:37:17 +02:00
docker_entrypoint.sh
Dockerfile Reduce container size with clean yarn (#3506) 2017-09-30 22:05:24 +02:00
Gemfile Add strong_migrations to production dependency (#5234) 2017-10-06 03:24:54 +02:00
Gemfile.lock Close connection when succeeded posting (#5390) 2017-10-14 14:38:57 +02:00
ISSUE_TEMPLATE.md
jest.config.js Enable coverage for Jest (#5442) 2017-10-18 11:39:36 +02:00
LICENSE
package.json Merge tag 'v2.0.0' into gs-master 2017-10-18 11:52:04 -05:00
Procfile
Procfile.dev Upgrade Webpacker to version 3.0.1 (#5122) 2017-09-27 14:41:54 +02:00
Rakefile
README.md Update outdated README (#5262) 2017-10-07 21:20:59 +02:00
scalingo.json Change logo URL for Heroku and Scalingo (#4476) 2017-08-01 05:59:11 +02:00
Vagrantfile
yarn.lock Merge remote-tracking branch 'upstream/master' into gs-master 2017-10-16 09:23:59 -05:00

Mastodon Glitch Edition

Now with automated deploys!

Build Status

So here's the deal: we all work on this code, and then it runs on dev.glitch.social and anyone who uses that does so absolutely at their own risk. can you dig it?