profile
viewpoint
Aaron Patterson tenderlove GitHub Seattle http://tenderlovemaking.com/ 💘💙💜💗💚❤💓💛💚💗

brianmario/mysql2 1970

A modern, simple and very fast Mysql library for Ruby - binding to libmysql

codahale/bcrypt-ruby 1594

bcrypt-ruby is a Ruby binding for the OpenBSD bcrypt() password hashing algorithm, allowing you to easily store a secure hash of your users' passwords.

brianmario/yajl-ruby 1374

A streaming JSON parsing and encoding library for Ruby (C bindings to yajl)

brianmario/charlock_holmes 870

Character encoding detection, brought to you by ICU

flavorjones/loofah 752

HTML/XML manipulation and sanitization based on Nokogiri

brianmario/escape_utils 520

Faster string escaping routines for your ruby apps

jbarnette/johnson 466

Johnson wraps JavaScript in a loving Ruby embrace.

blowmage/minitest-rails 463

Minitest integration for Rails

github/cmark-gfm 435

GitHub's fork of cmark, a CommonMark parsing and rendering library and program in C

drbrain/net-http-persistent 252

Thread-safe persistent connections with Net::HTTP

issue commentrack-test/rack-test

Suggestion: finding new maintainers

I'd be happy if we moved rack-test to the Rack repository. I think it might be nice if we could eventually make rack-test just a part of Rack. IOW if Rack defines an interface for "app ↔️ web servers", it might make sense that it ships with code for testing those interfaces.

junaruga

comment created time in 15 hours

create barnchrails/rails

branch : collection-refactor

created branch time in 18 hours

push eventrails/rails

Aaron Patterson

commit sha 6878c505f13b9f63e4d162907185289047762c61

Eliminate a hash allocation when rendering templates The `**options` in this code allocates a hash. Most template renders are probably not cached, so if we return a little early, we can save a hash allocation on each render call. Here is an allocation benchmark: ```ruby require "active_record" require "active_record/railties/collection_cache_association_loading" require "action_controller" require "action_view" require "tmpdir" ActionView::PartialRenderer.prepend(ActiveRecord::Railties::CollectionCacheAssociationLoading) class TestController < ActionController::Base def _prefixes; []; end # Search the current directory rather than "test/" end Dir.mktmpdir do |dir| TestController.view_paths = dir File.write File.join(dir, "_thing.html.erb"), "Hello <%= yield %>" cv = TestController.new.view_context # heat cv.render("thing") { "World" } # delete the line below and allocations go *way* down def recurse(cv, depth) if depth == 0 cv.render("thing") { "World" } else cv.render("thing") { recurse(cv, depth - 1) } end end def allocs x = GC.stat(:total_allocated_objects) yield GC.stat(:total_allocated_objects) - x end 10.times do |i| p i => allocs { recurse(cv, i) } end end ``` Before: ``` $ be ruby thing.rb {0=>58} {1=>77} {2=>115} {3=>153} {4=>192} {5=>231} {6=>270} {7=>309} {8=>348} {9=>387} ``` After: ``` $ be ruby thing.rb {0=>55} {1=>73} {2=>109} {3=>145} {4=>182} {5=>219} {6=>256} {7=>293} {8=>330} {9=>367} ``` I realize this is a "micro bench", but we're seeing the same line pop up in benchmarks from our app. I extracted this micro-bench from one we're using to test renders inside our app.

view details

Aaron Patterson

commit sha eb2aedb5a47ee6da709e58c3a6fbd4d84435b265

Remove hash deconstruction I don't think this hash deconstruction buys us much in terms of readability. We only need two parameters, the rest are ignored, and on top of that we have to allocate a hash. Convert to positional parameters instead.

view details

Aaron Patterson

commit sha fe7d0fd82ad357f8dc155d43624b83495078fe60

Merge pull request #38570 from rails/eeliminate-hash-on-render Eliminate a hash allocation when rendering templates

view details

push time in 2 days

delete branch rails/rails

delete branch : eeliminate-hash-on-render

delete time in 2 days

PR merged rails/rails

Eliminate a hash allocation when rendering templates activerecord

The **options in this code allocates a hash. Most template renders are probably not cached, so if we return a little early, we can save a hash allocation on each render call.

Here is an allocation benchmark:


require "active_record"
require "active_record/railties/collection_cache_association_loading"
require "action_controller"
require "action_view"
require "tmpdir"

ActionView::PartialRenderer.prepend(ActiveRecord::Railties::CollectionCacheAssociationLoading)

class TestController < ActionController::Base
  def _prefixes; []; end # Search the current directory rather than "test/"
end

Dir.mktmpdir do |dir|
  TestController.view_paths = dir

  File.write File.join(dir, "_thing.html.erb"), "Hello <%= yield %>"

  cv = TestController.new.view_context

  # heat
  cv.render("thing") { "World" }

  def recurse(cv, depth)
    if depth == 0
      cv.render("thing") { "World" }
    else
      cv.render("thing") { recurse(cv, depth - 1) }
    end
  end

  def allocs
    x = GC.stat(:total_allocated_objects)
    yield
    GC.stat(:total_allocated_objects) - x
  end

  10.times do |i|
    p i => allocs { recurse(cv, i) }
  end
end

Before:

$ be ruby thing.rb
{0=>58}
{1=>77}
{2=>115}
{3=>153}
{4=>192}
{5=>231}
{6=>270}
{7=>309}
{8=>348}
{9=>387}

After:

$ be ruby thing.rb
{0=>55}
{1=>73}
{2=>109}
{3=>145}
{4=>182}
{5=>219}
{6=>256}
{7=>293}
{8=>330}
{9=>367}

I realize this is a "micro bench", but we're seeing the same line pop up in benchmarks from our app. I extracted this micro-bench from one we're using to test renders inside our app.

+6 -4

0 comment

1 changed file

tenderlove

pr closed time in 2 days

push eventrails/rails

Aaron Patterson

commit sha eb2aedb5a47ee6da709e58c3a6fbd4d84435b265

Remove hash deconstruction I don't think this hash deconstruction buys us much in terms of readability. We only need two parameters, the rest are ignored, and on top of that we have to allocate a hash. Convert to positional parameters instead.

view details

push time in 2 days

push eventrails/rails

Aaron Patterson

commit sha 6878c505f13b9f63e4d162907185289047762c61

Eliminate a hash allocation when rendering templates The `**options` in this code allocates a hash. Most template renders are probably not cached, so if we return a little early, we can save a hash allocation on each render call. Here is an allocation benchmark: ```ruby require "active_record" require "active_record/railties/collection_cache_association_loading" require "action_controller" require "action_view" require "tmpdir" ActionView::PartialRenderer.prepend(ActiveRecord::Railties::CollectionCacheAssociationLoading) class TestController < ActionController::Base def _prefixes; []; end # Search the current directory rather than "test/" end Dir.mktmpdir do |dir| TestController.view_paths = dir File.write File.join(dir, "_thing.html.erb"), "Hello <%= yield %>" cv = TestController.new.view_context # heat cv.render("thing") { "World" } # delete the line below and allocations go *way* down def recurse(cv, depth) if depth == 0 cv.render("thing") { "World" } else cv.render("thing") { recurse(cv, depth - 1) } end end def allocs x = GC.stat(:total_allocated_objects) yield GC.stat(:total_allocated_objects) - x end 10.times do |i| p i => allocs { recurse(cv, i) } end end ``` Before: ``` $ be ruby thing.rb {0=>58} {1=>77} {2=>115} {3=>153} {4=>192} {5=>231} {6=>270} {7=>309} {8=>348} {9=>387} ``` After: ``` $ be ruby thing.rb {0=>55} {1=>73} {2=>109} {3=>145} {4=>182} {5=>219} {6=>256} {7=>293} {8=>330} {9=>367} ``` I realize this is a "micro bench", but we're seeing the same line pop up in benchmarks from our app. I extracted this micro-bench from one we're using to test renders inside our app.

