Switch to unified view

a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp
...
...
33
#ifdef __FreeBSD__
33
#ifdef __FreeBSD__
34
#include <osreldate.h>
34
#include <osreldate.h>
35
#endif
35
#endif
36
36
37
#include <iostream>
37
#include <iostream>
38
#include <sstream>
38
#include <cstdlib>
39
#include <cstdlib>
39
#include <cstring>
40
#include <cstring>
40
using namespace std;
41
using namespace std;
41
42
42
#include "cstr.h"
43
#include "cstr.h"
...
...
46
#include "debuglog.h"
47
#include "debuglog.h"
47
#include "smallut.h"
48
#include "smallut.h"
48
#include "textsplit.h"
49
#include "textsplit.h"
49
#include "readfile.h"
50
#include "readfile.h"
50
#include "fstreewalk.h"
51
#include "fstreewalk.h"
52
#include "cpuconf.h"
53
54
typedef pair<int,int> RclPII;
51
55
52
// Static, logically const, RclConfig members are initialized once from the
56
// Static, logically const, RclConfig members are initialized once from the
53
// first object build during process initialization.
57
// first object build during process initialization.
54
58
55
// We default to a case- and diacritics-less index for now
59
// We default to a case- and diacritics-less index for now
...
...
216
    return;
220
    return;
217
    }
221
    }
218
    if (!readFieldsConfig(cnferrloc))
222
    if (!readFieldsConfig(cnferrloc))
219
    return;
223
    return;
220
224
225
    // Default is no threading
226
    m_thrConf = create_vector<RclPII>
227
  (RclPII(-1, 0))(RclPII(-1, 0))(RclPII(-1, 0));
228
221
    m_ptrans = new ConfSimple(path_cat(m_confdir, "ptrans").c_str());
229
    m_ptrans = new ConfSimple(path_cat(m_confdir, "ptrans").c_str());
222
230
223
    m_ok = true;
231
    m_ok = true;
224
    setKeyDir(cstr_null);
232
    setKeyDir(cstr_null);
225
233
...
...
366
    }
374
    }
367
    }
375
    }
368
    return true;
376
    return true;
369
}
377
}
370
378
371
pair<int,int> RclConfig::getThrConf(ThrStage who) const
379
void RclConfig::initThrConf()
372
{
380
{
381
    // Default is no threading
382
    m_thrConf = create_vector<RclPII>
383
  (RclPII(-1, 0))(RclPII(-1, 0))(RclPII(-1, 0));
384
373
    vector<int> vq;
385
    vector<int> vq;
374
    vector<int> vt;
386
    vector<int> vt;
375
    if (!getConfParam("thrQSizes", &vq) || !getConfParam("thrTCounts", &vt)) {
387
    if (!getConfParam("thrQSizes", &vq)) {
388
  LOGINFO(("RclConfig::initThrConf: no thread info (queues)\n"));
389
  goto out;
390
    }
391
392
    // If the first queue size is 0, autoconf is requested.
393
    if (vq.size() > 0 && vq[0] == 0) {
394
  LOGDEB(("RclConfig::initThrConf: autoconf requested\n"));
395
  CpuConf cpus;
396
  if (!getCpuConf(cpus) || cpus.ncpus < 1) {
397
      LOGERR(("RclConfig::initThrConf: could not retrieve cpu conf\n"));
398
      cpus.ncpus = 1;
399
  }
400
  // Arbitrarily set threads config based on number of CPUS. This also
401
  // depends on the IO setup actually, so we're bound to be wrong...
402
  if (cpus.ncpus == 1) {
403
      // Somewhat counter-intuitively (because of possible IO//)
404
      // it seems that the best config here is no threading
405
  } else if (cpus.ncpus < 4) {
406
      // Untested so let's guess...
407
      m_thrConf = create_vector<RclPII>
408
      (RclPII(2, 2))(RclPII(2, 2))(RclPII(2, 1));
409
  } else if (cpus.ncpus < 6) {
410
      m_thrConf = create_vector<RclPII>
411
      (RclPII(2, 4))(RclPII(2, 2))(RclPII(2, 1));
412
  } else {
413
      m_thrConf = create_vector<RclPII>
414
      (RclPII(2, 5))(RclPII(2, 3))(RclPII(2, 1));
415
  }
416
  goto out;
417
    } else if (vq.size() > 0 && vq[0] < 0) {
418
  // threads disabled by config
419
  goto out;
420
    }
421
422
    if (!getConfParam("thrTCounts", &vt) ) {
423
  LOGINFO(("RclConfig::initThrConf: no thread info (threads)\n"));
424
  goto out;
425
    }
426
427
    if (vq.size() != 3 || vt.size() != 3) {
428
  LOGINFO(("RclConfig::initThrConf: bad thread info vector sizes\n"));
429
  goto out;
430
    }
431
432
    // Normal case: record info from config
433
    m_thrConf.clear();
434
    for (unsigned int i = 0; i < 3; i++) {
435
  m_thrConf.push_back(RclPII(vq[i], vt[i]));
436
    }
437
438
out:
439
    ostringstream sconf;
440
    for (unsigned int i = 0; i < 3; i++) {
441
  sconf << "(" << m_thrConf[i].first << ", " << m_thrConf[i].second <<
442
      ") ";
443
    }
444
445
    LOGDEB(("RclConfig::initThrConf: chosen config (ql,nt): %s\n", 
446
      sconf.str().c_str()));
447
}
448
449
pair<int,int> RclConfig::getThrConf(ThrStage who) const
450
{
451
    if (m_thrConf.size() != 3) {
452
  LOGERR(("RclConfig::getThrConf: bad data in rclconfig\n"));
376
    return pair<int,int>(-1,-1);
453
    return pair<int,int>(-1,-1);
377
    }
454
    }
378
    return pair<int,int>(vq[who], vt[who]);
455
    return m_thrConf[who];
379
}
456
}
380
457
381
vector<string> RclConfig::getTopdirs() const
458
vector<string> RclConfig::getTopdirs() const
382
{
459
{
383
    vector<string> tdl;
460
    vector<string> tdl;
...
...
1255
    m_defcharset = r.m_defcharset;
1332
    m_defcharset = r.m_defcharset;
1256
1333
1257
    m_stpsuffstate.init(this, mimemap, r.m_stpsuffstate.paramname);
1334
    m_stpsuffstate.init(this, mimemap, r.m_stpsuffstate.paramname);
1258
    m_skpnstate.init(this, m_conf, r.m_skpnstate.paramname);
1335
    m_skpnstate.init(this, m_conf, r.m_skpnstate.paramname);
1259
    m_rmtstate.init(this, m_conf, r.m_rmtstate.paramname);
1336
    m_rmtstate.init(this, m_conf, r.m_rmtstate.paramname);
1337
    m_thrConf = r.m_thrConf;
1260
}
1338
}
1261
1339
1262
#else // -> Test
1340
#else // -> Test
1263
1341
1264
#include <stdio.h>
1342
#include <stdio.h>