Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
45d6a2b3
提交
45d6a2b3
编辑于
7 years ago
作者:
Sean McGivern
浏览文件
操作
下载
补丁
差异文件
Add bin/profile-url tool and docs
上级
b16c0080
No related branches found
No related tags found
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
bin/profile-url
+57
-0
57 个添加, 0 个删除
bin/profile-url
doc/development/performance.md
+2
-1
2 个添加, 1 个删除
doc/development/performance.md
doc/development/profiling.md
+35
-10
35 个添加, 10 个删除
doc/development/profiling.md
有
94 个添加
和
11 个删除
bin/profile-url
0 → 100755
+
57
−
0
浏览文件 @
45d6a2b3
#!/usr/bin/env ruby
require
'optparse'
options
=
{}
opt_parser
=
OptionParser
.
new
do
|
opt
|
opt
.
banner
=
<<
DOCSTRING
Profile a URL on this GitLab instance.
Usage:
#{
__FILE__
}
url --output=<profile-html> --sql=<sql-log> [--user=<user>] [--post=<post-data>]
Example:
#{
__FILE__
}
/dashboard/issues --output=dashboard-profile.html --sql=dashboard.log --user=root
DOCSTRING
opt
.
separator
''
opt
.
separator
'Options:'
opt
.
on
(
'-o'
,
'--output=/tmp/profile.html'
,
'profile output filename'
)
do
|
output
|
options
[
:profile_output
]
=
output
end
opt
.
on
(
'-s'
,
'--sql=/tmp/profile_sql.txt'
,
'SQL output filename'
)
do
|
sql
|
options
[
:sql_output
]
=
sql
end
opt
.
on
(
'-u'
,
'--user=root'
,
'User to authenticate as'
)
do
|
username
|
options
[
:username
]
=
username
end
opt
.
on
(
'-p'
,
"--post='user=john&pass=test'"
,
'Send HTTP POST data'
)
do
|
post_data
|
options
[
:post_data
]
=
post_data
end
end
opt_parser
.
parse!
options
[
:url
]
=
ARGV
[
0
]
if
options
[
:url
].
nil?
||
options
[
:profile_output
].
nil?
||
options
[
:sql_output
].
nil?
puts
opt_parser
exit
end
require
File
.
expand_path
(
'../config/environment'
,
File
.
dirname
(
__FILE__
))
result
=
Gitlab
::
Profiler
.
profile
(
options
[
:url
],
logger:
Logger
.
new
(
options
[
:sql_output
]),
post_data:
options
[
:post_data
],
user:
User
.
find_by_username
(
options
[
:username
]),
private_token:
ENV
[
'PRIVATE_TOKEN'
])
printer
=
RubyProf
::
CallStackPrinter
.
new
(
result
)
file
=
File
.
open
(
options
[
:profile_output
],
'w'
)
printer
.
print
(
file
)
file
.
close
此差异已折叠。
点击以展开。
doc/development/performance.md
+
2
−
1
浏览文件 @
45d6a2b3
...
...
@@ -36,7 +36,8 @@ graphs/dashboards.
GitLab provides built-in tools to aid the process of improving performance:
*
[
Sherlock
](
profiling.md#sherlock
)
*
[
Profiling
](
profiling.md
)
*
[
Sherlock
](
profiling.md#sherlock
)
*
[
GitLab Performance Monitoring
](
../administration/monitoring/performance/index.md
)
*
[
Request Profiling
](
../administration/monitoring/performance/request_profiling.md
)
*
[
QueryRecoder
](
query_recorder.md
)
for preventing
`N+1`
regressions
...
...
此差异已折叠。
点击以展开。
doc/development/profiling.md
+
35
−
10
浏览文件 @
45d6a2b3
...
...
@@ -4,6 +4,41 @@ To make it easier to track down performance problems GitLab comes with a set of
profiling tools, some of these are available by default while others need to be
explicitly enabled.
## Profiling a URL
There is a
`Gitlab::Profiler.profile`
method, and corresponding
`bin/profile-url`
script, that enable profiling a GET or POST request to a
specific URL, either as an anonymous user (the default) or as a specific user.
When using the script, command-line documentation is available by passing no
arguments.
When using the method in an interactive console session, any changes to the
application code within that console session will be reflected in the profiler
output.
For example:
```
ruby
Gitlab
::
Profiler
.
profile
(
'/my-user'
)
# Returns a RubyProf::Profile for the regular operation of this request
class
UsersController
;
def
show
;
sleep
100
;
end
;
end
Gitlab
::
Profiler
.
profile
(
'/my-user'
)
# Returns a RubyProf::Profile where 100 seconds is spent in UsersController#show
```
Passing a
`logger:`
keyword argument to
`Gitlab::Profiler.profile`
will send
ActiveRecord and ActionController log output to that logger. Further options are
documented with the method source.
[
GitLab-Profiler
](
https://gitlab.com/gitlab-com/gitlab-profiler
)
is a project
that builds on this to add some additional niceties, such as allowing
configuration with a single Yaml file for multiple URLs, and uploading of the
profile and log output to S3.
For GitLab.com, you can find the latest results here:
<http://redash.gitlab.com/dashboard/gitlab-profiler-statistics>
## Sherlock
Sherlock is a custom profiling tool built into GitLab. Sherlock is _only_
...
...
@@ -27,13 +62,3 @@ Bullet will log query problems to both the Rails log as well as the Chrome
console.
As a follow up to finding
`N+1`
queries with Bullet, consider writing a
[
QueryRecoder test
](
query_recorder.md
)
to prevent a regression.
## GitLab Profiler
[
Gitlab-Profiler
](
https://gitlab.com/gitlab-com/gitlab-profiler
)
was built to
help developers understand why specific URLs of their application may be slow
and to provide hard data that can help reduce load times.
For GitLab.com, you can find the latest results here:
<http://redash.gitlab.com/dashboard/gitlab-profiler-statistics>
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录