view details

push time in 2 days

PR opened rails/rails

Eliminate a hash allocation when rendering templates

The **options in this code allocates a hash. Most template renders are probably not cached, so if we return a little early, we can save a hash allocation on each render call.

Here is an allocation benchmark:


require "active_record"
require "active_record/railties/collection_cache_association_loading"
require "action_controller"
require "action_view"
require "tmpdir"

ActionView::PartialRenderer.prepend(ActiveRecord::Railties::CollectionCacheAssociationLoading)

class TestController < ActionController::Base
  def _prefixes; []; end # Search the current directory rather than "test/"
end

Dir.mktmpdir do |dir|
  TestController.view_paths = dir

  File.write File.join(dir, "_thing.html.erb"), "Hello <%= yield %>"

  cv = TestController.new.view_context

  # heat
  cv.render("thing") { "World" }
  # delete the line below and allocations go *way* down

  def recurse(cv, depth)
    if depth == 0
      cv.render("thing") { "World" }
    else
      cv.render("thing") { recurse(cv, depth - 1) }
    end
  end

  def allocs
    x = GC.stat(:total_allocated_objects)
    yield
    GC.stat(:total_allocated_objects) - x
  end

  10.times do |i|
    p i => allocs { recurse(cv, i) }
  end
end

Before:

$ be ruby thing.rb
{0=>58}
{1=>77}
{2=>115}
{3=>153}
{4=>192}
{5=>231}
{6=>270}
{7=>309}
{8=>348}
{9=>387}

After:

$ be ruby thing.rb
{0=>55}
{1=>73}
{2=>109}
{3=>145}
{4=>182}
{5=>219}
{6=>256}
{7=>293}
{8=>330}
{9=>367}

I realize this is a "micro bench", but we're seeing the same line pop up in benchmarks from our app. I extracted this micro-bench from one we're using to test renders inside our app.

+4 -0

0 comment

1 changed file

pr created time in 2 days

create barnchrails/rails

branch : eeliminate-hash-on-render

created branch time in 2 days

pull request commentrack/rack

Fix undefined method `DelegateClass' for Rack::Session::Cookie:Class

[aaron@tc-lan-adapter ~/g/rack (master)]$ ruby --disable-gems -I lib -r rack -e'p Rack::Session::Cookie'
Traceback (most recent call last):
	5: from -e:1:in `<main>'
	4: from -e:1:in `require'
	3: from /Users/aaron/git/rack/lib/rack/session/cookie.rb:9:in `<top (required)>'
	2: from /Users/aaron/git/rack/lib/rack/session/cookie.rb:11:in `<module:Rack>'
	1: from /Users/aaron/git/rack/lib/rack/session/cookie.rb:50:in `<module:Session>'
/Users/aaron/git/rack/lib/rack/session/cookie.rb:155:in `<class:Cookie>': undefined method `DelegateClass' for Rack::Session::Cookie:Class (NoMethodError)
onigra

comment created time in 2 days

pull request commentrack/rack

Fix undefined method `DelegateClass' for Rack::Session::Cookie:Class

If you change your require to be "rack" instead of "rack/session/cookie", that will solve the problem.

How would this fix it? delegate needs to be required at some point. I don't see it required at all:

[aaron@tc-lan-adapter ~/g/rack (master)]$ git grep delegate | grep require
[aaron@tc-lan-adapter ~/g/rack (master)]$

Since rack/session/cookie is the one using DelegateClass, it seems to be the right place to put the require.

onigra

comment created time in 2 days

Pull request review commentrails/rails

Set source association when setting a through association (fix for #33155)

 def replace(record)           replace_keys(record)            self.target = record++          set_through_association_source_target(record)

Should this be on the target= method rather than just the replace method?

drogus

comment created time in 2 days

Pull request review commentrails/rails

Set source association when setting a through association (fix for #33155)

+# frozen_string_literal: true++module ActiveRecord+  module Associations+    module SetThroughAssociationSourceTarget+      def set_through_association_source_target(record)+        through_reflection = self.reflection.active_record.reflections.values.find { |r|+          r.through_reflection && r.through_reflection.name == self.reflection.name+        }

What are the keys for self.reflection.active_record.reflections? Is it not the name?

drogus

comment created time in 2 days

issue commentpenelopezone/rubyfmt

Reconsider position on adopting trailing commas

I like number two. It seems like how I normally write code.

penelopezone

comment created time in 3 days

delete branch tenderlove/bindata

delete branch : always-return-ascii-8bit

delete time in 5 days

push eventtenderlove/bindata

Aaron Patterson

commit sha 26d35a173313394636fa9d17c7c3618dcf62934e

`to_binary_s` should always return ASCII-8BIT encoded strings StringIO in Ruby <= 2.6.X didn't respect `Encoding.default_internal`, so calling `read` on the StringIO wouldn't tag the string with the same encoding. Ruby 2.7 fixes this bug. The problem is that `to_binary_s` is returning a binary string and should always return an ASCII-8BIT encoded string. This patch changes the method to always return the ASCII-8BIT string regardless of the value of `Encoding.default_internal`. Here is the behavior of StringIO on Ruby 2.6: ``` $ ruby -v -rstringio -e'Encoding.default_internal = Encoding::UTF_8; io = StringIO.new("foo".force_encoding("ASCII-8BIT")); io.rewind; p io.read.encoding' ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19] -e:1: warning: setting Encoding.default_internal #<Encoding:ASCII-8BIT> ``` Here it is on 2.7: ``` $ ruby -v -rstringio -e'Encoding.default_internal = Encoding::UTF_8; io = StringIO.new("foo".force_encoding("ASCII-8BIT")); io.rewind; p io.read.encoding' ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19] -e:1: warning: setting Encoding.default_internal #<Encoding:UTF-8> ``` We can see 2.7 respects `default_internal`, but unfortunately that means that `to_binary_s` would return the wrong encoding.

view details

push time in 6 days

PR opened dmendel/bindata

`to_binary_s` should always return ASCII-8BIT encoded strings

StringIO in Ruby <= 2.6.X didn't respect Encoding.default_internal, so calling read on the StringIO wouldn't tag the string with the same encoding. Ruby 2.7 fixes this bug. The problem is that to_binary_s is returning a binary string and should always return an ASCII-8BIT encoded string.

This patch changes the method to always return the ASCII-8BIT string regardless of the value of Encoding.default_internal.

Here is the behavior of StringIO on Ruby 2.6:

