Hello Mauricio,
Wednesday, October 23, 2002, 7:04:16 PM, you wrote:
Would it be possible for Ruby to know whether an object is referenced by
several variables so += does ‘<<’ or ‘… = … + …’ when appropriate?
operation 1
Perhaps a bit in each String indicating whether it is shared or
not would make it… and GC issues could be ignored at first.
operation 2
Yeah, KISS applies always, but I may anyway try to implement this in the
future for the following reasons:
- the modification seems easy enough
- I will possibly learn more about Ruby’s internals in the process
- if it’s simple and makes Ruby faster, what can be wrong about it?
i think, this will not make ruby faster. to begin, just add to
interpreter counting of both operations. i think, number of operations
2 will be much higher. second, it will definitely make ruby FATter
(one more bit per String variable)
···
–
Best regards,
Bulat mailto:bulatz@integ.ru
Hi batsman,
I consider the use of ‘<<’ when possible to be nothing but a slight
optimization which might (or not) prove to make Ruby faster.
You can do a “incomplete RC” (in fact I think something like that was
already used in Ruby, somewhere), for the common case where an object is
referenced only once. If another variable references it, set a “shared
bit” to 1, and that’s it. so you don’t have to do complete RC which
would be expensive.
If you do “incomplete RC”, basically you have to find all the places where
a variable (or another object) may start referring to an object. Do you
have any thought of assessing a “complete RC” implementation? I know that
the amount of work by going from “no RC” to “complete RC” is more than
twice of going from “no RC” to “incomplete RC” as currently Ruby uses
mark & sweep (M&S) gc (and therefore there exist a bunch of
“new” functions but not a complete set of “delete” functions.)
Well, Python started with RC and then added M&S. Ruby started with M&S
and now the RC is being considered. I don’t know which direction is
harder or both are equally as hard. I am just thinking that it will
be very nice if we can select the Ruby gc mode.
What I was thinking of isn’t really GC, but a rather elaborated COW with
some help from the AST interpreter.
AFAIK, I’d only have to care about multiple references to the same
String, and the only ways I can think of right now are assignment and
closures.
Are there any other?
I plan to learn on Ruby’s AST interpretation, as I’ve been reading other
parts of the code w/o any problem, but that one seems quite more
complex.
PS: I’m getting a computer of my own next week, and as I’m gonna have a
lot of free time, I may try this and other different tricks on Ruby’s
implementation, following my new policy on how to improve Ruby [52838]
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/52838
Good luck on your quest and have fun with your new computer.
Having to use the ones from the computer pools sucks, and these german
people close them around 7pm. What are they thinking about???
Hopefully in a week I’ll be typing messages as this one from my own dorm,
and I’ll at last be able to do some real work on Ruby 
···
On Thu, Oct 24, 2002 at 12:39:53AM +0900, William Djaja Tjokroaminata wrote:
Mauricio Fern?ndez batsman.geo@yahoo.com wrote:
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
Just go ahead and write your own multitasking multiuser os!
Worked for me all the times.
– Linus Torvalds
Hi Bulat,
I am not sure if it will make ruby fatter; I cannot verify whether
currently we still have extra free (unused) bits in the ‘flags’ member of
RBasic.
Regards,
Bill
···
Bulat Ziganshin bulatz@integ.ru wrote:
second, it will definitely make ruby FATter
(one more bit per String variable)> –
Hi batsman,
I guess then basically the optimization will work only with Ruby
scripts. If a person creates a C extension (and mixing Ruby scripts and C
function calls) then this optimization should be disabled.
Regards,
Bill
···
==========================================================================
Mauricio Fern?ndez batsman.geo@yahoo.com wrote:
AFAIK, I’d only have to care about multiple references to the same
String, and the only ways I can think of right now are assignment and
closures.
Are there any other?
Writing extensions is always quite unsafe, so we’re already trusting the
developer not to bomb Ruby’s internals from C. It would be easy to add
something like rb_set_dirty_bit() so things don’t get nasty when
keeping several references in C.
···
On Thu, Oct 24, 2002 at 07:21:38AM +0900, William Djaja Tjokroaminata wrote:
Hi batsman,
I guess then basically the optimization will work only with Ruby
scripts. If a person creates a C extension (and mixing Ruby scripts and C
function calls) then this optimization should be disabled.
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
Those who don’t understand Linux are doomed to reinvent it, poorly.
– unidentified source
Hi batsman,
I think there are already existing Ruby applications/library/extensions
that are written in part in C (that have references to Ruby objects). I
don’t think we can expect all of them to add rb_set_dirty_bit().
Regards,
Bill
···
Mauricio Fern?ndez batsman.geo@yahoo.com wrote:
Writing extensions is always quite unsafe, so we’re already trusting the
developer not to bomb Ruby’s internals from C. It would be easy to add
something like rb_set_dirty_bit() so things don’t get nasty when
keeping several references in C.
How many do need several references to the same string from the C side?
If the number is high enough (ie, > a couple of them) doing this would
be pointless 
Bah, just have to find another thing to work on 
···
On Thu, Oct 24, 2002 at 10:22:53PM +0900, William Djaja Tjokroaminata wrote:
Mauricio Fern?ndez batsman.geo@yahoo.com wrote:
Writing extensions is always quite unsafe, so we’re already trusting the
developer not to bomb Ruby’s internals from C. It would be easy to add
something like rb_set_dirty_bit() so things don’t get nasty when
keeping several references in C.
Hi batsman,
I think there are already existing Ruby applications/library/extensions
that are written in part in C (that have references to Ruby objects). I
don’t think we can expect all of them to add rb_set_dirty_bit().
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
eat Depends: cook | eat-out.
But eat-out is non-free so that’s out.
And cook Recommends: clean-pans.
– Seen on #Debian
Hi batsman,
I think the point is not how many but just if there exists some C code
that may have more than one references to a Ruby object.
Also, are you trying to do this only for the String objects? (i.e., “aStr
+=” means “aStr <<” if there is only one reference count to the
object referred to by aStr.)
Regards,
Bill
···
Mauricio Fern?ndez batsman.geo@yahoo.com wrote:
How many do need several references to the same string from the C side?
If the number is high enough (ie, > a couple of them) doing this would
be pointless 
Bah, just have to find another thing to work on 
How many do need several references to the same string from the C side?
If the number is high enough (ie, > a couple of them) doing this would
be pointless 
Bah, just have to find another thing to work on 
Hi batsman,
I think the point is not how many but just if there exists some C code
that may have more than one references to a Ruby object.
I was thinking ‘how many’ because I could always “fix” them if it’s only
a couple.
Also, are you trying to do this only for the String objects? (i.e., “aStr
+=” means “aStr <<” if there is only one reference count to the
object referred to by aStr.)
Two things here:
- I was considering this a “one-time hack” only for String objects, as
a simple exercise to get to know Ruby’s AST interpretation
- it would only work for String, as it is a class we understand fairly
well, and I cannot think of any circumstances (in Ruby code, of
course) that require “+=” to create a new object but those I cited
previously.
Better forget about it; I might do it on my own but it seems it has
little — if any — value but the educational one 
killall -9 this-thread
···
On Thu, Oct 24, 2002 at 11:23:05PM +0900, William Djaja Tjokroaminata wrote:
Mauricio Fern?ndez batsman.geo@yahoo.com wrote:
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
No, that’s wrong too. Now there’s a race condition between the rm and
the mv. Hmm, I need more coffee.
– Guy Maor on Debian Bug#25228