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

How are calls being counted? #23

Open
ghost opened this issue Oct 1, 2013 · 5 comments
Open

How are calls being counted? #23

ghost opened this issue Oct 1, 2013 · 5 comments

Comments

@ghost
Copy link

ghost commented Oct 1, 2013

I got the following result from 100 iterations of the method and I'm wondering how rblineprof comes up with these counts.

                   | module Aeee
                   |   class Request
                   |     attr_reader :finished, :banana
                   | 
                   |     attr_reader :http_method, :uri, :headers, :body
                   |     attr_reader :http_version
                   | 
                   |     def initialize(http_method, uri, headers = {}, body = '', http_version = 1.1)
                   |       @http_method, @uri = http_method, uri
                   |       @headers, @body = headers, body
                   |       @http_version = http_version
                   | 
     0.6ms (  600) |       @finished, @banana = Promise.new, Promise.new
                   |     end
                   | 
                   |     def self.build(parser)
     0.3ms (  300) |       http_method = parser.http_method.downcase.to_sym
     3.2ms (  200) |       uri = URI('http://' + parser.request_url)
     0.1ms (  100) |       headers = parser.headers
     0.7ms (  500) |       http_version = parser.http_version.join('.').to_f
                   | 
     1.4ms (  400) |       new(http_method, uri.request_uri, headers, '', http_version)
                   |     end
                   |   end
                   | end

In the first three lines of self.build, it seems to count the number of method calls, but from then on I have no idea. Might there be a problem with Fibers? Each of the iterations was running in its own Fiber, with roughly 10 running concurrently - although clearly none should have been interrupted (Promise.new doesn't yield either).

Edit: the actual code is on its way...

@tmm1
Copy link
Owner

tmm1 commented Oct 1, 2013

It's a number of "events", that loosely correlates to number of method calls. It depends on the exact version of ruby and VM optimizations enabled.

@ghost
Copy link
Author

ghost commented Oct 1, 2013

The same events as in Kernel#set_trace_func?

@ghost
Copy link
Author

ghost commented Oct 1, 2013

Briefly looking at the code it looks like we could increase the counter in profiler_hook instead of stackframe_record, which is called for every event. Once per "stack frame entry", which seems to more closely correlate to method calls.

Giving it a try.

@ghost
Copy link
Author

ghost commented Oct 1, 2013

Nevermind that idea, it's effectively the same as how it works now.

@ghost
Copy link
Author

ghost commented Oct 1, 2013

I came up with lgierth/rblineprof@6517ddc, it's supposed to skip the frame if its file and line equal the previous frame's file and line. Doesn't work yet, but I'll figure it out - my first C steps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant