ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:69955] [Ruby trunk - Feature #11348] [Open] TracePoint API needs events for fiber's switching
       [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
@ 2015-07-13 14:02 ` os97673
  2015-08-10  1:39 ` [ruby-core:70289] [Ruby trunk - Feature #11348] [Assigned] " nagachika00
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: os97673 @ 2015-07-13 14:02 UTC (permalink / raw)
  To: ruby-core

Issue #11348 has been reported by Oleg Sukhodolsky.

----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348

* Author: Oleg Sukhodolsky
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used.  The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event.

It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently.
Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities.
E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called.
So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions.

Here are two tests which can be used to play with (one for Enumerator, another for Fiber)

~~~ruby
triangular_numbers = Enumerator.new do |yielder|
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    yielder.yield number
  end
end

print triangular_numbers.next, " "

5.times do
  print triangular_numbers.next, " "
end
~~~

~~~ruby
fiber = Fiber.new do
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    Fiber.yield number
  end
end

print fiber.resume, " "

5.times do
  print fiber.resume, " "
end
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:70289] [Ruby trunk - Feature #11348] [Assigned] TracePoint API needs events for fiber's switching
       [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
  2015-07-13 14:02 ` [ruby-core:69955] [Ruby trunk - Feature #11348] [Open] TracePoint API needs events for fiber's switching os97673
@ 2015-08-10  1:39 ` nagachika00
  2015-08-21  9:56 ` [ruby-core:70506] [Ruby trunk - Feature #11348] [Feedback] " ko1
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nagachika00 @ 2015-08-10  1:39 UTC (permalink / raw)
  To: ruby-core

Issue #11348 has been updated by Tomoyuki Chikanaga.

Status changed from Open to Assigned
Assignee set to Koichi Sasada

----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348#change-53711

* Author: Oleg Sukhodolsky
* Status: Assigned
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used.  The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event.

It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently.
Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities.
E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called.
So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions.

Here are two tests which can be used to play with (one for Enumerator, another for Fiber)

~~~ruby
triangular_numbers = Enumerator.new do |yielder|
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    yielder.yield number
  end
end

print triangular_numbers.next, " "

5.times do
  print triangular_numbers.next, " "
end
~~~

~~~ruby
fiber = Fiber.new do
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    Fiber.yield number
  end
end

print fiber.resume, " "

5.times do
  print fiber.resume, " "
end
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:70506] [Ruby trunk - Feature #11348] [Feedback] TracePoint API needs events for fiber's switching
       [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
  2015-07-13 14:02 ` [ruby-core:69955] [Ruby trunk - Feature #11348] [Open] TracePoint API needs events for fiber's switching os97673
  2015-08-10  1:39 ` [ruby-core:70289] [Ruby trunk - Feature #11348] [Assigned] " nagachika00
@ 2015-08-21  9:56 ` ko1
  2015-08-21 12:42 ` [ruby-core:70514] [Ruby trunk - Feature #11348] " os97673
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ko1 @ 2015-08-21  9:56 UTC (permalink / raw)
  To: ruby-core

Issue #11348 has been updated by Koichi Sasada.

Status changed from Closed to Feedback

I agree to add 'switching' events so I try to commit it.

Could you try it and could you tell me "what" is not enough?

(Actually, I don't increase the number of events)

For example, how about to provide a method to know resume chain like that?

```ruby
Fiber.new{ # f1
  Fiber.new{ # f2
    Fiber.nesting #=> [root_fiber, f1, f2]
  }
}
```

(not sure nesting is good name or not)


----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348#change-53906

* Author: Oleg Sukhodolsky
* Status: Feedback
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used.  The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event.

It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently.
Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities.
E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called.
So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions.

Here are two tests which can be used to play with (one for Enumerator, another for Fiber)

~~~ruby
triangular_numbers = Enumerator.new do |yielder|
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    yielder.yield number
  end
end

print triangular_numbers.next, " "

5.times do
  print triangular_numbers.next, " "
end
~~~

~~~ruby
fiber = Fiber.new do
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    Fiber.yield number
  end
end

print fiber.resume, " "

5.times do
  print fiber.resume, " "
end
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:70514] [Ruby trunk - Feature #11348] TracePoint API needs events for fiber's switching
       [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-08-21  9:56 ` [ruby-core:70506] [Ruby trunk - Feature #11348] [Feedback] " ko1
@ 2015-08-21 12:42 ` os97673
  2015-08-25 13:08 ` [ruby-core:70591] " os97673
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: os97673 @ 2015-08-21 12:42 UTC (permalink / raw)
  To: ruby-core

Issue #11348 has been updated by Oleg Sukhodolsky.


Koichi Sasada wrote:
> I agree to add 'switching' events so I try to commit it.
> 
> Could you try it and could you tell me "what" is not enough?

I'm on vacation right now will play with ruby-head early next week.

----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348#change-53916

* Author: Oleg Sukhodolsky
* Status: Feedback
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used.  The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event.

It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently.
Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities.
E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called.
So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions.

Here are two tests which can be used to play with (one for Enumerator, another for Fiber)

~~~ruby
triangular_numbers = Enumerator.new do |yielder|
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    yielder.yield number
  end
end

print triangular_numbers.next, " "

5.times do
  print triangular_numbers.next, " "
end
~~~

~~~ruby
fiber = Fiber.new do
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    Fiber.yield number
  end
end

print fiber.resume, " "

5.times do
  print fiber.resume, " "
end
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:70591] [Ruby trunk - Feature #11348] TracePoint API needs events for fiber's switching
       [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-08-21 12:42 ` [ruby-core:70514] [Ruby trunk - Feature #11348] " os97673
@ 2015-08-25 13:08 ` os97673
  2015-09-01  8:57 ` [ruby-core:70642] " ko1
  2015-09-01  9:12 ` [ruby-core:70645] " os97673
  6 siblings, 0 replies; 8+ messages in thread
From: os97673 @ 2015-08-25 13:08 UTC (permalink / raw)
  To: ruby-core

Issue #11348 has been updated by Oleg Sukhodolsky.


Oleg Sukhodolsky wrote:
> Koichi Sasada wrote:
> > I agree to add 'switching' events so I try to commit it.
> > 
> > Could you try it and could you tell me "what" is not enough?

I've played with the event a little bit and here is what I think.
Suppose we have the following program:

~~~ruby
f1 = Fiber.new do
  loop do
    Fiber.yield 1
  end
end
f1.resume # stopped at the line
f1.resume # want to stop here after step over
f1.resume
f1.resume
~~~

To implement expected behavior debugger (debase/byebug) store current stack size and stops at next line event with the same (or lower) stack size.
To handle fibers I would expect to use pair (fiber-stack-size, stack-size) and stop only if current fiber stack size is less than original or fiber stack sizes are equal and stack-size is equal or less than original (if you have better idea how to implement this feel free to share it with me).
So to implement this approach we need to detect fiber switch AND figure out if it was "fiber call" or "fiber return"  to be able to do this we either need to have two different events, or Fiber.nesting call you propose should help as at the moment we receive "fiber-switch" event, or (worse case for debugger) store the information about the switch and detect if it was call/return at next event we will process.  The latter is more complicated for debugger than 1 or 2.

Thus I'd prefer to have fiber-call/fiber-return, or be able to detect direction of the switch at the moment debugger is processing "fiber-switch".
Does this looks reasonable for you?  Is it doable on Ruby VM side? Do you have another ideas about implementing the debugger's functionality?

----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348#change-53997

* Author: Oleg Sukhodolsky
* Status: Feedback
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used.  The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event.

It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently.
Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities.
E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called.
So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions.

Here are two tests which can be used to play with (one for Enumerator, another for Fiber)

~~~ruby
triangular_numbers = Enumerator.new do |yielder|
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    yielder.yield number
  end
end

print triangular_numbers.next, " "

5.times do
  print triangular_numbers.next, " "
end
~~~

~~~ruby
fiber = Fiber.new do
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    Fiber.yield number
  end
end

print fiber.resume, " "

5.times do
  print fiber.resume, " "
end
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:70642] [Ruby trunk - Feature #11348] TracePoint API needs events for fiber's switching
       [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2015-08-25 13:08 ` [ruby-core:70591] " os97673
@ 2015-09-01  8:57 ` ko1
  2015-09-01  9:12 ` [ruby-core:70645] " os97673
  6 siblings, 0 replies; 8+ messages in thread
From: ko1 @ 2015-09-01  8:57 UTC (permalink / raw)
  To: ruby-core

Issue #11348 has been updated by Koichi Sasada.


> f1.resume # stopped at the line
> f1.resume # want to stop here after step over

Only for this purpose, how about to stop every fiber switching? It is true that the program enter newline!


----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348#change-54043

* Author: Oleg Sukhodolsky
* Status: Feedback
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used.  The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event.

It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently.
Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities.
E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called.
So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions.

Here are two tests which can be used to play with (one for Enumerator, another for Fiber)

~~~ruby
triangular_numbers = Enumerator.new do |yielder|
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    yielder.yield number
  end
end

print triangular_numbers.next, " "

5.times do
  print triangular_numbers.next, " "
end
~~~

~~~ruby
fiber = Fiber.new do
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    Fiber.yield number
  end
end

print fiber.resume, " "

5.times do
  print fiber.resume, " "
end
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:70645] [Ruby trunk - Feature #11348] TracePoint API needs events for fiber's switching
       [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2015-09-01  8:57 ` [ruby-core:70642] " ko1
@ 2015-09-01  9:12 ` os97673
  2015-09-01  9:53   ` [ruby-core:70648] " SASADA Koichi
  6 siblings, 1 reply; 8+ messages in thread
From: os97673 @ 2015-09-01  9:12 UTC (permalink / raw)
  To: ruby-core

Issue #11348 has been updated by Oleg Sukhodolsky.


Koichi Sasada wrote:
> > f1.resume # stopped at the line
> > f1.resume # want to stop here after step over
> 
> Only for this purpose, how about to stop every fiber switching? It is true that the program enter newline!

I'm not sure I've completely understand you suggestion :(  Could you please clarify?
I've provided the example ask how to guarantee that we will not stop somewhere inside f1's implementation.

----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348#change-54046

* Author: Oleg Sukhodolsky
* Status: Feedback
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used.  The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event.

It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently.
Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities.
E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called.
So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions.

Here are two tests which can be used to play with (one for Enumerator, another for Fiber)

~~~ruby
triangular_numbers = Enumerator.new do |yielder|
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    yielder.yield number
  end
end

print triangular_numbers.next, " "

5.times do
  print triangular_numbers.next, " "
end
~~~

~~~ruby
fiber = Fiber.new do
  number = 0
  count = 1
  loop do
    number += count
    count += 1
    Fiber.yield number
  end
end

print fiber.resume, " "

5.times do
  print fiber.resume, " "
end
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:70648] Re: [Ruby trunk - Feature #11348] TracePoint API needs events for fiber's switching
  2015-09-01  9:12 ` [ruby-core:70645] " os97673
@ 2015-09-01  9:53   ` SASADA Koichi
  0 siblings, 0 replies; 8+ messages in thread
From: SASADA Koichi @ 2015-09-01  9:53 UTC (permalink / raw)
  To: ruby-core

On 2015/09/01 18:12, os97673@gmail.com wrote:
> I've provided the example ask how to guarantee that we will not stop somewhere inside f1's implementation.

Why you don't want to stop in a fiber?

-- 
// SASADA Koichi at atdot dot net

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-09-01  9:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-11348.20150713140158@ruby-lang.org>
2015-07-13 14:02 ` [ruby-core:69955] [Ruby trunk - Feature #11348] [Open] TracePoint API needs events for fiber's switching os97673
2015-08-10  1:39 ` [ruby-core:70289] [Ruby trunk - Feature #11348] [Assigned] " nagachika00
2015-08-21  9:56 ` [ruby-core:70506] [Ruby trunk - Feature #11348] [Feedback] " ko1
2015-08-21 12:42 ` [ruby-core:70514] [Ruby trunk - Feature #11348] " os97673
2015-08-25 13:08 ` [ruby-core:70591] " os97673
2015-09-01  8:57 ` [ruby-core:70642] " ko1
2015-09-01  9:12 ` [ruby-core:70645] " os97673
2015-09-01  9:53   ` [ruby-core:70648] " SASADA Koichi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).