Skip to content

Commit d6066ff

Browse files
committed
flag for miner activity metric
1 parent ecfb8de commit d6066ff

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To install or update LODA, please follow the [installation instructions](https:/
99
### Features
1010

1111
* Built-in parallel mining command: `loda mine -p` (replaces `mine_parallel.sh` script)
12-
* New metrics on program submissions and CPU hours
12+
* New metrics for counting program submissions and miner activity
1313

1414
### Enhancements
1515

src/include/setup.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Setup {
3636

3737
static std::string getSetupValue(const std::string& key);
3838

39-
static bool getSetupFlag(const std::string& key);
39+
static bool getSetupFlag(const std::string& key, bool default_value);
4040

4141
static int64_t getSetupInt(const std::string& key, int64_t default_value);
4242

src/miner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ void Miner::checkRegularTasks() {
171171
// regular task: report CPU hours
172172
if (cpuhours_scheduler.isTargetReached()) {
173173
cpuhours_scheduler.reset();
174-
if (mining_mode != MINING_MODE_LOCAL) {
174+
if (mining_mode != MINING_MODE_LOCAL &&
175+
Setup::getSetupFlag("LODA_SUBMIT_CPU_HOURS", true)) {
175176
api_client->postCPUHour();
176177
}
177178
}

src/oeis_manager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ size_t getBadOpsCount(const Program &p) {
659659
// - w/o indirect memory access
660660
// - w/o loops that have non-constant args
661661
// - w/o gcd with powers of a small constant
662+
// - w/o bin (can be very slow)
662663
size_t num_ops = ProgramUtil::numOps(p, Operand::Type::INDIRECT);
663664
for (auto &op : p.ops) {
664665
if (op.type == Operation::Type::LPB &&
@@ -670,6 +671,9 @@ size_t getBadOpsCount(const Program &p) {
670671
Minimizer::getPowerOf(op.source.value) != 0) {
671672
num_ops++;
672673
}
674+
if (op.type == Operation::Type::BIN) {
675+
num_ops++;
676+
}
673677
}
674678
return num_ops;
675679
}

src/setup.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,12 @@ std::string Setup::getSetupValue(const std::string& key) {
149149
return std::string();
150150
}
151151

152-
bool Setup::getSetupFlag(const std::string& key) {
152+
bool Setup::getSetupFlag(const std::string& key, bool default_value) {
153153
auto s = getSetupValue(key);
154-
return (s == "yes" || s == "true");
154+
if (s.empty()) {
155+
return default_value;
156+
}
157+
return (s == "yes" || s == "true" || s == "1");
155158
}
156159

157160
int64_t Setup::getSetupInt(const std::string& key, int64_t default_value) {

src/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ void Log::error(const std::string &msg, bool throw_) {
7373
void Log::alert(const std::string &msg, AlertDetails details) {
7474
log(Log::Level::ALERT, msg);
7575
if (!loaded_alerts_config) {
76-
slack_alerts = Setup::getSetupFlag("LODA_SLACK_ALERTS");
77-
tweet_alerts = Setup::getSetupFlag("LODA_TWEET_ALERTS");
76+
slack_alerts = Setup::getSetupFlag("LODA_SLACK_ALERTS", false);
77+
tweet_alerts = Setup::getSetupFlag("LODA_TWEET_ALERTS", false);
7878
loaded_alerts_config = true;
7979
}
8080
std::string copy = msg;

0 commit comments

Comments
 (0)