$ ruby -v -rstringio -e'Encoding.default_internal = Encoding::UTF_8; io = StringIO.new("foo".force_encoding("ASCII-8BIT")); io.rewind; p io.read.encoding'
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
-e:1: warning: setting Encoding.default_internal
 #<Encoding:ASCII-8BIT>

Here it is on 2.7:

$ ruby -v -rstringio -e'Encoding.default_internal = Encoding::UTF_8; io = StringIO.new("foo".force_encoding("ASCII-8BIT")); io.rewind; p io.read.encoding'
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
-e:1: warning: setting Encoding.default_internal
  #<Encoding:UTF-8>

We can see 2.7 respects default_internal, but unfortunately that means that to_binary_s would return the wrong encoding.

+20 -2

0 comment

2 changed files

pr created time in 6 days

create barnchtenderlove/bindata

branch : always-return-ascii-8bit

created branch time in 6 days

fork tenderlove/bindata

BinData - Parsing Binary Data in Ruby

fork in 6 days

issue closedaws/aws-sdk-ruby

Release tags in git

Hi,

I'm trying to find what version shipped with d98d94c413a815d1bcf14fab7ccb6f526e3c4111, but I found that none of the v3.X tags have been pushed to GitHub. Could someone push the tags please?

Thanks!

closed time in 7 days

tenderlove

issue commentaws/aws-sdk-ruby

Release tags in git

@mullermp ok, thanks for the info! 🙇🏻‍♀️

tenderlove

comment created time in 7 days

pull request commentrails/rails

Deprecate usage of Rack::Runtime in the default middleware stack reso…

I'm not sure this is what we want to do. Won't this just cause warnings on every Rails application unless the users specifically remove the middleware? The issue isn't people specifically adding the Rack::Runtime middleware, it's that people may have code like this:

config.middleware.insert_before(::Rack::Runtime, SomeCoolMiddleware.new)

The user never asked for Rack::Runtime to be added, but they want their "cool middleware" to be inserted before Rack::Runtime. If Rack::Runtime doesn't exist in the middleware stack, then the above code won't work.

I think the best way to go about fixing this is probably to insert a dummy middleware, then check for people passing in Rack::Runtime to any methods that manipulate the middleware stack.

SValkanov

comment created time in 7 days

issue commentaws/aws-sdk-ruby

Release tags in git

I see. Is there a good way for me to tell what commit was in a particular release? Reading through changelogs seems rough. Also is there a way to know what git revision is equivalent to a particular release?

Thanks for your time!

tenderlove

comment created time in 8 days

issue openedaws/aws-sdk-ruby

Release tags in git

Hi,

I'm trying to find what version shipped with d98d94c413a815d1bcf14fab7ccb6f526e3c4111, but I found that none of the v3.X tags have been pushed to GitHub. Could someone push the tags please?

Thanks!

created time in 8 days

push eventrack/rack

Aaron Patterson

commit sha c9a75ffecff48367850ddbe6aeaa3e8a001ce460

master is 2.3.0 development now

view details

push time in 18 days

created tagrack/rack

tag2.2.0

a modular Ruby webserver interface

created time in 18 days

create barnchrack/rack

branch : 2-2-stable

created branch time in 18 days

push eventrack/rack

Aaron Patterson

commit sha 64f1a3fe50163946b9309f45c19efe93484e03af

fix release task

view details

push time in 18 days

created tagrack/rack

tag2.0.9

a modular Ruby webserver interface

created time in 18 days

push eventrack/rack

Aaron Patterson

commit sha 85684323f8f58409e717af91e446d257d496f8b8

bump version

view details

push time in 18 days

created tagrack/rack

tag1.6.13

a modular Ruby webserver interface

created time in 18 days

push eventrack/rack

Aaron Patterson

commit sha 47a1fd73fc77f094573f4215b0fc884f4ac1c03c

bump version

view details

push time in 18 days

issue closedruby/psych

Support for ruby2.7?

Hi,

Ruby 2.7 was out last year in December. I am not sure if ruby-psych works with that, does it? If not, could you possible make that happen?

Also, the last release was in October'18, maybe it's time for a release again, please? :)

closed time in 19 days

utkarsh2102

pull request commentrails/rails

Fixes TypeError raised for parameter filter if the json data has key as integer

@abhaynikam Can you verify that this test doesn't output anything to the terminal? https://github.com/rails/rails/pull/37435/files#diff-44d7367a5a923d3a4a825dbdb591d83dR46

When I wrote the code it was outputting stuff, but I might not have been doing it right. If you can verify that for me, I will merge this. Thanks again!

abhaynikam

comment created time in 20 days

push eventtenderlove/mmap

Daniel Magliola

commit sha d1135e967743880d919e33b78a9cc1fcc2e18a8a

Include contents of `mmap.rd` into `README.rdoc` Currently, the gem's main README, or the docs generated with `rake docs` don't include a description of the interface, or much documentation. The most useful documentation is in file `mmap.rd` which is not very obvious. This change includes the contents of `mmap.rd` into `README.rdoc`, which is the main port of call for any user of a gem.

view details

Daniel Magliola

commit sha 85dcc17e5bd75b03441626f890e327c40e7121c9

Reformatted the README for better readability

view details

Aaron Patterson

commit sha 887ceb747bd14be778aa67dfa6036af66f4dd0f9

Merge pull request #9 from dmagliola/better_docs_in_readme Include contents of `mmap.rd` into `README.rdoc`

view details

push time in 20 days

PR merged tenderlove/mmap

Include contents of `mmap.rd` into `README.rdoc`

Currently, the gem's main README, or the docs generated with rake docs don't include a description of the interface, or much documentation at all.

The most useful documentation is in file mmap.rd which is not very obvious.

This change includes the contents of mmap.rd into README.rdoc, which is the main port of call for any user of a gem.

+215 -561

0 comment

4 changed files

dmagliola

pr closed time in 20 days

delete branch tenderlove/oedo08

delete branch : add-title

delete time in 21 days

push eventasakusarb/oedo08

Aaron Patterson

commit sha d3e8be744975497f65a059136fbccf7c3640f618

Fix title. I am calling it "My Seikatsu". It's about my seikatsu.

view details

Aaron Patterson

commit sha 6d2e32d507d7947d7103ee96267e396a993f684c

Merge pull request #54 from tenderlove/add-title Fix title.

view details

push time in 21 days

PR merged asakusarb/oedo08

Fix title.

I am calling it "My Seikatsu". It's about my seikatsu.

+1 -1

0 comment

1 changed file

tenderlove

pr closed time in 21 days

PR opened asakusarb/oedo08

Fix title.

I am calling it "My Seikatsu". It's about my seikatsu.

+1 -1

0 comment

1 changed file

pr created time in 21 days

create barnchtenderlove/oedo08

branch : add-title

created branch time in 21 days

issue commentrack/rack

Document maintainership

In that case I'm fine with changing the gemspec (I don't particularly care other than my comment above)

leahneukirchen

comment created time in 21 days

push eventgithub/ruby

Aaron Patterson

commit sha 1b0644e7096252543f750177421bc12377f6c336

Add test infrastructure and eliminate network dependency This commit just adds dockerfiles we can run to ensure this repo doesn't have a network dependency when we compile and install. I also added the files necessary to eliminate the network dependency.

view details

push time in 21 days

create barnchgithub/ruby

branch : 2.7-github

created branch time in 21 days

