Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOOLS/INFO: Optional name filter for config dump #10469

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ColinNV
Copy link

@ColinNV ColinNV commented Jan 31, 2025

What?

Add optional filters for ucx_info -c and ucx_info -f to select which config parameters are printed.

All additional command line arguments to ucx_info -c and ucx_info -f are used as disjunctive substring filter, e.g. ucx_info -c TCP LOG will only print config parameters that contain TCP and/or LOG.

When -F string is passed in addition to -c and/or -f then only config parameters whose name contains string are printed.

@ColinNV ColinNV changed the title Enhance ucx_info TOOLS/INFO: Optional name filter for config dump Jan 31, 2025
@@ -113,9 +114,9 @@ Christophe Harle
Christopher Lamb
Craig Stunkel
Cydney Ewald Stevens
Davide Rossetti
Davide Rossetti
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to remove trailing spaces in this PR, can be done separately

return;
}

if ((flags & UCS_CONFIG_PRINT_HEADER) && (*printed == 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could check ucs_config_parser_is_filtered before calling ucs_config_parser_print_field, so that ucs_config_parser_print_field would not have to be made responsible for printing the header

Copy link
Author

@ColinNV ColinNV Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I was undecided on this, however keeping the responsibility of printing the header in ucs_config_parser_print_opts() means that it has to know in advance whether ucs_config_parser_print_opts_recurs() will print anything via ucs_config_parse_print_field(), and that seemed even more of a hassle. Did I miss something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if ucs_config_parser_print_opts checked the filter before calling ucs_config_parser_print_field?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, but ucs_config_parser_print_opts() calls ucs_config_parser_print_opts_recurs(), which in turn calls both ucs_config_parser_print_opts_recurs() and ucs_config_parser_print_field(), possibly multiple times ... it seems that there is no shortcut to determine from the outside whether the top call to ucs_config_parser_print_opts_recurs() will eventually lead to something being printed. Did I miss something?

Comment on lines 2038 to 2039
char name_buf[128] = {0};
char value_buf[128] = {0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char name_buf[128] = {0};
char value_buf[128] = {0};
char name_buf[128] = {0};
char value_buf[128] = {0};

@@ -428,7 +428,7 @@ class test_config : public ucs::test {
FILE *file = open_memstream(&dump_data, &dump_size);
ucs_config_parser_print_opts(file, "", *opts, car_opts_table,
prefix, UCS_DEFAULT_ENV_PREFIX,
(ucs_config_print_flags_t)flags);
(ucs_config_print_flags_t)flags, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you used nullptr in the other method above

Comment on lines 940 to 942
const std::string dump1 = opts.dump(UCS_CONFIG_PRINT_CONFIG);
const char filter[] = "TIME_";
const std::string dump2 = opts.dump(UCS_CONFIG_PRINT_CONFIG, filter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const std::string dump1 = opts.dump(UCS_CONFIG_PRINT_CONFIG);
const char filter[] = "TIME_";
const std::string dump2 = opts.dump(UCS_CONFIG_PRINT_CONFIG, filter);
const std::string dump1 = opts.dump(UCS_CONFIG_PRINT_CONFIG);
const char filter[] = "TIME_";
const std::string dump2 = opts.dump(UCS_CONFIG_PRINT_CONFIG, filter);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants