Your self-hosted, globally interconnected microblogging community
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
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)
8 years ago
app Use more idiomatic string concatentation. #164. 8 years ago
bin Upgrade Webpacker to version 3.0.1 (#5122) 9 years ago
config Merge tag 'v2.0.0' into gs-master 8 years ago
db Add KeywordMute model. 8 years ago
docs Fix redirect link on Tuning.md (#1595) 9 years ago
lib Merge tag 'v2.0.0' into gs-master 8 years ago
log
nanobox [nanobox] Allow Full-size Uploads (#4123) 9 years ago
public Merge tag 'v2.0.0rc2' into gs-master 8 years ago
spec Fix case-insensitive match scenario; test some word ornamentation. #164. 8 years ago
streaming use-DB_NAME-in-development (#5430) 8 years ago
vendor/assets
.babelrc 🎄🔨 Force tree shake emojione (#4202) 9 years ago
.buildpacks Add heroku APT buildpack for scalingo. (#3051) 9 years ago
.codeclimate.yml Enable CodeClimate SCSS Lint checks (#2886) 9 years ago
.dockerignore Remove Storybook (#4397) 9 years ago
.editorconfig Add final newline to locale files (#2890) 9 years ago
.env.nanobox [nanobox] Add Automated Backups (#4023) 9 years ago
.env.production.sample Document REDIS_NAMESPACE (#5038) 9 years ago
.env.test Add recovery code support for two-factor auth (#1773) 9 years ago
.env.vagrant
.eslintignore
.eslintrc.yml Enable ESLint rules import/* (#5414) 8 years ago
.foreman Replace sprockets/browserify with Webpack (#2617) 9 years ago
.gitattributes Add .gitattributes file to avoid unwanted CRLF (#3954) 9 years ago
.gitignore Fix #5274 - Create symlink from public/500.html to public/assets/500.html (#5288) 8 years ago
.haml-lint.yml Added haml-lint and fix warnings (#2773) 9 years ago
.nanoignore Remove Storybook (#4397) 9 years ago
.nvmrc update Node to 6.x LTS (#1228) 9 years ago
.postcssrc.yml Add object-fit polyfill for Edge (#4182) 9 years ago
.profile Add ffmpeg and dependent packages as well as LD_LIBRARY_PATHs (#3276) 9 years ago
.rspec
.rubocop.yml Add handling of Linked Data Signatures in payloads (#4687) 9 years ago
.ruby-version Bump ruby version to 2.4.2 (#4958) 9 years ago
.scss-lint.yml Enable CodeClimate SCSS Lint checks (#2886) 9 years ago
.slugignore Remove Storybook (#4397) 9 years ago
.travis.yml Run `i18n-tasks checked-normalized` in Travis CI (#5443) 8 years ago
.yarnclean Reduce container size with clean yarn (#3506) 9 years ago
Aptfile Specify libicu explicitly in Aptfile (#4920) 9 years ago
CODEOWNERS + me for Dutch (#5349) 8 years ago
CONTRIBUTING.md Added link to docs website 9 years ago
Capfile remove capistrano/faster_assets from Capfile (#2737) 9 years ago
Dockerfile Reduce container size with clean yarn (#3506) 9 years ago
Gemfile Add strong_migrations to production dependency (#5234) 9 years ago
Gemfile.lock Close connection when succeeded posting (#5390) 8 years ago
ISSUE_TEMPLATE.md Adds note for instance admins. (#1925) 9 years ago
LICENSE
Procfile More robust PuSH subscription refreshes (#2799) 9 years ago
Procfile.dev Upgrade Webpacker to version 3.0.1 (#5122) 9 years ago
README.md Update outdated README (#5262) 9 years ago
Rakefile
Vagrantfile Install libidn11-dev in Vagrant (#4238) 9 years ago
app.json Change logo URL for Heroku and Scalingo (#4476) 9 years ago
boxfile.yml [nanobox] Minor tweaks for 1.5 (#4395) 9 years ago
config.ru
docker-compose.yml Specify middleware versions in docker-compose.yml (#5247) 9 years ago
docker_entrypoint.sh Some Dockerfile improvements (#3182) 9 years ago
jest.config.js Enable coverage for Jest (#5442) 8 years ago
package.json Merge tag 'v2.0.0' into gs-master 8 years ago
scalingo.json Change logo URL for Heroku and Scalingo (#4476) 9 years ago
yarn.lock Merge remote-tracking branch 'upstream/master' into gs-master 8 years ago

README.md

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?