push eventgithub/ruby

John Hawthorn

commit sha c2e45422f7abc9836d3b68bb94e527b3aad9bfd7

Store "UTC" and "" fstring as globals in time.c

view details

John Hawthorn

commit sha 5f3189474c3ee3e11b6588acfbb026e119522092

Avoid rb_check_string_type in month_arg This will usually receive a fixnum so we should check that first instead of the more expensive rb_check_string_type check.

view details

John Hawthorn

commit sha 91601dcc6a608cb6f9a124959c738755091dfbd9

Simplify obj2ubits checks If this value is less than zero, then the mask check is guaranteed to fail as well, so we might as well rely on that.

view details

git

commit sha e0a9b8ecef32a1eb719b80e0935a9c5840d2a1fe

* 2020-01-14 [ci skip]

view details

Jun Aruga

commit sha 440013b2fa73d12aeb4027bb8d8d237ea8700099

Remove s390x from allow_failures

view details

Ben

commit sha 9994eb8a5e72ff68ee2a13ddeff8d9307ba7cd84

[ruby/irb] Fix newline depth with multiple braces This commit fixes the check_newline_depth_difference method to multiple open braces on one line into account. Before this change we were subtracting from the depth in check_newline_depth_difference on every open brace. This is the right thing to do if the opening and closing brace are on the same line. For example in a method definition we have an opening and closing parentheses we want to add 1 to our depth, and then remove it. ``` def foo() end ``` However this isn't the correct behavior when the brace spans multiple lines. If a brace spans multiple lines we don't want to subtract from check_newline_depth_difference and we want to treat the braces the same way as we do `end` and allow check_corresponding_token_depth to pop the correct depth. Example of bad behavior: ``` def foo() [ ] puts 'bar' end ``` Example of desired behavior: ``` def foo() [ ] puts 'bar' end ``` https://github.com/ruby/irb/commit/7dc8af01e0

view details

Ben

commit sha c94025b63091be5b5e83a2f5ab5dc8d6c6147b84

[ruby/irb] Fix crashing when multiple open braces per line https://github.com/ruby/irb/issues/55 If we had put multiple open braces on a line the with no closing brace spaces_of_nest array keeps getting '0' added to it. This means that when we pop off of this array we are saying that we should be in position zero for the next line. This is an issue because we don't always want to be in position 0 after a closing brace. Example: ``` [[[ ] ] ] ``` In the above example the 'spaces_of_nest' array looks like this after the first line is entered: [0,0,0]. We really want to be indented 4 spaces for the 1st closing brace 2 for the 2nd and 0 for the 3rd. i.e. we want it to be: [0,2,4]. We also saw this issue with a heredoc inside of an array. ``` [<<FOO] hello FOO ``` https://github.com/ruby/irb/commit/80c69c8272

view details

aycabta

commit sha f8ea2860b0cac1aec79978e6c44168802958e8af

Introduce an abstracted structure about the encoding of Reline The command prompt on Windows always uses Unicode to take input and print output but most Reline implementation depends on Encoding.default_external. This commit introduces an abstracted structure about the encoding of Reline.

view details

aycabta

commit sha a2638c0d87106c6ba023a321eea502f35131753e

Remove an unused setting variable

view details

aycabta

commit sha 8c3efa494091e6e0001f4a708fb7568c242387b9

Use Reline.encoding_system_needs if exists

view details

Koichi Sasada

commit sha eb4c86a698e1be9fa2a79f4edb1c891396e6074e

