Skip to content

Commit

Permalink
FEATURE: Use speedscope to display flamegraphs and switch from the fl…
Browse files Browse the repository at this point in the history
…amegraph gem to stackprof (#475)

Mini Profiler now ships with an embedded copy of speedscope which
provides a very nice experience for viewing flamegraphs.

Flamegraph has been replaced with the stackprof gem. It's an optional
dependency, so if you use the flamegraphs feature, you'll need to add
the `stackprof` gem to your `Gemfile` and require it. If you don't use
the feature, you don't need to add anything and Mini Profiler will work
just fine.
  • Loading branch information
OsamaSayegh authored Dec 28, 2020
1 parent d4a3e77 commit cc78c69
Show file tree
Hide file tree
Showing 17 changed files with 754 additions and 13 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ You can also include optional libraries to enable additional features.
gem 'memory_profiler'

# For call-stack profiling flamegraphs
gem 'flamegraph'
gem 'stackprof'
```

Expand Down Expand Up @@ -159,7 +158,7 @@ export RACK_MINI_PROFILER_PATCH="false"

To generate [flamegraphs](http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler):

* add the [**flamegraph**](https://github.com/SamSaffron/flamegraph) gem to your Gemfile
* add the [**stackprof**](https://rubygems.org/gems/stackprof) gem to your Gemfile
* visit a page in your app with `?pp=flamegraph`

### Memory Profiling
Expand Down
21 changes: 21 additions & 0 deletions lib/html/speedscope/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Jamie Wong

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions lib/html/speedscope/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains the necessary files and assets to run [speedscope](https://github.com/jlfwong/speedscope). If you wish to update speedscope to a new version, head over to the [releases](https://github.com/jlfwong/speedscope/releases) page on Github, download the `.zip` file of the release you want to upgrade to and unzip it right here inside this directory. Be sure to delete the `perf-vertx-stacks-01-collapsed-all.*.txt` and `README` files that are in the `.zip` file after you unzip it.

We're currently on version 1.12.1 of speedscope.
4 changes: 4 additions & 0 deletions lib/html/speedscope/demangle-cpp.1768f4cc.js

Large diffs are not rendered by default.

Binary file added lib/html/speedscope/favicon-16x16.f74b3187.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/html/speedscope/favicon-32x32.bc503437.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
324 changes: 324 additions & 0 deletions lib/html/speedscope/file-format-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"CloseFrameEvent": {
"properties": {
"at": {
"title": "at",
"type": "number"
},
"frame": {
"title": "frame",
"type": "number"
},
"type": {
"enum": [
"C"
],
"title": "type",
"type": "string"
}
},
"required": [
"at",
"frame",
"type"
],
"title": "CloseFrameEvent",
"type": "object"
},
"FileFormat.EventType": {
"enum": [
"C",
"O"
],
"title": "FileFormat.EventType",
"type": "string"
},
"FileFormat.EventedProfile": {
"properties": {
"endValue": {
"title": "endValue",
"type": "number"
},
"events": {
"items": {
"anyOf": [
{
"$ref": "#/definitions/OpenFrameEvent"
},
{
"$ref": "#/definitions/CloseFrameEvent"
}
]
},
"title": "events",
"type": "array"
},
"name": {
"title": "name",
"type": "string"
},
"startValue": {
"title": "startValue",
"type": "number"
},
"type": {
"enum": [
"evented"
],
"title": "type",
"type": "string"
},
"unit": {
"$ref": "#/definitions/FileFormat.ValueUnit",
"title": "unit"
}
},
"required": [
"endValue",
"events",
"name",
"startValue",
"type",
"unit"
],
"title": "FileFormat.EventedProfile",
"type": "object"
},
"FileFormat.File": {
"properties": {
"$schema": {
"enum": [
"https://www.speedscope.app/file-format-schema.json"
],
"title": "$schema",
"type": "string"
},
"activeProfileIndex": {
"title": "activeProfileIndex",
"type": "number"
},
"exporter": {
"title": "exporter",
"type": "string"
},
"name": {
"title": "name",
"type": "string"
},
"profiles": {
"items": {
"anyOf": [
{
"$ref": "#/definitions/FileFormat.EventedProfile"
},
{
"$ref": "#/definitions/FileFormat.SampledProfile"
}
]
},
"title": "profiles",
"type": "array"
},
"shared": {
"properties": {
"frames": {
"items": {
"$ref": "#/definitions/FileFormat.Frame"
},
"title": "frames",
"type": "array"
}
},
"required": [
"frames"
],
"title": "shared",
"type": "object"
}
},
"required": [
"$schema",
"profiles",
"shared"
],
"title": "FileFormat.File",
"type": "object"
},
"FileFormat.Frame": {
"properties": {
"col": {
"title": "col",
"type": "number"
},
"file": {
"title": "file",
"type": "string"
},
"line": {
"title": "line",
"type": "number"
},
"name": {
"title": "name",
"type": "string"
}
},
"required": [
"name"
],
"title": "FileFormat.Frame",
"type": "object"
},
"FileFormat.IProfile": {
"properties": {
"type": {
"$ref": "#/definitions/FileFormat.ProfileType",
"title": "type"
}
},
"required": [
"type"
],
"title": "FileFormat.IProfile",
"type": "object"
},
"FileFormat.Profile": {
"anyOf": [
{
"$ref": "#/definitions/FileFormat.EventedProfile"
},
{
"$ref": "#/definitions/FileFormat.SampledProfile"
}
]
},
"FileFormat.ProfileType": {
"enum": [
"evented",
"sampled"
],
"title": "FileFormat.ProfileType",
"type": "string"
},
"FileFormat.SampledProfile": {
"properties": {
"endValue": {
"title": "endValue",
"type": "number"
},
"name": {
"title": "name",
"type": "string"
},
"samples": {
"items": {
"items": {
"type": "number"
},
"type": "array"
},
"title": "samples",
"type": "array"
},
"startValue": {
"title": "startValue",
"type": "number"
},
"type": {
"enum": [
"sampled"
],
"title": "type",
"type": "string"
},
"unit": {
"$ref": "#/definitions/FileFormat.ValueUnit",
"title": "unit"
},
"weights": {
"items": {
"type": "number"
},
"title": "weights",
"type": "array"
}
},
"required": [
"endValue",
"name",
"samples",
"startValue",
"type",
"unit",
"weights"
],
"title": "FileFormat.SampledProfile",
"type": "object"
},
"FileFormat.ValueUnit": {
"enum": [
"bytes",
"microseconds",
"milliseconds",
"nanoseconds",
"none",
"seconds"
],
"title": "FileFormat.ValueUnit",
"type": "string"
},
"IEvent": {
"properties": {
"at": {
"title": "at",
"type": "number"
},
"type": {
"$ref": "#/definitions/FileFormat.EventType",
"title": "type"
}
},
"required": [
"at",
"type"
],
"title": "IEvent",
"type": "object"
},
"OpenFrameEvent": {
"properties": {
"at": {
"title": "at",
"type": "number"
},
"frame": {
"title": "frame",
"type": "number"
},
"type": {
"enum": [
"O"
],
"title": "type",
"type": "string"
}
},
"required": [
"at",
"frame",
"type"
],
"title": "OpenFrameEvent",
"type": "object"
},
"SampledStack": {
"items": {
"type": "number"
},
"type": "array"
}
},
"$ref": "#/definitions/FileFormat.File"
}
Loading

0 comments on commit cc78c69

Please sign in to comment.