mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 12:28:13 -04:00
feat: add --perfmon-trace-file and -o perfmon_trace_file
This commit is contained in:
parent
80f84c6f44
commit
d0626212a8
@ -156,8 +156,12 @@ options:
|
||||
- `-o perfmon=`*name*:
|
||||
Enable performance monitoring for the list of comma-separated components.
|
||||
This option is only available if the project was built with performance
|
||||
monitoring enabled. Available components include `fuse`, `filesystem_v2`
|
||||
and `inode_reader_v2`.
|
||||
monitoring enabled. Available components include `fuse`, `filesystem_v2`,
|
||||
`inode_reader_v2` and `block_cache`.
|
||||
|
||||
- `-o perfmon_trace=`*file*:
|
||||
Write JSON trace data for all components enabled by `--perfmon` to this
|
||||
file when the process exits.
|
||||
|
||||
- `--man`:
|
||||
If the project was built with support for built-in manual pages, this
|
||||
|
@ -93,8 +93,12 @@ to disk:
|
||||
- `--perfmon=`*name*:
|
||||
Enable performance monitoring for the list of comma-separated components.
|
||||
This option is only available if the project was built with performance
|
||||
monitoring enabled. Available components include `fuse`, `filesystem_v2`
|
||||
and `inode_reader_v2`.
|
||||
monitoring enabled. Available components include `fuse`, `filesystem_v2`,
|
||||
`inode_reader_v2` and `block_cache`.
|
||||
|
||||
- `--perfmon-trace=`*file*:
|
||||
Write JSON trace data for all components enabled by `--perfmon` to this
|
||||
file when the process exits.
|
||||
|
||||
- `-h`, `--help`:
|
||||
Show program help, including option defaults.
|
||||
|
@ -159,7 +159,8 @@ struct options {
|
||||
char const* cache_tidy_interval_str{nullptr}; // TODO: const?? -> use string?
|
||||
char const* cache_tidy_max_age_str{nullptr}; // TODO: const?? -> use string?
|
||||
#if DWARFS_PERFMON_ENABLED
|
||||
char const* perfmon_enabled_str{nullptr}; // TODO: const?? -> use string?
|
||||
char const* perfmon_enabled_str{nullptr}; // TODO: const?? -> use string?
|
||||
char const* perfmon_trace_file_str{nullptr}; // TODO: const?? -> use string?
|
||||
#endif
|
||||
int enable_nlink{0};
|
||||
int readonly{0};
|
||||
@ -237,6 +238,7 @@ constexpr struct ::fuse_opt dwarfs_opts[] = {
|
||||
DWARFS_OPT("no_cache_files", cache_files, 0),
|
||||
#if DWARFS_PERFMON_ENABLED
|
||||
DWARFS_OPT("perfmon=%s", perfmon_enabled_str, 0),
|
||||
DWARFS_OPT("perfmon_trace=%s", perfmon_trace_file_str, 0),
|
||||
#endif
|
||||
FUSE_OPT_END};
|
||||
|
||||
@ -1041,6 +1043,7 @@ void usage(std::ostream& os, std::filesystem::path const& progname) {
|
||||
<< " -o tidy_max_age=TIME tidy blocks after this time (10m)\n"
|
||||
#if DWARFS_PERFMON_ENABLED
|
||||
<< " -o perfmon=name[,...] enable performance monitor\n"
|
||||
<< " -o perfmon_trace=FILE write performance monitor trace file\n"
|
||||
#endif
|
||||
#ifdef DWARFS_BUILTIN_MANPAGE
|
||||
<< " --man show manual page and exit\n"
|
||||
@ -1274,15 +1277,21 @@ void load_filesystem(dwarfs_userdata& userdata) {
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> perfmon_enabled;
|
||||
std::optional<std::filesystem::path> perfmon_trace_file;
|
||||
#if DWARFS_PERFMON_ENABLED
|
||||
if (opts.perfmon_enabled_str) {
|
||||
folly::splitTo<std::string>(
|
||||
',', opts.perfmon_enabled_str,
|
||||
std::inserter(perfmon_enabled, perfmon_enabled.begin()));
|
||||
}
|
||||
if (opts.perfmon_trace_file_str) {
|
||||
perfmon_trace_file = userdata.iol.os->canonical(std::filesystem::path(
|
||||
reinterpret_cast<char8_t const*>(opts.perfmon_trace_file_str)));
|
||||
}
|
||||
#endif
|
||||
|
||||
userdata.perfmon = performance_monitor::create(perfmon_enabled);
|
||||
userdata.perfmon = performance_monitor::create(
|
||||
perfmon_enabled, userdata.iol.file, perfmon_trace_file);
|
||||
|
||||
PERFMON_EXT_PROXY_SETUP(userdata, userdata.perfmon, "fuse")
|
||||
PERFMON_EXT_TIMER_SETUP(userdata, op_init)
|
||||
|
@ -59,7 +59,7 @@ constexpr std::string_view kDash{"-"};
|
||||
} // namespace
|
||||
|
||||
int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
sys_string filesystem, output;
|
||||
sys_string filesystem, output, trace_file;
|
||||
std::string format, cache_size_str, image_offset;
|
||||
logger_options logopts;
|
||||
#if DWARFS_PERFMON_ENABLED
|
||||
@ -103,6 +103,9 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
("perfmon",
|
||||
po::value<std::string>(&perfmon_str),
|
||||
"enable performance monitor")
|
||||
("perfmon-trace",
|
||||
po_sys_value<sys_string>(&trace_file),
|
||||
"write performance monitor trace file")
|
||||
#endif
|
||||
;
|
||||
// clang-format on
|
||||
@ -152,15 +155,19 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
fsopts.metadata.enable_nlink = true;
|
||||
|
||||
std::unordered_set<std::string> perfmon_enabled;
|
||||
std::optional<std::filesystem::path> perfmon_trace_file;
|
||||
#if DWARFS_PERFMON_ENABLED
|
||||
if (!perfmon_str.empty()) {
|
||||
folly::splitTo<std::string>(
|
||||
',', perfmon_str,
|
||||
std::inserter(perfmon_enabled, perfmon_enabled.begin()));
|
||||
}
|
||||
if (!trace_file.empty()) {
|
||||
perfmon_trace_file = iol.os->canonical(trace_file);
|
||||
}
|
||||
#endif
|
||||
std::shared_ptr<performance_monitor> perfmon =
|
||||
performance_monitor::create(perfmon_enabled);
|
||||
std::shared_ptr<performance_monitor> perfmon = performance_monitor::create(
|
||||
perfmon_enabled, iol.file, perfmon_trace_file);
|
||||
|
||||
auto fs_path = iol.os->canonical(filesystem);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user