Add option hash doc for GC stats. Add a description about optional hash objects for GC.stat and GC.latest_gc_info. [Bug #14408] The patch is provided by sho-h (Sho Hashimoto). Thank you so much.

view details

git

commit sha 07aef4c99ac4be3073f8b15ebdfa324a7f94f5e3

* 2020-01-15 [ci skip]

view details

Jean Boussier

commit sha 98ef38ada43338c073f50a0093196f0356284625

Freeze Regexp literals [Feature #8948] [Feature #16377] Since Regexp literals always reference the same instance, allowing to mutate them can lead to state leak.

view details

Kazuhiro NISHIYAMA

commit sha ac93cf4ff85ef195e8f6f151091a86f449a0be7a

Update version guard fix up 98ef38ada43338c073f50a0093196f0356284625

view details

Yusuke Endoh

commit sha 9feca5ceb924858e54e312da4b1ba097f72c5582

NEWS.md: converted from NEWS and NEWS is deleted

view details

Yusuke Endoh

commit sha 815807d2ab9e87b5543d6837234952fd6cd481a3

NEWS.md: mention "Freeze Regexp literals" [Feature #8948]

view details

Nobuyoshi Nakada

commit sha 4f19666e8b144600e959e4673f79d63f98bd637d

`Regexp` in `MatchData` can be `nil` `String#sub` with a string pattern defers creating a `Regexp` until `MatchData#regexp` creates a `Regexp` from the matched string. `Regexp#last_match(group_name)` accessed its content without creating the `Regexp` though. [Bug #16508]

view details

git

commit sha 0b6682dc57afc95eca9f75f895ec1bf554697e6c

* 2020-01-16 [ci skip]

view details

Nobuyoshi Nakada

commit sha fce54a5404139a77bd0b7d6f82901083fcb16f1e

Fix `String#partition` Split with the matched part when the separator matches the empty part at the beginning. [Bug #11014]

view details

Hiroshi SHIBATA

commit sha 62baad9fe17077f8881e8512234cf55563aa9fca

Removed xmlrpc and net-telnet from the bundled gems. [Feature #16484][ruby-core:96682]

view details

push time in 21 days

issue commentrack/rack

Document maintainership

My only concern is that I don't want to create a situation in which the original author of Rack is removed from the gemspec. If Leah ever decides to leave the core team, I'd rather not remove her from the gemspec (unless that's what she wants). So making "gemspec" == "core team" makes me slightly uncomfortable.

leahneukirchen

comment created time in 21 days

push eventrails/rails

Katrina Owen

commit sha 464d997076a057a984a1ae40122cd395ca00839c

Add a fallback database config when loading schema cache The schema cache defaults to loading the 'primary' database config. However, if an app doesn't have a db config with a spec name of 'primary' the filename lookup will blow up. This adds a fallback for this case.

view details

Katrina Owen

commit sha a13c134f642da71c3133a4bf579eb5c5a7865344

Don't try to autoload cache if no primary spec is found

view details

Aaron Patterson

commit sha 25c38079563baa2b6de8a6318aa5cd5297f97be8

Merge pull request #38383 from kytrinyx/schema-spec-fallback-config Add a fallback database config when loading schema cache

view details

push time in 21 days

PR merged rails/rails

Add a fallback database config when loading schema cache activerecord

Summary

The schema cache defaults to loading the 'primary' database config. However, if an app doesn't have a db config with a spec name of 'primary' the filename lookup will blow up.

This adds a fallback for this case.

Other Information

The filename for the schema cache used to be hard-coded, but Rails allows people to override the default path. In https://github.com/rails/rails/pull/38348 I made a change to take overrides into account, but failed to account for apps without a database config containing a spec named primary.

It turns out, at GitHub we don't have a database named primary, so even though we don't rely on this active record initializer, it blows up for us.

+2 -0

10 comments

1 changed file

kytrinyx

pr closed time in 21 days

issue commentsparklemotion/nokogiri

Memory access violation / Crash during GC

Something I think is interesting is that you can pretty easily demonstrate that turning a document in to a schema removes the node:

require 'nokogiri'

doc = <<~doc
<?xml version="1.0" encoding="UTF-8" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="foo" type="xs:string"/></xs:schema>
doc

xsd_doc = Nokogiri::XML(doc)
p xsd_doc.root.children.find(&:blank?) # Finds a node

xsd_doc = Nokogiri::XML(doc)
Nokogiri::XML::Schema.from_document(xsd_doc)
p xsd_doc.root.children.find(&:blank?) # nil
aleksandrs-ledovskis

comment created time in 22 days

pull request commentrails/rails

Add a fallback database config when loading schema cache

@kytrinyx ya, that PR does look like what we should be doing. Can you test it out, and try fixing if it's broken?

kytrinyx

comment created time in 22 days

pull request commentrails/rails

Add a fallback database config when loading schema cache

Got it.

Instead of loading the cache just for the "primary" connection, would it make sense to loop through each configuration, looking for schema caches, then loading those caches? Then we don't depend on a "primary" connection.

kytrinyx

comment created time in 22 days

pull request commentrails/rails

Add a fallback database config when loading schema cache

I thought the database configuration loading code guaranteed that one of the db configs would have a spec name of "primary". Is that not the case? Do you have a test app that can reproduce the issue?

kytrinyx

comment created time in 22 days

issue commentsparklemotion/nokogiri

Memory access violation / Crash during GC

Probably needs a better exception, but this would prevent the segvs:

diff --git a/ext/nokogiri/xml_schema.c b/ext/nokogiri/xml_schema.c
index da2774ba..42bbeb8d 100644
--- a/ext/nokogiri/xml_schema.c
+++ b/ext/nokogiri/xml_schema.c
@@ -133,6 +133,31 @@ static VALUE read_memory(VALUE klass, VALUE content)
   return rb_schema;
 }
 
+/* Schema creation will remove and deallocate "blank" nodes.
+ * If those blank nodes have been exposed to Ruby, they could get freed
+ * out from under the VALUE pointer.  This function checks to see if any of
+ * those nodes have been exposed to Ruby, and if so we should raise an exception.
+ */
+static int has_blank_nodes_p(VALUE cache)
+{
+    long i;
+
+    if (NIL_P(cache)) {
+        return 0;
+    }
+
+    for (i = 0; i < RARRAY_LEN(cache); i++) {
+        xmlNodePtr node;
+        VALUE element = rb_ary_entry(cache, i);
+        Data_Get_Struct(element, xmlNode, node);
+        if (xmlIsBlankNode(node)) {
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
 /*
  * call-seq:
  *  from_document(doc)
@@ -152,6 +177,10 @@ static VALUE from_document(VALUE klass, VALUE document)
   /* In case someone passes us a node. ugh. */
   doc = doc->doc;
 
+  if (has_blank_nodes_p(DOC_NODE_CACHE(doc))) {
+    rb_raise(rb_eRuntimeError, "Creating a schema from a document that has blank nodes exposed to Ruby is dangerous");
+  }
+
   ctx = xmlSchemaNewDocParserCtxt(doc);
 
   errors = rb_ary_new();
aleksandrs-ledovskis

comment created time in 22 days

issue commentsparklemotion/nokogiri

Memory access violation / Crash during GC

It is somewhat strange that you couldn't repeat the crash. While I was testing initially with CRuby 2.5.7 (to match with PROD version), I have just retested with master.

tbf, I only ran the Ruby program twice. Your description was clear enough and reading the code made it obvious there's a bug. I figured we'd need a pure C test case anyway if we plan to fix upstream.

I will try to think of a fix for libxml2, but even if I can't I'll still file a ticket upstream.

If per Nick's comment it's unfeasible to change the way how Libxml2 operates, maybe at least Nokogiri could detect (and raise hell) in situations when document containing blank text objects is passed on to Schema::from_document?

I think this is a possible alternative. The document should know what nodes have been exposed to Ruby, and if any of them are "blank", we can raise an exception. It'll make constructing the schema a little more expensive, but I agree it's better to get an exception than find a segv later.

aleksandrs-ledovskis

comment created time in 22 days

issue commentrack/rack

Managing environments.

I should have also mentioned: providing middleware seems fine too, but since my goal is for Rack to be "optional" in an app we shouldn't make defaults.

ioquatix

comment created time in 23 days

pull request commentrack/rack

Memoize header hash

It would be pretty cool if we had a benchmark suite and could keep track of the speeds over time.

ioquatix

comment created time in 23 days

issue commentrack/rack

Managing environments.

I'm ok with removing the default middleware in v3.0.0. My overall "vision" is that Rack defines an interface that webservers and applications can use to communicate. It should have no opinions about what a default middleware is, as it's just defining an interface. Also, it means that theoretically apps that speak Rack could work with webservers that speak Rack and never depend on Rack itself.

That said, I think it would be nice for Rack to provide things like:

  • Ways to test things (mock request / response)
  • A default request / response object (of course you can define your own)
  • Multipart parsing

Basically things that are nice to have but are never between the app and the webserver. Does that make sense as a direction?

I think keeping the webrick handler around is fine as an example implementation for a webserver, but I do think we should rm the rest.

ioquatix

comment created time in 23 days

issue commentrack/rack

Stop setting HTTP_VERSION to SERVER_PROTOCOL

IMO it's fine to remove this for v3.0.0

mattrobenolt

comment created time in 23 days

issue closedrack/rack

Rack::Utils.build_nested_query should use escaped square brackets

According to validator.w3.org and http://www.ietf.org/rfc/rfc3986.txt square brackets are not valid characters in query part of url and should be escaped as %5B resp %5D.

Rack::Utils.build_nested_query is using unescaped ones.

I must admit I'm not entirely sure what is you supposed to do if you want to use square brackets as hash key, but seems that input part of rack is already parsing encoded square brackets according to http://www.ietf.org/rfc/rfc3986.txt ...

closed time in 23 days

hkmaly

issue commentrack/rack

Rack::Utils.build_nested_query should use escaped square brackets

Sorry, this ship has sailed. We're not following the RFC and things seem to be working. If we changed the code to follow the RFC, then yes we would be more "technically correct", but on the other hand we'd probably end up breaking a ton of code and with no benefit to us or Rack users.

hkmaly

comment created time in 23 days

PR closed rack/rack

Escape [ and ] in Rack::Utils.escape

These should be escaped per RFC 3986 section 3.4, which does not allow them in query strings.

Rack already handled these correctly when processing input, the test changes are places where the values were checked directly without running it through an input processor.

Fixes #792

+26 -24

9 comments

3 changed files

jeremyevans

pr closed time in 23 days

pull request commentrack/rack

Escape [ and ] in Rack::Utils.escape

Lets document that we don't follow RFC. I really don't think this change is worth it. I can imagine tons of tests breaking out there because suddenly [ is escaped differently. Being "correct" WRT the RFC doesn't buy us anything and also would cause a lot of pain.

jeremyevans

comment created time in 23 days

pull request commentrack/rack

Memoize header hash

This benchmarks are nice and an abbreviated version could go in the commit message, but I don't think we need them in the repository. Could you remove them and squash?

I agree with this, but can you put the benchmarks and results in this PR? We can refer back to the PR to see the results, and the PR will be linked to from the merge commit (another reason I like backporting merge commits rather than individual cherry picking).

ioquatix

comment created time in 23 days

issue commentsparklemotion/nokogiri

Memory access violation / Crash during GC

I couldn't reproduce with Ruby, but the explanation makes sense. I think the XSLT parser shouldn't touch memory that it didn't allocate. Anyway, I was able to write a C program that uses libxml2 to demonstrate the problem:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <libxml/parser.h>
#include <libxml/xmlschemas.h>

static xmlNode *
find_text_node(xmlNode * a_node)
{
  xmlNode *cur_node = NULL;

  for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
    if (cur_node->type == XML_TEXT_NODE) {
      return cur_node;
    } else {
      xmlNode *found = find_text_node(cur_node->children);

      if (found) {
        return found;
      }
    }
  }

  return NULL;
}

int main(int argc, char *argv[]) {
  char * source = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n<xs:element name=\"foo\" type=\"xs:string\"/></xs:schema>";

  xmlDocPtr doc = xmlReadMemory(source, strlen(source), NULL, NULL, 0);
  xmlNodePtr root = xmlDocGetRootElement(doc);
  xmlSchemaParserCtxtPtr ctx;
  xmlSchemaPtr schema;

  xmlNode * text = find_text_node(root);
  printf("node type: Element, name: %s %d\n", text->name, xmlIsBlankNode(text));

  ctx = xmlSchemaNewDocParserCtxt(doc);
  schema = xmlSchemaParse(ctx);

  printf("node type: Element, name: %s %d\n", text->name, xmlIsBlankNode(text));

  exit(0);
}

If I enable malloc scribbling on MacOS, it will segv:

$ env MallocScribble=1 ./a.out
a.out(78495,0x102687dc0) malloc: enabling scribbling to detect mods to free blocks
node type: Element, name: text 1
fish: 'env MallocScribble=1 ./a.out' terminated by signal SIGSEGV (Address boundary error)

I think upstream should probably not call that free function when a schema is created from a document.

aleksandrs-ledovskis

comment created time in 23 days

issue commentrack/rack

Considerations for response body implementing `#call`.

I've only thought about this for 2 minutes or so, but on the surface this seems like a good idea.

  1. I don't know off the top of my head what all of the rack. headers are, so we need to look in to that.

  2. How should middleware that want to do something depending on the response body be written? For example a middleware that wants to set at Content-Length header, or a middleware that wants to rewrite links in a response body.

ioquatix

comment created time in 23 days

issue commentrails/rails

What about removing `Rack::Runtime` from the default middleware stack?

I think any mutation or manipulation of the middleware stack that passes in Rack::Runtime would need to display a warning. But you would also have to check to see if the user manually added Rack::Runtime as to prevent false positives. Probably MiddlewareStackProxy

kevinnio

comment created time in 23 days

pull request commentrails/rails

Fixes TypeError raised for parameter filter if the json data has key as integer

@abhaynikam no problem, thank you for sending this PR!

abhaynikam

comment created time in 23 days

pull request commentrails/rails

Deprecate schema dump marshaling behavior

TBH I don't think we should get rid of marshal. It's probably going to be faster than JSON or YAML (if speed is your thing). Regardless though, we should provide some way to configure the schema dump strategy, be it JSON, YAML, or Marshal.

kytrinyx

comment created time in 23 days

pull request commentrails/rails

Fixes TypeError raised for parameter filter if the json data has key as integer

I think this should get you started:

diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb
index ee08841eb3..a8781ffaa4 100644
--- a/activerecord/test/cases/adapters/postgresql/json_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/json_test.rb
@@ -6,6 +6,15 @@
 module PostgresqlJSONSharedTestCases
   include JSONSharedTestCases
 
+  class JsonDataTypeWithFilter < ActiveRecord::Base
+    self.table_name = "json_data_type"
+
+    def self.filter_attributes
+      # Rails.application.config.filter_parameters += [:password]
+      super + [:password]
+    end
+  end
+
   def setup
     super
     @connection.create_table("json_data_type") do |t|
@@ -17,6 +26,14 @@ def setup
     skip "do not test on PostgreSQL without #{column_type} type."
   end
 
+  def test_pretty_print
+    x = JsonDataTypeWithFilter.create!(payload: {})
+    x.payload[11] =  "foo"
+    io = StringIO.new
+    pp x, io
+    assert io.string
+  end
+
   def test_default
     @connection.add_column "json_data_type", "permissions", column_type, default: { "users": "read", "posts": ["read", "write"] }
     klass.reset_column_information
abhaynikam

comment created time in 23 days

pull request commentrails/rails

Fixes TypeError raised for parameter filter if the json data has key as integer

@abhaynikam or @phoet: Would either you mind adding a test that demonstrates the filtering issue in PG from #37428? The test case in this PR works, but it's not very clear where an int would come from in a real app. An AR-JSON test would demonstrate a surprising behavior.

abhaynikam

comment created time in 23 days

push eventrails/rails

Narendra Rajput

commit sha f8059d2383990c59f04fcd3c13f3c1dde5732d96

Fix the environment.rb file path in the benchmark generator template

view details

Aaron Patterson

commit sha b69382967efe448722329c41978e48316d8eb71e

Merge pull request #38378 from bknarendra/fix_template_for_benchmark_generator Fix the environment.rb file path in the benchmark generator template

view details

push time in 23 days

PR merged rails/rails

Fix the environment.rb file path in the benchmark generator template railties

The environment.rb file path in the benchmark generator template is incorrect. So if we generate a benchmark file using benchmark generator and run it. It throws an error

Traceback (most recent call last):
	1: from script/benchmarks/opt_compare.rb:3:in `<main>'
script/benchmarks/opt_compare.rb:3:in `require_relative': cannot load such file -- /path/to/rails_repo/script/config/environment (LoadError)

This PR fixes this path.

+3 -3

0 comment

2 changed files

bknarendra

pr closed time in 23 days

issue closedrails/rails

Hi how to compress the html.erb file by removing white spaces

Steps to reproduce

Hi how to remove comments and white spaces in html.erb files while deploying to prod Please help Thanks in advance

System configuration

Rails version: 6.0.0 Ruby version: 2.6.1

closed time in 23 days

medicharlachiranjeevi

issue commentrails/rails

Hi how to compress the html.erb file by removing white spaces

Hi, I don't think this is a bug in Rails so I'm going to close it. Thanks!

medicharlachiranjeevi

comment created time in 23 days

issue closedrails/rails

String#sql_safe flag (equivalent to html_safe)

Goal

Avoid a potential injection pattern by promoting safer SQL string composition.

Problem

In ActiveRecord conditions, it's possible to pass a relation object to compose a subquery:

Feature.where(project_id: Project.active.select(:id))

However, this is limited to relations that can be built with the ActiveRecord query interface. Once it becomes necessary to construct that fragment using raw SQL, the only option for querying it becomes:

Feature.where("features.project_id IN(#{complex_ids_sql})")

This style of string interpolation naturally looks suspicious, and is warned by static analysis tools like Brakeman. Ideally we should be able to pass a known-safe SQL literal fragment to querying methods like where and avoid this pattern.

Proposal

Internally, Arel.sql("str") exists for defining a SqlLiteral fragment. This style of wrapping to declare the string as a valid SQL fragment could be exposed as "str".sql_safe, analogous to what happens with SafeBuffer and html_safe.

When a SqlLiteral is passed instead of a String, the following patterns could be supported:

complex_ids_sql = QUERY.sql_safe
where(project_id: complex_ids_sql)
where("project_id IN (?)", complex_ids_sql)
where("project_id IN (%s)", complex_ids_sql)

These would result in having the SQL fragment interpolated to the predicate—instead of quoting it as a string literal. The resulting query would be the same as just building the string using today's #{} interpolation.

Benefits

  1. It can simplify the "project_id IN (?)" syntax construction for us, and let the relation provide the disambiguated table name by using the hash argument format (project_id: sql)
  2. It makes it very clear that there is no injection, given that the SQL fragment is properly sanitized and declared "SQL safe" at its source.

I would be happy to provide a PR for further review of this idea if the core team is interested.

closed time in 23 days

avit

issue commentrails/rails

String#sql_safe flag (equivalent to html_safe)

@simi sure!

avit

comment created time in 23 days

issue commentrails/rails

String#sql_safe flag (equivalent to html_safe)

Just echoing @matthewd here. Arel.sql("str") is public API, please feel free to use it.

avit

comment created time in 23 days

push eventrack/rack

Jeremy Evans

commit sha c3130cf9903d01641d759055f960119bb362a699

Update security policy Remove entry about providing backports to unsupported versions in git, as that is a contridiction (providing backports is providing at least minimal support). Of course, nothing precludes us from doing this, but we don't want users to consider it an expectation.

view details

Aaron Patterson

commit sha 16455b4c9a73d2fa65d3eed8a68b37ed06ebfe40

Merge pull request #1548 from jeremyevans/sec-policy Update security policy

view details

push time in 23 days

PR merged rack/rack

Reviewers
Update security policy

Remove entry about providing backports to unsupported versions in git, as that is a contradiction (providing backports is providing at least minimal support). Of course, nothing precludes us from doing this, but we don't want users to consider it an expectation.

+7 -7

0 comment

1 changed file

jeremyevans

pr closed time in 23 days

push eventruby/ruby

Lars Kanis

commit sha a4fca28b805cc8714cad1107424d97b822bf6414

Fix description of Encoding.default_(in|ex)ternal Data written to files is not transcoded per default, but only when default_internal is set. The default for default_internal is nil and doesn't depend on the source file encoding.

view details

push time in 23 days

PR merged ruby/ruby

Fix description of Encoding.default_(in|ex)ternal

Data written to files is not transcoded per default, but only when default_internal is set.

The default for default_internal is nil and doesn't depend on the source file encoding.

+2 -3

0 comment

1 changed file

larskanis

pr closed time in 23 days

issue commentruby/psych

Support for ruby2.7?

Psych works fine on Ruby 2.7. Is there a specific problem you are having? I see your exception, but I don't know how to reproduce it. Thanks.

utkarsh2102

comment created time in 23 days

push eventgithub/ruby

John Hawthorn

commit sha c2e45422f7abc9836d3b68bb94e527b3aad9bfd7

Store "UTC" and "" fstring as globals in time.c

view details

John Hawthorn

commit sha 5f3189474c3ee3e11b6588acfbb026e119522092

Avoid rb_check_string_type in month_arg This will usually receive a fixnum so we should check that first instead of the more expensive rb_check_string_type check.

view details

John Hawthorn

commit sha 91601dcc6a608cb6f9a124959c738755091dfbd9

Simplify obj2ubits checks If this value is less than zero, then the mask check is guaranteed to fail as well, so we might as well rely on that.

view details

git

commit sha e0a9b8ecef32a1eb719b80e0935a9c5840d2a1fe

* 2020-01-14 [ci skip]

view details

Jun Aruga

commit sha 440013b2fa73d12aeb4027bb8d8d237ea8700099

Remove s390x from allow_failures

view details

Ben

commit sha 9994eb8a5e72ff68ee2a13ddeff8d9307ba7cd84

[ruby/irb] Fix newline depth with multiple braces This commit fixes the check_newline_depth_difference method to multiple open braces on one line into account. Before this change we were subtracting from the depth in check_newline_depth_difference on every open brace. This is the right thing to do if the opening and closing brace are on the same line. For example in a method definition we have an opening and closing parentheses we want to add 1 to our depth, and then remove it. ``` def foo() end ``` However this isn't the correct behavior when the brace spans multiple lines. If a brace spans multiple lines we don't want to subtract from check_newline_depth_difference and we want to treat the braces the same way as we do `end` and allow check_corresponding_token_depth to pop the correct depth. Example of bad behavior: ``` def foo() [ ] puts 'bar' end ``` Example of desired behavior: ``` def foo() [ ] puts 'bar' end ``` https://github.com/ruby/irb/commit/7dc8af01e0

view details

Ben

commit sha c94025b63091be5b5e83a2f5ab5dc8d6c6147b84

[ruby/irb] Fix crashing when multiple open braces per line https://github.com/ruby/irb/issues/55 If we had put multiple open braces on a line the with no closing brace spaces_of_nest array keeps getting '0' added to it. This means that when we pop off of this array we are saying that we should be in position zero for the next line. This is an issue because we don't always want to be in position 0 after a closing brace. Example: ``` [[[ ] ] ] ``` In the above example the 'spaces_of_nest' array looks like this after the first line is entered: [0,0,0]. We really want to be indented 4 spaces for the 1st closing brace 2 for the 2nd and 0 for the 3rd. i.e. we want it to be: [0,2,4]. We also saw this issue with a heredoc inside of an array. ``` [<<FOO] hello FOO ``` https://github.com/ruby/irb/commit/80c69c8272

view details

aycabta

commit sha f8ea2860b0cac1aec79978e6c44168802958e8af

Introduce an abstracted structure about the encoding of Reline The command prompt on Windows always uses Unicode to take input and print output but most Reline implementation depends on Encoding.default_external. This commit introduces an abstracted structure about the encoding of Reline.

view details

aycabta

commit sha a2638c0d87106c6ba023a321eea502f35131753e

Remove an unused setting variable

view details

aycabta

commit sha 8c3efa494091e6e0001f4a708fb7568c242387b9

Use Reline.encoding_system_needs if exists

view details

Koichi Sasada

commit sha eb4c86a698e1be9fa2a79f4edb1c891396e6074e

Add option hash doc for GC stats. Add a description about optional hash objects for GC.stat and GC.latest_gc_info. [Bug #14408] The patch is provided by sho-h (Sho Hashimoto). Thank you so much.

view details

git

commit sha 07aef4c99ac4be3073f8b15ebdfa324a7f94f5e3

* 2020-01-15 [ci skip]

view details

Jean Boussier

commit sha 98ef38ada43338c073f50a0093196f0356284625

Freeze Regexp literals [Feature #8948] [Feature #16377] Since Regexp literals always reference the same instance, allowing to mutate them can lead to state leak.

view details

Kazuhiro NISHIYAMA

commit sha ac93cf4ff85ef195e8f6f151091a86f449a0be7a

Update version guard fix up 98ef38ada43338c073f50a0093196f0356284625

view details

Yusuke Endoh

commit sha 9feca5ceb924858e54e312da4b1ba097f72c5582

NEWS.md: converted from NEWS and NEWS is deleted

view details

Yusuke Endoh

commit sha 815807d2ab9e87b5543d6837234952fd6cd481a3

NEWS.md: mention "Freeze Regexp literals" [Feature #8948]

view details

Nobuyoshi Nakada

commit sha 4f19666e8b144600e959e4673f79d63f98bd637d

`Regexp` in `MatchData` can be `nil` `String#sub` with a string pattern defers creating a `Regexp` until `MatchData#regexp` creates a `Regexp` from the matched string. `Regexp#last_match(group_name)` accessed its content without creating the `Regexp` though. [Bug #16508]

view details

git

commit sha 0b6682dc57afc95eca9f75f895ec1bf554697e6c

* 2020-01-16 [ci skip]

view details

Nobuyoshi Nakada

commit sha fce54a5404139a77bd0b7d6f82901083fcb16f1e

Fix `String#partition` Split with the matched part when the separator matches the empty part at the beginning. [Bug #11014]

view details

Hiroshi SHIBATA

commit sha 62baad9fe17077f8881e8512234cf55563aa9fca

Removed xmlrpc and net-telnet from the bundled gems. [Feature #16484][ruby-core:96682]

view details

push time in a month

push eventruby/ruby

Florian Heinle

commit sha 39a1959d289ecba5e61431deaef239123c3f0fcc

Fix wrong return value in proc documentation.

view details

push time in a month

PR merged ruby/ruby

Fix wrong return value in proc documentation.

Correct return value in a Proc class documentation example.

+1 -1

1 comment

1 changed file

FloHeinle

pr closed time in a month

pull request commentruby/ruby

Fix wrong return value in proc documentation.

@FloHeinle thank you!

FloHeinle

comment created time in a month

issue commentrails/rails

What about removing `Rack::Runtime` from the default middleware stack?

@kevinnio that sounds like a good plan!

kevinnio

comment created time in a month

push eventrails/rails

Jean Boussier

commit sha 1e209d71b05c9d2f9dadeeb256bd3ee42949a42f

Save a string allocation for each attribute method call

view details

Aaron Patterson

commit sha 6a6e3f6efe9d621543da77dd3e9f1e875778d4e6

Merge pull request #38355 from Shopify/attribute-methods-frozen-strings Save a string allocation for each attribute method call

view details

push time in a month

PR merged rails/rails

Save a string allocation for each attribute method call activemodel

I noticed that the attribute method proxy call would systematically instantiate the same string over and over:

[10] pry(main)> MemoryProfiler.report { s.name? }.pretty_print
# ...
Allocated String Report
-----------------------------------
         1  "name"
         1  ~/gems/rails-1d1991430dc5/activemodel/lib/active_model/attribute_methods.rb:380

It's not a lot per say, but it can easily add up.

Backward compatibility

It's possible that there are attribute methods out there that mutate the received attribute name, but IMHO it's quite an edge case and easy to fix.

cc @rafaelfranca @Edouard-chin

+1 -0

1 comment

1 changed file

casperisfine

pr closed time in a month

pull request commentrails/rails

Save a string allocation for each attribute method call

ooooo lol, I love it.

casperisfine

comment created time in a month

delete branch github/ruby

delete branch : use-rb-gc-mark-in-globals

delete time in a month

PR closed ruby/ruby

Use `rb_gc_mark` when marking globals

I think global references should either be 0 or valid heap pointers. rb_gc_mark_maybe checks to see if the pointer is a valid heap pointer, but I believe we already know they are valid addresses

+1 -1

0 comment

1 changed file

tenderlove

pr closed time in a month

pull request commentrack/rack

Kill Constants

Looking at it another way, if constant lookups were cached and as fast as string literals (definitely possible), would we do this?

No, definitely not.

To me, there is value in using constants, which is not just about performance.

Yes. Not only are the constants part of Rack's API, we use these "magic strings" in multiple places. It's good practice to put those types of things in constants so we don't have to go hunting for strings if we change them.

That being said, I'd personally like to see if this impacts real web application performance before making a decision, because I think from a code POV, it's a bit worse.

I agree with this. I'm not super keen on this change just because it wins in micro benchmarks. It loses in code hygiene IMO. If constant lookups were as fast as frozen string literals, I wouldn't make this change so I'm reticent to accept it (not to mention Charlie's point about this being an optimization for an implementation detail of one specific Ruby implementation). Maybe we can speed up constant lookups and then more people win?

If we could show this has measurable impact in an app (doesn't need to be Rails), then I'd be more happy to merge this (until we can make constant lookup faster of course, and then I'd revert)

schneems

comment created time in a month

issue commentrails/rails

What about removing `Rack::Runtime` from the default middleware stack?

Sorry, I thought this was the Rack repo >_<

Yes, we tried to remove it once here: https://github.com/rails/rails/commit/37423e4ff883ad5584bab983aceb4b2b759a1fd8

Then ended up reverting that here: https://github.com/rails/rails/commit/24f9c03d52ad4c7f081cc7a9561946109b3ad500

I'd like to remove it, but commit comment details the issue.

kevinnio

comment created time in a month

issue commentrails/rails

What about removing `Rack::Runtime` from the default middleware stack?

I'm OK removing it, but if I remember correctly we tried to do it once and people were depending on it being in the middleware stack. That might have just been on the Rails side though, but give me some time to investigate

kevinnio

comment created time in a month

issue commentrails/rails

active record store attributes and accessors don't handle ActionController::Parameters well

I think this might be multiple bugs. initialize is clearly treating attributes differently than the setter, I think.

Here is a smaller test case that reproduces just one of the issues you've shown:

# frozen_string_literal: true

require "active_record"
require 'action_controller'
require "minitest/autorun"
require "logger"

# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Schema.define do
  create_table :posts, force: true do |t|
    t.text :store1
    t.text :store2
  end
end

class Post < ActiveRecord::Base
  store :store1, accessors: [:store1_arr1]
  store :store2, accessors: [:store2_hash1]
end

class BugTest < Minitest::Test
  def test_as_attribute_to_initialize
    post = Post.new ActionController::Parameters.new({store2: {store2_hash1: {a: 1}}}).permit!
    post2 = Post.new store2: ActionController::Parameters.new({store2_hash1: {a: 1}}).permit!
    p post.store2
    p post2.store2
    assert_equal post.store2.to_yaml, post2.store2.to_yaml
  end
end

store2 on both of those objects should probably be the same.

bughit

comment created time in a month

push eventtenderlove/ruby-tree-sitter

Aaron Patterson

commit sha a4d312e571a2d4c7842792fcb55a2bc6cf1ce44b

Use newer Rubys in CI

view details

push time in a month

create barnchgithub/ruby

branch : use-rb-gc-mark-in-globals

created branch time in a month

PR opened ruby/ruby

Use `rb_gc_mark` when marking globals

I think global references should either be 0 or valid heap pointers. rb_gc_mark_maybe checks to see if the pointer is a valid heap pointer, but I believe we already know they are valid addresses

+1 -1

0 comment

1 changed file

pr created time in a month

more