Skip to content

Commit a7ce16a

Browse files
authored
Disable dynamic trace file (#7106) (#7113)
1 parent 5ff6935 commit a7ce16a

File tree

6 files changed

+54
-81
lines changed

6 files changed

+54
-81
lines changed

qa/L0_trace/test.sh

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ SERVER=/opt/tritonserver/bin/tritonserver
6060
source ../common/util.sh
6161

6262
rm -f *.log
63+
rm -f *.log.*
6364
rm -fr $MODELSDIR && mkdir -p $MODELSDIR
6465

6566
# set up simple and global_simple model using MODELBASE
@@ -232,27 +233,18 @@ set +e
232233

233234
# Add trace setting for 'simple' via trace API, first use the same trace file
234235
update_trace_setting "simple" '{"trace_file":"global_trace.log"}'
235-
assert_curl_success "Failed to modify trace settings for 'simple' model"
236+
assert_curl_failure "trace_file updated through network protocol expects an error"
236237

237238
# Check if the current setting is returned (not specified setting from global)
238-
if [ `grep -c "\"trace_level\":\[\"TIMESTAMPS\"\]" ./curl.out` != "1" ]; then
239-
RET=1
240-
fi
241-
if [ `grep -c "\"trace_rate\":\"6\"" ./curl.out` != "1" ]; then
242-
RET=1
243-
fi
244-
if [ `grep -c "\"log_frequency\":\"0\"" ./curl.out` != "1" ]; then
245-
RET=1
246-
fi
247-
if [ `grep -c "\"trace_file\":\"global_trace.log\"" ./curl.out` != "1" ]; then
239+
if [ `grep -c "\"error\":\"trace file location can not be updated through network protocol\"" ./curl.out` != "1" ]; then
248240
RET=1
249241
fi
250242
if [ `grep -c "\"trace_mode\":\"triton\"" ./curl.out` != "1" ]; then
251243
RET=1
252244
fi
253245

254246
# Use a different name
255-
update_trace_setting "simple" '{"trace_file":"simple_trace.log","log_frequency":"2"}'
247+
update_trace_setting "simple" '{"log_frequency":"2"}'
256248
assert_curl_success "Failed to modify trace settings for 'simple' model"
257249

258250
# Check if the current setting is returned (not specified setting from global)
@@ -268,7 +260,7 @@ fi
268260
if [ `grep -c "\"log_frequency\":\"2\"" ./curl.out` != "1" ]; then
269261
RET=1
270262
fi
271-
if [ `grep -c "\"trace_file\":\"simple_trace.log\"" ./curl.out` != "1" ]; then
263+
if [ `grep -c "\"trace_file\":\"global_trace.log\"" ./curl.out` != "1" ]; then
272264
RET=1
273265
fi
274266
if [ `grep -c "\"trace_mode\":\"triton\"" ./curl.out` != "1" ]; then
@@ -284,35 +276,35 @@ wait $SERVER_PID
284276

285277
set +e
286278

287-
if [ -f ./global_trace.log ]; then
288-
echo -e "\n***\n*** Test Failed, unexpected generation of global_trace.log\n***"
279+
if [ -f ./simple_trace.log ]; then
280+
echo -e "\n***\n*** Test Failed, unexpected generation of simple_trace.log\n***"
289281
RET=1
290282
fi
291283

292-
$TRACE_SUMMARY -t simple_trace.log.0 > summary_simple_trace.log.0
284+
$TRACE_SUMMARY -t global_trace.log.0 > summary_global_trace.log.0
293285

294-
if [ `grep -c "COMPUTE_INPUT_END" summary_simple_trace.log.0` != "2" ]; then
295-
cat summary_simple_trace.log.0
286+
if [ `grep -c "COMPUTE_INPUT_END" summary_global_trace.log.0` != "2" ]; then
287+
cat summary_global_trace.log.0
296288
echo -e "\n***\n*** Test Failed\n***"
297289
RET=1
298290
fi
299291

300-
if [ `grep -c ^simple summary_simple_trace.log.0` != "2" ]; then
301-
cat summary_simple_trace.log.0
292+
if [ `grep -c ^simple summary_global_trace.log.0` != "2" ]; then
293+
cat summary_global_trace.log.0
302294
echo -e "\n***\n*** Test Failed\n***"
303295
RET=1
304296
fi
305297

306-
$TRACE_SUMMARY -t simple_trace.log.1 > summary_simple_trace.log.1
298+
$TRACE_SUMMARY -t global_trace.log.1 > summary_global_trace.log.1
307299

308-
if [ `grep -c "COMPUTE_INPUT_END" summary_simple_trace.log.1` != "1" ]; then
309-
cat summary_simple_trace.log.1
300+
if [ `grep -c "COMPUTE_INPUT_END" summary_global_trace.log.1` != "1" ]; then
301+
cat summary_global_trace.log.1
310302
echo -e "\n***\n*** Test Failed\n***"
311303
RET=1
312304
fi
313305

314-
if [ `grep -c ^simple summary_simple_trace.log.1` != "1" ]; then
315-
cat summary_simple_trace.log.1
306+
if [ `grep -c ^simple summary_global_trace.log.1` != "1" ]; then
307+
cat summary_global_trace.log.1
316308
echo -e "\n***\n*** Test Failed\n***"
317309
RET=1
318310
fi
@@ -332,10 +324,10 @@ fi
332324
set +e
333325

334326
# Add model setting and update it
335-
update_trace_setting "simple" '{"trace_file":"update_trace.log","trace_rate":"1"}'
327+
update_trace_setting "simple" '{"trace_rate":"1"}'
336328
assert_curl_success "Failed to modify trace settings for 'simple' model"
337329

338-
update_trace_setting "simple" '{"trace_file":"update_trace.log","trace_level":["OFF"]}'
330+
update_trace_setting "simple" '{"trace_level":["OFF"]}'
339331
assert_curl_success "Failed to modify trace settings for 'simple' model"
340332

341333
# Check if the current setting is returned
@@ -351,7 +343,7 @@ fi
351343
if [ `grep -c "\"log_frequency\":\"0\"" ./curl.out` != "1" ]; then
352344
RET=1
353345
fi
354-
if [ `grep -c "\"trace_file\":\"update_trace.log\"" ./curl.out` != "1" ]; then
346+
if [ `grep -c "\"trace_file\":\"global_trace.log\"" ./curl.out` != "1" ]; then
355347
RET=1
356348
fi
357349
if [ `grep -c "\"trace_mode\":\"triton\"" ./curl.out` != "1" ]; then
@@ -365,7 +357,7 @@ rm -f ./curl.out
365357
set +e
366358

367359
# Clear trace setting by explicitly asking removal for every field except 'trace_rate'
368-
update_trace_setting "simple" '{"trace_file":null,"trace_level":null}'
360+
update_trace_setting "simple" '{"trace_level":null}'
369361
assert_curl_success "Failed to modify trace settings for 'simple' model"
370362

371363
# Check if the current setting (global) is returned
@@ -510,8 +502,8 @@ if [ `grep -c "\"trace_mode\":\"triton\"" ./curl.out` != "1" ]; then
510502
fi
511503

512504
# Check if the indexed file has been generated when trace count reaches 0
513-
if [ -f ./global_trace.log.0 ]; then
514-
echo -e "\n***\n*** Test Failed, expect generation of global_trace.log.0 before stopping server\n***"
505+
if [ ! -f ./global_count.log.0 ]; then
506+
echo -e "\n***\n*** Test Failed, expect generation of global_count.log.0 before stopping server\n***"
515507
RET=1
516508
fi
517509

qa/L0_trace/trace_endpoint_test.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import tritonclient.grpc as grpcclient
3939
import tritonclient.http as httpclient
4040
from google.protobuf import json_format
41+
from tritonclient.utils import InferenceServerException
4142

4243

4344
# Similar set up as dynamic batcher tests
@@ -49,7 +50,6 @@ def tearDown(self):
4950
# tearDown() is properly executed and not affecting start state of
5051
# other test cases
5152
clear_settings = {
52-
"trace_file": None,
5353
"trace_level": None,
5454
"trace_rate": None,
5555
"trace_count": None,
@@ -157,23 +157,26 @@ def test_http_update_settings(self):
157157
self.check_server_initial_state()
158158

159159
expected_first_model_settings = {
160-
"trace_file": "model.log",
160+
"trace_file": "global_unittest.log",
161161
"trace_level": ["TIMESTAMPS"],
162162
"trace_rate": "1",
163163
"trace_count": "-1",
164164
"log_frequency": "0",
165165
"trace_mode": "triton",
166166
}
167+
expected_first_model_response = {
168+
"error": "trace file location can not be updated through network protocol"
169+
}
167170
expected_second_model_settings = {
168-
"trace_file": "model.log",
171+
"trace_file": "global_unittest.log",
169172
"trace_level": ["TIMESTAMPS", "TENSORS"],
170173
"trace_rate": "1",
171174
"trace_count": "-1",
172175
"log_frequency": "0",
173176
"trace_mode": "triton",
174177
}
175178
expected_global_settings = {
176-
"trace_file": "another.log",
179+
"trace_file": "global_unittest.log",
177180
"trace_level": ["TIMESTAMPS", "TENSORS"],
178181
"trace_rate": "1",
179182
"trace_count": "-1",
@@ -183,17 +186,20 @@ def test_http_update_settings(self):
183186

184187
model_update_settings = {"trace_file": "model.log"}
185188
global_update_settings = {
186-
"trace_file": "another.log",
187189
"trace_level": ["TIMESTAMPS", "TENSORS"],
188190
}
189191

190192
triton_client = httpclient.InferenceServerClient("localhost:8000")
191-
self.assertEqual(
192-
expected_first_model_settings,
193+
with self.assertRaisesRegex(
194+
InferenceServerException, expected_first_model_response["error"]
195+
) as e:
193196
triton_client.update_trace_settings(
194197
model_name="simple", settings=model_update_settings
195-
),
196-
"Unexpected updated model trace settings",
198+
)
199+
self.assertEqual(
200+
expected_first_model_settings,
201+
triton_client.get_trace_settings(model_name="simple"),
202+
"Unexpected model trace settings after global update",
197203
)
198204
# Note that 'trace_level' may be mismatch due to the order of
199205
# the levels listed, currently we assume the order is the same
@@ -230,7 +236,7 @@ def test_grpc_update_settings(self):
230236
json.dumps(
231237
{
232238
"settings": {
233-
"trace_file": {"value": ["model.log"]},
239+
"trace_file": {"value": ["global_unittest.log"]},
234240
"trace_level": {"value": ["TIMESTAMPS"]},
235241
"trace_rate": {"value": ["1"]},
236242
"trace_count": {"value": ["-1"]},
@@ -247,7 +253,7 @@ def test_grpc_update_settings(self):
247253
json.dumps(
248254
{
249255
"settings": {
250-
"trace_file": {"value": ["model.log"]},
256+
"trace_file": {"value": ["global_unittest.log"]},
251257
"trace_level": {"value": ["TIMESTAMPS", "TENSORS"]},
252258
"trace_rate": {"value": ["1"]},
253259
"trace_count": {"value": ["-1"]},
@@ -264,7 +270,7 @@ def test_grpc_update_settings(self):
264270
json.dumps(
265271
{
266272
"settings": {
267-
"trace_file": {"value": ["another.log"]},
273+
"trace_file": {"value": ["global_unittest.log"]},
268274
"trace_level": {"value": ["TIMESTAMPS", "TENSORS"]},
269275
"trace_rate": {"value": ["1"]},
270276
"trace_count": {"value": ["-1"]},
@@ -278,18 +284,10 @@ def test_grpc_update_settings(self):
278284

279285
model_update_settings = {"trace_file": "model.log"}
280286
global_update_settings = {
281-
"trace_file": "another.log",
282287
"trace_level": ["TIMESTAMPS", "TENSORS"],
283288
}
284289

285290
triton_client = grpcclient.InferenceServerClient("localhost:8001")
286-
self.assertEqual(
287-
expected_first_model_settings,
288-
triton_client.update_trace_settings(
289-
model_name="simple", settings=model_update_settings
290-
),
291-
"Unexpected updated model trace settings",
292-
)
293291
# Note that 'trace_level' may be mismatch due to the order of
294292
# the levels listed, currently we assume the order is the same
295293
# for simplicity. But the order shouldn't be enforced and this checking

src/grpc/grpc_server.cc

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,18 +1210,11 @@ CommonHandler::RegisterTrace()
12101210
static std::string setting_name = "trace_file";
12111211
auto it = request.settings().find(setting_name);
12121212
if (it != request.settings().end()) {
1213-
if (it->second.value().size() == 0) {
1214-
new_setting.clear_filepath_ = true;
1215-
} else if (it->second.value().size() == 1) {
1216-
filepath = it->second.value()[0];
1217-
new_setting.filepath_ = &filepath;
1218-
} else {
1219-
err = TRITONSERVER_ErrorNew(
1220-
TRITONSERVER_ERROR_INVALID_ARG,
1221-
(std::string("expect only 1 value for '") + setting_name + "'")
1222-
.c_str());
1223-
GOTO_IF_ERR(err, earlyexit);
1224-
}
1213+
err = TRITONSERVER_ErrorNew(
1214+
TRITONSERVER_ERROR_UNSUPPORTED,
1215+
"trace file location can not be updated through network "
1216+
"protocol");
1217+
GOTO_IF_ERR(err, earlyexit);
12251218
}
12261219
}
12271220
{

src/http_server.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,12 +1856,11 @@ HTTPAPIServer::HandleTrace(evhtp_request_t* req, const std::string& model_name)
18561856

18571857
triton::common::TritonJson::Value setting_json;
18581858
if (request.Find("trace_file", &setting_json)) {
1859-
if (setting_json.IsNull()) {
1860-
new_setting.clear_filepath_ = true;
1861-
} else {
1862-
RETURN_AND_RESPOND_IF_ERR(req, setting_json.AsString(&filepath));
1863-
new_setting.filepath_ = &filepath;
1864-
}
1859+
RETURN_AND_RESPOND_IF_ERR(
1860+
req, TRITONSERVER_ErrorNew(
1861+
TRITONSERVER_ERROR_UNSUPPORTED,
1862+
"trace file location can not be updated through network "
1863+
"protocol"));
18651864
}
18661865
if (request.Find("trace_level", &setting_json)) {
18671866
if (setting_json.IsNull()) {

src/tracer.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ TraceManager::UpdateTraceSettingInternal(
162162
current_setting->log_frequency_specified_) ||
163163
(new_setting.log_frequency_ != nullptr)));
164164
const bool filepath_specified =
165-
(new_setting.clear_filepath_ ? false
166-
: (((current_setting != nullptr) &&
167-
current_setting->filepath_specified_) ||
168-
(new_setting.filepath_ != nullptr)));
165+
(((current_setting != nullptr) && current_setting->filepath_specified_));
169166

170167
if (level_specified) {
171168
level = (new_setting.level_ != nullptr) ? *new_setting.level_
@@ -185,9 +182,7 @@ TraceManager::UpdateTraceSettingInternal(
185182
: current_setting->log_frequency_;
186183
}
187184
if (filepath_specified) {
188-
filepath = (new_setting.filepath_ != nullptr)
189-
? *new_setting.filepath_
190-
: current_setting->file_->FileName();
185+
filepath = current_setting->file_->FileName();
191186
}
192187

193188
// Some special case when updating model setting

src/tracer.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ class TraceManager {
106106
NewSetting()
107107
: clear_level_(false), level_(nullptr), clear_rate_(false),
108108
rate_(nullptr), clear_count_(false), count_(nullptr),
109-
clear_log_frequency_(false), log_frequency_(nullptr),
110-
clear_filepath_(false), filepath_(nullptr), mode_(nullptr),
109+
clear_log_frequency_(false), log_frequency_(nullptr), mode_(nullptr),
111110
config_map_(nullptr)
112111
{
113112
}
@@ -123,9 +122,6 @@ class TraceManager {
123122
bool clear_log_frequency_;
124123
const uint32_t* log_frequency_;
125124

126-
bool clear_filepath_;
127-
const std::string* filepath_;
128-
129125
const InferenceTraceMode* mode_;
130126

131127
const TraceConfigMap* config_map_;

0 commit comments

Comments
 (0)