Forum: Ruby-core [ruby-trunk - Bug #7161][Open] Perf fix: use symbols instead of strings for const/ivar access method

Posted by Charles Nutter (headius)
on 2012-10-14 21:35
(Received via mailing list)
Issue #7161 has been reported by headius (Charles Nutter).

----------------------------------------
Bug #7161: Perf fix: use symbols instead of strings for const/ivar 
access methods
https://bugs.ruby-lang.org/issues/7161

Author: headius (Charles Nutter)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 2.0.0


From pull request: https://github.com/ruby/ruby/pull/195

Fixes a number of places where literal, non-dynamic strings are used as 
the first argument for constant and instance variable get, set, and 
defined? methods. This reduces object overhead in all cases.

Notable fixes:

* Setting @original_filename and @content_type in read_multipart 
(cgi/core.rb). This is called for every multipart read.
* Setting @uri and @ref in DrbObject.new_with (drb/drb.rb). Called for 
every "with" instantiation of a DrbObject.
* Setting BINDING_QUEUE in IRB::Workspace#initialize (irb/workspace.rb). 
Called for every new IRB workspace.
* Getting @mon_mutex in ConditionVariable#wait (monitor.rb). Called for 
every #wait. This fix makes the method require zero object allocation 
(other than imposed by the runtime).

The other fixes are rarely called, but fixed for consistency.

make test-all passes the same with or without this patch.
Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-05 13:45
(Received via mailing list)
Issue #7161 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to shyouhei (Shyouhei Urabe)

The patch looks benign.  I wonder how much is the performance improved, 
though.
Urabe-san, could you handle the pull request?

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Bug #7161: Perf fix: use symbols instead of strings for const/ivar 
access methods
https://bugs.ruby-lang.org/issues/7161#change-32405

Author: headius (Charles Nutter)
Status: Assigned
Priority: Normal
Assignee: shyouhei (Shyouhei Urabe)
Category:
Target version:
ruby -v: 2.0.0


From pull request: https://github.com/ruby/ruby/pull/195

Fixes a number of places where literal, non-dynamic strings are used as 
the first argument for constant and instance variable get, set, and 
defined? methods. This reduces object overhead in all cases.

Notable fixes:

* Setting @original_filename and @content_type in read_multipart 
(cgi/core.rb). This is called for every multipart read.
* Setting @uri and @ref in DrbObject.new_with (drb/drb.rb). Called for 
every "with" instantiation of a DrbObject.
* Setting BINDING_QUEUE in IRB::Workspace#initialize (irb/workspace.rb). 
Called for every new IRB workspace.
* Getting @mon_mutex in ConditionVariable#wait (monitor.rb). Called for 
every #wait. This fix makes the method require zero object allocation 
(other than imposed by the runtime).

The other fixes are rarely called, but fixed for consistency.

make test-all passes the same with or without this patch.
Posted by Charles Nutter (headius)
on 2012-11-05 18:39
(Received via mailing list)
Issue #7161 has been updated by headius (Charles Nutter).


The performance gain is not tremendous, but it does avoid a lot of 
intermediate string objects that could cumulatively impact performance 
through GC overhead.

In any case, it's a good cleanup patch, and there are certainly small 
perf gains.
----------------------------------------
Bug #7161: Perf fix: use symbols instead of strings for const/ivar 
access methods
https://bugs.ruby-lang.org/issues/7161#change-32452

Author: headius (Charles Nutter)
Status: Assigned
Priority: Normal
Assignee: shyouhei (Shyouhei Urabe)
Category:
Target version:
ruby -v: 2.0.0


From pull request: https://github.com/ruby/ruby/pull/195

Fixes a number of places where literal, non-dynamic strings are used as 
the first argument for constant and instance variable get, set, and 
defined? methods. This reduces object overhead in all cases.

Notable fixes:

* Setting @original_filename and @content_type in read_multipart 
(cgi/core.rb). This is called for every multipart read.
* Setting @uri and @ref in DrbObject.new_with (drb/drb.rb). Called for 
every "with" instantiation of a DrbObject.
* Setting BINDING_QUEUE in IRB::Workspace#initialize (irb/workspace.rb). 
Called for every new IRB workspace.
* Getting @mon_mutex in ConditionVariable#wait (monitor.rb). Called for 
every #wait. This fix makes the method require zero object allocation 
(other than imposed by the runtime).

The other fixes are rarely called, but fixed for consistency.

make test-all passes the same with or without this patch.
Posted by Charles Nutter (headius)
on 2012-11-16 16:38
(Received via mailing list)
Issue #7161 has been updated by headius (Charles Nutter).


Ping!
----------------------------------------
Bug #7161: Perf fix: use symbols instead of strings for const/ivar 
access methods
https://bugs.ruby-lang.org/issues/7161#change-32966

Author: headius (Charles Nutter)
Status: Assigned
Priority: Normal
Assignee: shyouhei (Shyouhei Urabe)
Category:
Target version:
ruby -v: 2.0.0


From pull request: https://github.com/ruby/ruby/pull/195

Fixes a number of places where literal, non-dynamic strings are used as 
the first argument for constant and instance variable get, set, and 
defined? methods. This reduces object overhead in all cases.

Notable fixes:

* Setting @original_filename and @content_type in read_multipart 
(cgi/core.rb). This is called for every multipart read.
* Setting @uri and @ref in DrbObject.new_with (drb/drb.rb). Called for 
every "with" instantiation of a DrbObject.
* Setting BINDING_QUEUE in IRB::Workspace#initialize (irb/workspace.rb). 
Called for every new IRB workspace.
* Getting @mon_mutex in ConditionVariable#wait (monitor.rb). Called for 
every #wait. This fix makes the method require zero object allocation 
(other than imposed by the runtime).

The other fixes are rarely called, but fixed for consistency.

make test-all passes the same with or without this patch.
Posted by marcandre (Marc-Andre Lafortune) (Guest)
on 2012-11-16 18:45
(Received via mailing list)
Issue #7161 has been updated by marcandre (Marc-Andre Lafortune).

Category set to lib
Status changed from Assigned to Closed

Committed as r37688.

I'm sorry, I should have added 'patch by Charles Nutter' to the commit 
log but I forgot that although git can track authors, svn does not.
----------------------------------------
Bug #7161: Perf fix: use symbols instead of strings for const/ivar 
access methods
https://bugs.ruby-lang.org/issues/7161#change-32985

Author: headius (Charles Nutter)
Status: Closed
Priority: Normal
Assignee: shyouhei (Shyouhei Urabe)
Category: lib
Target version:
ruby -v: 2.0.0


From pull request: https://github.com/ruby/ruby/pull/195

Fixes a number of places where literal, non-dynamic strings are used as 
the first argument for constant and instance variable get, set, and 
defined? methods. This reduces object overhead in all cases.

Notable fixes:

* Setting @original_filename and @content_type in read_multipart 
(cgi/core.rb). This is called for every multipart read.
* Setting @uri and @ref in DrbObject.new_with (drb/drb.rb). Called for 
every "with" instantiation of a DrbObject.
* Setting BINDING_QUEUE in IRB::Workspace#initialize (irb/workspace.rb). 
Called for every new IRB workspace.
* Getting @mon_mutex in ConditionVariable#wait (monitor.rb). Called for 
every #wait. This fix makes the method require zero object allocation 
(other than imposed by the runtime).

The other fixes are rarely called, but fixed for consistency.

make test-all passes the same with or without this patch.
Posted by Charles Nutter (headius)
on 2012-11-17 11:10
(Received via mailing list)
Issue #7161 has been updated by headius (Charles Nutter).


I'll forgive you this time, Marc-Andre :)
----------------------------------------
Bug #7161: Perf fix: use symbols instead of strings for const/ivar 
access methods
https://bugs.ruby-lang.org/issues/7161#change-33014

Author: headius (Charles Nutter)
Status: Closed
Priority: Normal
Assignee: shyouhei (Shyouhei Urabe)
Category: lib
Target version:
ruby -v: 2.0.0


From pull request: https://github.com/ruby/ruby/pull/195

Fixes a number of places where literal, non-dynamic strings are used as 
the first argument for constant and instance variable get, set, and 
defined? methods. This reduces object overhead in all cases.

Notable fixes:

* Setting @original_filename and @content_type in read_multipart 
(cgi/core.rb). This is called for every multipart read.
* Setting @uri and @ref in DrbObject.new_with (drb/drb.rb). Called for 
every "with" instantiation of a DrbObject.
* Setting BINDING_QUEUE in IRB::Workspace#initialize (irb/workspace.rb). 
Called for every new IRB workspace.
* Getting @mon_mutex in ConditionVariable#wait (monitor.rb). Called for 
every #wait. This fix makes the method require zero object allocation 
(other than imposed by the runtime).

The other fixes are rarely called, but fixed for consistency.

make test-all passes the same with or without this patch.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.