@@ -33,7 +33,7 @@ better to begin the process with a candidate task or method *within* the
33
33
service that can be associated with an identifier. For example,
34
34
``select_destinations `` in the ``FilterScheduler `` can be associated with the
35
35
list of ``instance_uuids `` passed to it and it runs only once for that set of
36
- instance uuids .
36
+ instance UUIDs .
37
37
38
38
The process for profiling is:
39
39
@@ -100,80 +100,39 @@ profiling and benchmarking scenarios so not all changes are relevant here):
100
100
[notifications]
101
101
notification_format = unversioned
102
102
103
- Change the code in ``nova/scheduler/filter_scheduler.py `` as follows:
103
+ Change the code in ``nova/scheduler/driver.py `` as follows to start the
104
+ profiler at the start of ``select_destinations `` call and to dump the
105
+ statistics at the end. For example:
104
106
105
107
.. code-block :: diff
106
108
107
-
108
- diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py
109
- index 672f23077e..cb0f87fe48 100644
110
- --- a/nova/scheduler/filter_scheduler.py
111
- +++ b/nova/scheduler/filter_scheduler.py
112
- @@ -49,92 +49,99 @@ class FilterScheduler(driver.Scheduler):
113
- def select_destinations(self, context, spec_obj, instance_uuids,
114
- alloc_reqs_by_rp_uuid, provider_summaries,
115
- allocation_request_version=None, return_alternates=False):
116
- """Returns a list of lists of Selection objects, which represent the
117
- hosts and (optionally) alternates for each instance.
118
-
119
- :param context: The RequestContext object
120
- :param spec_obj: The RequestSpec object
121
- :param instance_uuids: List of UUIDs, one for each value of the spec
122
- object's num_instances attribute
123
- :param alloc_reqs_by_rp_uuid: Optional dict, keyed by resource provider
124
- UUID, of the allocation_requests that may
125
- be used to claim resources against
126
- matched hosts. If None, indicates either
127
- the placement API wasn't reachable or
128
- that there were no allocation_requests
129
- returned by the placement API. If the
130
- latter, the provider_summaries will be an
131
- empty dict, not None.
132
- :param provider_summaries: Optional dict, keyed by resource provider
133
- UUID, of information that will be used by
134
- the filters/weighers in selecting matching
135
- hosts for a request. If None, indicates that
136
- the scheduler driver should grab all compute
137
- node information locally and that the
138
- Placement API is not used. If an empty dict,
139
- indicates the Placement API returned no
140
- potential matches for the requested
141
- resources.
142
- :param allocation_request_version: The microversion used to request the
143
- allocations.
144
- :param return_alternates: When True, zero or more alternate hosts are
145
- returned with each selected host. The number
146
- of alternates is determined by the
147
- configuration option
148
- `CONF.scheduler.max_attempts`.
109
+ diff --git nova/scheduler/driver.py nova/scheduler/driver.py
110
+ index 555236e8a1..efa84b5a47 100644
111
+ --- nova/scheduler/driver.py
112
+ +++ nova/scheduler/driver.py
113
+ @@ -95,6 +95,10 @@ class SchedulerDriver:
114
+ determined by the configuration option
115
+ `CONF.scheduler.max_attempts`.
149
116
"""
150
117
+ from eventlet.green import profile
151
118
+ pr = profile.Profile()
152
119
+ pr.start()
153
120
+
154
121
self.notifier.info(
155
122
context, 'scheduler.select_destinations.start',
156
- dict(request_spec=spec_obj.to_legacy_request_spec_dict()))
157
- compute_utils.notify_about_scheduler_action(
158
- context=context, request_spec=spec_obj,
159
- action=fields_obj.NotificationAction.SELECT_DESTINATIONS,
160
- phase=fields_obj.NotificationPhase.START)
161
-
162
- host_selections = self._schedule(context, spec_obj, instance_uuids,
163
- alloc_reqs_by_rp_uuid, provider_summaries,
164
- allocation_request_version, return_alternates)
165
- self.notifier.info(
166
- context, 'scheduler.select_destinations.end',
167
- dict(request_spec=spec_obj.to_legacy_request_spec_dict()))
168
- compute_utils.notify_about_scheduler_action(
123
+ {'request_spec': spec_obj.to_legacy_request_spec_dict()})
124
+ @@ -114,6 +118,10 @@ class SchedulerDriver:
169
125
context=context, request_spec=spec_obj,
170
126
action=fields_obj.NotificationAction.SELECT_DESTINATIONS,
171
127
phase=fields_obj.NotificationPhase.END)
128
+ +
172
129
+ pr.stop()
173
130
+ pr.dump_stats('/tmp/select_destinations/%s.prof' % ':'.join(instance_uuids))
174
131
+
175
132
return host_selections
176
133
134
+ def _schedule(
135
+
177
136
Make a ``/tmp/select_destinations `` directory that is writable by the user
178
137
nova-scheduler will run as. This is where the profile output will go.
179
138
@@ -189,7 +148,7 @@ Create a server (which will call ``select_destinations``)::
189
148
openstack server create --image cirros-0.4.0-x86_64-disk --flavor c1 x1
190
149
191
150
In ``/tmp/select_destinations `` there should be a file with a name using the
192
- uuid of the created server with a ``.prof `` extension.
151
+ UUID of the created server with a ``.prof `` extension.
193
152
194
153
Change to that directory and view the profile using the pstats
195
154
`interactive mode `_::
0 commit comments