Add Linux dirty paging kernel parameters dump.#712
Add Linux dirty paging kernel parameters dump.#712eynhaender wants to merge 1 commit intolibbitcoin:masterfrom
Conversation
| { | ||
| std::ifstream file("/proc/sys/vm/" + key); | ||
| T value{}; | ||
| if (file >> value) |
There was a problem hiding this comment.
As a rule we avoid using iostream for parse/serialize. We use the operators (in config classes) where we have overridden them, or when we are taking I/O via boost properties. This is because they are locale dependent, then to throw unexpectedly, and are slow. In this case the better approach is to use https://en.cppreference.com/cpp/utility/from_chars.
| T value{}; | ||
| if (file >> value) | ||
| return value; | ||
| return std::nullopt; |
There was a problem hiding this comment.
The return can have no value...
| { | ||
| dirty_page_params p{}; | ||
| if (const auto v = read_proc_vm<uint64_t>("dirty_bytes")) | ||
| p.dirty_bytes = *v; |
There was a problem hiding this comment.
... in which case these dereferences will throw an exception and crash the application. So crash just from an unexpected value in the "file", or even missing file, which means all macos/windows. There needs to be consideration for how/what to present on Linux when these values are expected but one or more is failed.
| % LIBBITCOIN_SYSTEM_VERSION); | ||
| } | ||
|
|
||
| void executor::dump_kernel_parameters() const |
There was a problem hiding this comment.
This is the place to implement the exclusion for platforms that don't support these features.
| capture_.start(); | ||
| dump_version(); | ||
| dump_hardware(); | ||
| dump_kernel_parameters(); |
There was a problem hiding this comment.
How about we are mosre specific and call this dump_paging()
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| #ifndef LIBBITCOIN_BS_DIRTY_PAGES_HPP |
There was a problem hiding this comment.
This shouldn't be implemented in a header file, as it's neither inline nor template. The read_proc_vm<> template method is a local utility (cpp). So this should follow the existing pattern and be implemented in executor_paging.cpp, with prototype in executor.hpp.
Add Linux dirty paging kernel parameters dump.