Was asked to repost this under a separate thread, so here it is!
Currently we have
IO#write_nonblock(string) [writes as much of the string as currently
possible]
What I was thinking would be useful would be
IO#write_nonblock(string, offset) [starts the write at offset bytes into
the string].
Would anybody else find this useful?
Thanks!
-=R
···
--
Posted via http://www.ruby-forum.com/.
Roger Pack wrote:
Was asked to repost this under a separate thread, so here it is!
Currently we have
IO#write_nonblock(string) [writes as much of the string as currently
possible]
What I was thinking would be useful would be
IO#write_nonblock(string, offset) [starts the write at offset bytes into
the string].
Would anybody else find this useful?
Thanks!
With COW strings, is this really needed?
s = (0..9).to_a.to_s * 1000000
sa = (1..10000).map {|i| s[i..-1]}
puts `cat /proc/#{$$}/status`[/VmRSS:\s*(.*)/,1] # 13292 kB
Is there a reason other than saving memory and avoiding a #slice call?
···
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Rob Biedenharn wrote:
Rob, are you aware that your message body is empty, at least on ruby-talk. Are you posting from the forum or newsgroup?
···
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
puts `cat /proc/#{$$}/status`[/VmRSS:\s*(.*)/,1] # 13292 kB
Is there a reason other than saving memory and avoiding a #slice call?
Those would be the reasons I'd consider it useful--to save on CPU and
RAM [since it would avoid having to create all those extra objects]. I
think that's what you were pointing out?
Thanks!
-=R
···
--
Posted via http://www.ruby-forum.com/\.
Hi Rob,
i've noticed loss of the message with some of you other posts, too,
the most recent group starting from the Chris Pine tutorial thread.
Todd
···
On Tue, Sep 2, 2008 at 2:29 PM, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:
Rob Biedenharn wrote:
Rob, are you aware that your message body is empty, at least on ruby-talk.
Are you posting from the forum or newsgroup?
From email (therefore the newsgroup). This happens when I forget to uncheck the "digitally signed" option. What I meant to say was:
I presume that the IO#write_nonblock returns the number of bytes written (which the write(2) man page says, but is only implied by the rdoc).
Assuming this is the case (and the method will become IO#write_nonblock(string, offset=0)), I'd think that this was a good idea. (Even though I've never had to use it.)
-Rob
Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
···
On Sep 2, 2008, at 3:29 PM, Joel VanderWerf wrote:
Rob Biedenharn wrote:
Rob, are you aware that your message body is empty, at least on ruby-talk. Are you posting from the forum or newsgroup?
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Roger Pack wrote:
puts `cat /proc/#{$$}/status`[/VmRSS:\s*(.*)/,1] # 13292 kB
Is there a reason other than saving memory and avoiding a #slice call?
Those would be the reasons I'd consider it useful--to save on CPU and RAM [since it would avoid having to create all those extra objects]. I think that's what you were pointing out?
It's just that those extra objects are fairly small, due to copy-on-write... just the 20 byte ruby RString object for each slice rather than a copy of the whole 1Mb string you are trying to send. They share the 1Mb string data.
···
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
It's just that those extra objects are fairly small, due to
copy-on-write... just the 20 byte ruby RString object for each slice
rather than a copy of the whole 1Mb string you are trying to send. They
share the 1Mb string data.
Fascinating. Thanks for pointing that out. I guess that being the case
then it'd be only a small improvement--10,000 slices on my machine takes
0.02s and calls the GC twice, so...there's some room for improvement,
but it's probably not a bottleneck.]
Thanks!
-=R
···
--
Posted via http://www.ruby-forum.com/\.