Forum: Ruby-core [ruby-trunk - Feature #7393][Open] Fix array behaviour when it is used as a queue: github#174

Posted by zzak (Zachary Scott) (Guest)
on 2012-11-19 04:18
(Received via mailing list)
Issue #7393 has been reported by zzak (Zachary Scott).

----------------------------------------
Feature #7393: Fix array behaviour when it is used as a queue: 
github#174
https://bugs.ruby-lang.org/issues/7393

Author: zzak (Zachary Scott)
Status: Open
Priority: Normal
Assignee: mame (Yusuke Endoh)
Category: core
Target version: 2.0.0


=begin
from github:
https://github.com/ruby/ruby/pull/174

When array is used intensively as a queue (ie repeated push/shift 
calls), then its performance degrades very quickly with array's size 
(especially when almost every shift is followed be push), cause each 
push which is called after shift leads to allocation of new memory space 
and copying all items to.

This pull request fixes it in following way:

* reuse shared array's storage when array is a single owner of shared 
array.
* try to push items directly into shared array when array is a single 
owner of shared array
* try to unshift items directly into shared array when array is a single 
owner (and allocate room for futher unshifts)
=end
Posted by nagachika (Tomoyuki Chikanaga) (Guest)
on 2012-11-19 04:28
(Received via mailing list)
Issue #7393 has been updated by nagachika (Tomoyuki Chikanaga).


Hi,

I think the pull request was merged to trunk as r37581-r37584.

----------------------------------------
Feature #7393: Fix array behaviour when it is used as a queue: 
github#174
https://bugs.ruby-lang.org/issues/7393#change-33080

Author: zzak (Zachary Scott)
Status: Open
Priority: Normal
Assignee: mame (Yusuke Endoh)
Category: core
Target version: 2.0.0


=begin
from github:
https://github.com/ruby/ruby/pull/174

When array is used intensively as a queue (ie repeated push/shift 
calls), then its performance degrades very quickly with array's size 
(especially when almost every shift is followed be push), cause each 
push which is called after shift leads to allocation of new memory space 
and copying all items to.

This pull request fixes it in following way:

* reuse shared array's storage when array is a single owner of shared 
array.
* try to push items directly into shared array when array is a single 
owner of shared array
* try to unshift items directly into shared array when array is a single 
owner (and allocate room for futher unshifts)
=end
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-11-19 10:36
(Received via mailing list)
Issue #7393 has been updated by kosaki (Motohiro KOSAKI).

Status changed from Open to Closed


----------------------------------------
Feature #7393: Fix array behaviour when it is used as a queue: 
github#174
https://bugs.ruby-lang.org/issues/7393#change-33089

Author: zzak (Zachary Scott)
Status: Closed
Priority: Normal
Assignee: mame (Yusuke Endoh)
Category: core
Target version: 2.0.0


=begin
from github:
https://github.com/ruby/ruby/pull/174

When array is used intensively as a queue (ie repeated push/shift 
calls), then its performance degrades very quickly with array's size 
(especially when almost every shift is followed be push), cause each 
push which is called after shift leads to allocation of new memory space 
and copying all items to.

This pull request fixes it in following way:

* reuse shared array's storage when array is a single owner of shared 
array.
* try to push items directly into shared array when array is a single 
owner of shared array
* try to unshift items directly into shared array when array is a single 
owner (and allocate room for futher unshifts)
=end
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.