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
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
.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
.nvmrc
.postcssrc.yml
.profile
.rspec
.rubocop.yml
.ruby-version Bump ruby version to 2.4.2 (#4958) 2017-09-18 04:55:57 +02:00
.scss-lint.yml
.slugignore
.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
Aptfile
boxfile.yml
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
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?