Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve stackprof measure #243

Merged
merged 1 commit into from
Jun 5, 2021
Merged

Improve stackprof measure #243

merged 1 commit into from
Jun 5, 2021

Conversation

BuonOmo
Copy link
Contributor

@BuonOmo BuonOmo commented May 27, 2021

Allow usage of more detailed args when setting stackprof callback.


Hi,

Since this is my first contrib here please tell me if there is anything I could improve.

On tests, looking at what is written already it seems that they are designed only for critical processes. If it is not the case, I can add some.

On my addition to the Gemfile, it felt important to me that when developing, one should be able to try all features without needing to pollute its global gems.

Cheers,
Ulysse

Gemfile Outdated
@@ -10,4 +10,5 @@ group :development do
gem 'vterm', '>= 0.0.5' if is_unix && ENV['WITH_VTERM']
gem 'yamatanooroti', '>= 0.0.6'
gem "rake"
gem "stackprof"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stackprof gem supports only Linux-based OS officially, it's a problem when developing on Windows. Could you use the variable is_unix, which is just above?

Copy link
Contributor Author

@BuonOmo BuonOmo Jun 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@aycabta, may I ask an unrelated (rdoc) question? I'm having a great pain handling metaprogramming (that basically aliases then override original methods) and keeping original documentation, & even better: adding documentation for the dynamically aliased methods. Do you know where I could get more information on that, or where I could talk to RDoc champions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, Net::HTTPResponse.ancestors is equal to [Net::HTTPResponse, Net::HTTPHeader, Object, PP::ObjectMixin, Kernel, BasicObject]. So, Net::HTTPResponse#decode_content overrides Net::HTTPGenericRequest#decode_content, and the documents also overrides (You can check them by commands, ri 'Net::HTTPGenericRequest#decode_content' and ri 'Net::HTTPResponse#decode_content'). On the other hand, Net::HTTPGenericRequest#[]= overrides Net::HTTPHeader#[]=, but ri 'Net::HTTPGenericRequest#[]=' shows "Implementation from HTTPHeader" because Net::HTTPGenericRequest#[]= has no documents. It means "the document of Net::HTTPGenericRequest#[]= doesn't override the document of Net::HTTPHeader#[]=". RDoc tracks inheritance relationships and method traversals accurately (as long as there are no bugs).

However, overriding a method complicates the story.

# a.rb

class A
  # Doc of method "a".
  def a
  end
end
# b.rb

require 'a'

class A
  # The second doc of method "a"
  def a
  end
end
$ rdoc -o doc_a -f ri a.rb
$ rdoc -o doc_b -f ri b.rb
$ ri -d doc_a -d doc_b 'A#a'
= A#a
(from /home/aycabta/ruby/rdoc/doc_a)
------------------------------------------------------------------------
  a()
------------------------------------------------------------------------
Doc of method "a".

(from /home/aycabta/ruby/rdoc/doc_b)
------------------------------------------------------------------------
  a()
------------------------------------------------------------------------
The second doc of method "a"
# c.rb

class A
  # Doc of method "a".
  def a
  end
end

class A
  # The second doc of method "a"
  def a
  end
end
$ rdoc -o doc_c -f ri c.rb
$ ri -d doc_c 'A#a'
= A#a
(from /home/aycabta/ruby/rdoc/doc_c)
------------------------------------------------------------------------
  a()
------------------------------------------------------------------------
Doc of method "a".
$ rdoc -o doc_ab -f ri a.rb b.rb
$ ri -d doc_ab 'A#a'
= A#a
(from /home/aycabta/ruby/rdoc/doc_ab)
------------------------------------------------------------------------
  a()
------------------------------------------------------------------------
Doc of method "a".

This means that "A namespace can only have one document per output directory" and "A namespace can have multiple documents if the output directory is different". So a namespace with multiple documents by the "override" in a single project can only have one document in one output directory. However, I feel this is sometimes a problem. If necessary, it might be possible to tie multiple documents in a single project to a single namespace. Please raise an issue in ruby/rdoc if you need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the clear answer, I don't think the method overriding will be a problem for our repo (https://github.com/rgeo/rgeo) but I'll keep that in mind.

In the end we did find an issue where the doc was not propagated correctly, one colleague of mine should open a PR soon :)

Allow usage of more detailed args when setting stackprof callback.

Signed-off-by: Ulysse Buonomo <[email protected]>
Copy link
Member

@aycabta aycabta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, CI still fails but it's just for testing on TruffleRuby, I'll fix it later.

@aycabta aycabta merged commit 21d2473 into ruby:master Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants