Comments (9)
3-4ms per db call is pretty much impossible even when profiling, lets just clarify here, you don't have rack-mini-profiler enabled for all users on the site?
the work it performs when disabled is minuscule, it adds a method call and thread lookup.
from miniprofiler.
Nope, only enabled for logged in administrators and users from trusted IP addresses (eg, our office). For control I will re-add the gem but not include the before_filter that enables it in those cases.
from miniprofiler.
Restored the gem, and the configuration, but commented out the logic that enables it for admins & local users.
Very interesting!
Versions
rack-mini-profiler (0.1.26)
rails (3.2.13)
newrelic_rpm (3.6.2.96)
$ ruby --version
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
Configuration
# Don't show it by default, only if the user pressers alt-p
Rack::MiniProfiler.config.start_hidden = true
# Move to RHS
Rack::MiniProfiler.config.position = :right
Ruby compiled using RVM and the "falcon" patches as described at https://gist.github.com/funny-falcon/4136373
from miniprofiler.
How are you determining current user
see: https://github.com/discourse/discourse/blob/master/config/initializers/06-mini_profiler.rb
your Rack::MiniProfiler.config.user_provider
from miniprofiler.
We haven't set up anything fun with the user detection - it's still using the request IP, as is the default. I suspect there's a bug in our code which was making our authorization method fire incorrectly.
However, I found something else interesting. I set up a simple benchmark on the train this morning in one of our views:
%ul
- range = (Advert.minimum(:product_id)..Advert.maximum(:product_id)).to_a[0..1000]
%li= "Range: #{range.length} elements"
%li
= Benchmark.measure { range.each { |a| Advert.connection.select_value("SELECT title FROM adverts WHERE product_id = #{a}")} }
With MiniProfiler enabled I'd get: Range: 1001 elements 1.680000 0.070000 1.750000 ( 1.892392)
Without: 0.150000 0.020000 0.170000 ( 0.210001)
So, that's about 1.6ms added to each DB request. Remembering what you said about Ruby 1.9.3 and backtrace performance, I added pp=no-backtrace
to query. Doing so returned the performance back to pre-miniprofiler levels.
I started work on a PR to both add a skip-backtrace option to config and make it the default for Ruby versions pre 2.x. Thoughts?
from miniprofiler.
I would prefer not to make it default but would be more than happy to add the option
from miniprofiler.
Thinking about this over the weekend: I was thinking of instead adding an
option that omits stacktraces if the query takes less than a certain time
to execute.
This could then be set to a sane default on various rubies: ie 10ms for
Ruby 1.9, 0ms for Ruby 2.x.
My concern is that if you add MiniProfiler to a Ruby 1.9 project, and you
have lots of queries, you'll have a severe case of the observer changing
the observed.
Alternatively I could add something to the README.md about this instead.
On Mon, May 20, 2013 at 9:47 AM, Sam [email protected] wrote:
I would prefer not to make it default but would be more than happy to add
the option—
Reply to this email directly or view it on GitHubhttps://github.com//issues/156#issuecomment-18127124
.
Michael Pearson
from miniprofiler.
I'm happy to close this request now that my PR has been merged. Do you agree, @SamSaffron ?
from miniprofiler.
sure ... closing
from miniprofiler.
Related Issues (20)
- Add license to the gemspec HOT 1
- Step method to return the yield call returned data? HOT 2
- Rack::MiniProfiler.config HOT 1
- DbSpacial support
- skip_schema_queries setting seems to be ignored in development HOT 7
- MiniProfiler OnDeserialized method missing the StreamingContext parameter. HOT 2
- No support of jQuery 2 HOT 3
- MiniProfiler requires JQuery HOT 3
- StackExchange.Profiling.EntityFramework not working with EF5 HOT 1
- Internal Server Error HOT 4
- Doesnt Seem to be working with Mountable Rails engines HOT 4
- Unnecessary newline inject HOT 2
- Profiling results pile up in production
- Should implementations of IStorage be thread-safe?
- Uncaught TypeError: Object [object Object] has no method 'tmpl' HOT 1
- Error when running Ruby version in app with Sunspot HOT 2
- JavaScript erros in IE8 HOT 2
- Does MP work with DataMapper?
- Setup Continuous Integration HOT 2
- Add bottom left/right positions to RenderPosition argument
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miniprofiler.