Skip to content

Commit

Permalink
src/crush: extra logging to debug CPU burn in test_with_fork()
Browse files Browse the repository at this point in the history
related: https://tracker.ceph.com/issues/57782

Signed-off-by: Deepika Upadhyay <[email protected]>
  • Loading branch information
Deepika Upadhyay committed Oct 21, 2022
1 parent e3795cb commit 79e2902
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
22 changes: 19 additions & 3 deletions src/crush/CrushTester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
#include "include/stringify.h"
#include "CrushTester.h"
#include "CrushTreeDumper.h"
#include "common/ceph_context.h"
#include "include/ceph_features.h"
#include "common/debug.h"

#define dout_subsys ceph_subsys_crush
#undef dout_prefix
#define dout_prefix *_dout << "CrushTester: "

using std::cerr;
using std::cout;
Expand Down Expand Up @@ -365,11 +370,12 @@ void CrushTester::write_integer_indexed_scalar_data_string(vector<string> &dst,
dst.push_back( data_buffer.str() );
}

int CrushTester::test_with_fork(int timeout)
int CrushTester::test_with_fork(CephContext* cct, int timeout)
{
ldout(cct, 20) << __func__ << dendl;
ostringstream sink;
int r = fork_function(timeout, sink, [&]() {
return test();
return test(cct);
});
if (r == -ETIMEDOUT) {
err << "timed out during smoke test (" << timeout << " seconds)";
Expand Down Expand Up @@ -429,8 +435,9 @@ bool CrushTester::check_name_maps(unsigned max_id) const
return true;
}

int CrushTester::test()
int CrushTester::test(CephContext* cct)
{
ldout(cct, 20) << dendl;
if (min_rule < 0 || max_rule < 0) {
min_rule = 0;
max_rule = crush.get_max_rules() - 1;
Expand Down Expand Up @@ -477,6 +484,8 @@ int CrushTester::test()
crush.start_choose_profile();

for (int r = min_rule; r < crush.get_max_rules() && r <= max_rule; r++) {
ldout(cct, 20) << "rule: " << r << dendl;

if (!crush.rule_exists(r)) {
if (output_statistics)
err << "rule " << r << " dne" << std::endl;
Expand All @@ -490,6 +499,8 @@ int CrushTester::test()
<< std::endl;

for (int nr = min_rep; nr <= max_rep; nr++) {
ldout(cct, 20) << "current numrep: " << nr << dendl;

vector<int> per(crush.get_max_devices());
map<int,int> sizes;

Expand Down Expand Up @@ -635,6 +646,8 @@ int CrushTester::test()
}
}

ldout(cct, 20) << "output statistics created" << dendl;

if (output_data_file)
for (unsigned i = 0; i < per.size(); i++) {
vector_data_buffer_f.clear();
Expand All @@ -655,10 +668,13 @@ int CrushTester::test()
}
}

ldout(cct, 20) << "output data file created" << dendl;
string rule_tag = crush.get_rule_name(r);

if (output_csv)
write_data_set_to_csv(output_data_file_name+rule_tag,tester_data);

ldout(cct, 20) << "successfully written csv" << dendl;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/crush/CrushTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define CEPH_CRUSH_TESTER_H

#include "crush/CrushWrapper.h"
#include "include/common_fwd.h"

#include <fstream>

Expand Down Expand Up @@ -347,8 +348,8 @@ class CrushTester {
* large, true otherwise
*/
bool check_name_maps(unsigned max_id = 0) const;
int test();
int test_with_fork(int timeout);
int test(CephContext* cct);
int test_with_fork(CephContext* cct, int timeout);

int compare(CrushWrapper& other);
};
Expand Down
5 changes: 3 additions & 2 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8041,7 +8041,8 @@ int OSDMonitor::prepare_new_pool(string& name,
tester.set_rule(crush_rule);
tester.set_num_rep(size);
auto start = ceph::coarse_mono_clock::now();
r = tester.test_with_fork(g_conf()->mon_lease);
r = tester.test_with_fork(cct, g_conf()->mon_lease);
dout(10) << __func__ << " crush test_with_fork tester created " << dendl;
auto duration = ceph::coarse_mono_clock::now() - start;
if (r < 0) {
dout(10) << "tester.test_with_fork returns " << r
Expand Down Expand Up @@ -10019,7 +10020,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
tester.set_max_x(50);
tester.set_num_rep(3); // arbitrary
auto start = ceph::coarse_mono_clock::now();
int r = tester.test_with_fork(g_conf()->mon_lease);
int r = tester.test_with_fork(cct, g_conf()->mon_lease);
auto duration = ceph::coarse_mono_clock::now() - start;
if (r < 0) {
dout(10) << " tester.test_with_fork returns " << r
Expand Down
2 changes: 1 addition & 1 deletion src/tools/crushtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ int main(int argc, const char **argv)
tester.get_output_utilization())
tester.set_output_statistics(true);

int r = tester.test();
int r = tester.test(cct->get());
if (r < 0)
return EXIT_FAILURE;
}
Expand Down

0 comments on commit 79e2902

Please sign in to comment.