Collect profile data on DH requests
- Seeing issues with a lot of Drydock requests timing out and it seems to be a downstream issue with pulling Deckhand docs - Add jsonpath cacheing as the jsonpath-ng parser was consuming 54s of the total 56s runtime of a rendered-documents GET call. With caching, the call is taking closer to 2s. - All add a .dockerignore file to make image building a little faster Change-Id: I6ef84ffd946dcf2713b4f7570b985156deb1d697
This commit is contained in:
parent
99ab93727b
commit
9f2a0fb347
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.tox
|
||||||
|
build
|
@ -78,8 +78,16 @@ spec:
|
|||||||
mountPath: /etc/deckhand/policy.yaml
|
mountPath: /etc/deckhand/policy.yaml
|
||||||
subPath: policy.yaml
|
subPath: policy.yaml
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
{{ if .Values.conf.deckhand.DEFAULT.profiler }}
|
||||||
|
- name: tmp-profiles
|
||||||
|
mountPath: /tmp/profiles
|
||||||
|
{{ end }}
|
||||||
{{ if $mounts_deckhand.volumeMounts }}{{ toYaml $mounts_deckhand.volumeMounts | indent 12 }}{{ end }}
|
{{ if $mounts_deckhand.volumeMounts }}{{ toYaml $mounts_deckhand.volumeMounts | indent 12 }}{{ end }}
|
||||||
volumes:
|
volumes:
|
||||||
|
{{ if .Values.conf.deckhand.DEFAULT.profiler }}
|
||||||
|
- name: tmp-profiles
|
||||||
|
emptyDir: {}
|
||||||
|
{{ end }}
|
||||||
- name: etc-deckhand
|
- name: etc-deckhand
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
- name: deckhand-etc
|
- name: deckhand-etc
|
||||||
|
@ -215,6 +215,7 @@ conf:
|
|||||||
debug: true
|
debug: true
|
||||||
use_stderr: true
|
use_stderr: true
|
||||||
use_syslog: true
|
use_syslog: true
|
||||||
|
profiler: false
|
||||||
database:
|
database:
|
||||||
connection:
|
connection:
|
||||||
keystone_authtoken:
|
keystone_authtoken:
|
||||||
|
@ -48,6 +48,9 @@ Possible values:
|
|||||||
* True
|
* True
|
||||||
* False
|
* False
|
||||||
"""),
|
"""),
|
||||||
|
cfg.BoolOpt('profiler', default=False,
|
||||||
|
help="Enabling profiling of API requests. Do NOT "
|
||||||
|
"use in production."),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import os
|
|||||||
import falcon
|
import falcon
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from werkzeug.contrib.profiler import ProfilerMiddleware
|
||||||
|
|
||||||
from deckhand.control import base
|
from deckhand.control import base
|
||||||
from deckhand.control import buckets
|
from deckhand.control import buckets
|
||||||
@ -82,5 +83,11 @@ def deckhand_app_factory(global_config, **local_config):
|
|||||||
|
|
||||||
app = falcon.API(request_type=base.DeckhandRequest,
|
app = falcon.API(request_type=base.DeckhandRequest,
|
||||||
middleware=middleware_list)
|
middleware=middleware_list)
|
||||||
|
if CONF.profiler:
|
||||||
return configure_app(app, version='v1.0')
|
LOG.warning("Profiler ENABLED. Expect significant "
|
||||||
|
"performance overhead.")
|
||||||
|
return ProfilerMiddleware(
|
||||||
|
configure_app(app, version='v1.0'),
|
||||||
|
profile_dir="/tmp/profiles") # nosec w/o profile data
|
||||||
|
else:
|
||||||
|
return configure_app(app, version='v1.0')
|
||||||
|
@ -25,6 +25,8 @@ from deckhand import errors
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
path_cache = dict()
|
||||||
|
|
||||||
|
|
||||||
def to_camel_case(s):
|
def to_camel_case(s):
|
||||||
"""Convert string to camel case."""
|
"""Convert string to camel case."""
|
||||||
@ -71,7 +73,12 @@ def jsonpath_parse(data, jsonpath, match_all=False):
|
|||||||
elif jsonpath.startswith('.'):
|
elif jsonpath.startswith('.'):
|
||||||
jsonpath = '$' + jsonpath
|
jsonpath = '$' + jsonpath
|
||||||
|
|
||||||
p = jsonpath_ng.parse(jsonpath)
|
if jsonpath not in path_cache:
|
||||||
|
p = jsonpath_ng.parse(jsonpath)
|
||||||
|
path_cache[jsonpath] = p
|
||||||
|
else:
|
||||||
|
p = path_cache[jsonpath]
|
||||||
|
|
||||||
matches = p.find(data)
|
matches = p.find(data)
|
||||||
if matches:
|
if matches:
|
||||||
result = [m.value for m in matches]
|
result = [m.value for m in matches]
|
||||||
|
@ -41,3 +41,6 @@ oslo.utils>=3.35.0 # Apache-2.0
|
|||||||
# likely this should be imported from a
|
# likely this should be imported from a
|
||||||
# container sidecar long-term
|
# container sidecar long-term
|
||||||
python-barbicanclient>=4.6.0 # Apache-2.0
|
python-barbicanclient>=4.6.0 # Apache-2.0
|
||||||
|
|
||||||
|
# To support profiling in non-prod
|
||||||
|
Werkzeug==0.14.1
|
||||||
|
Loading…
Reference in New Issue
Block a user