Commit 88ff1c58 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #4883 remove affinity code, we weren't using it anyway

git-svn-id: file:///svn/toku/tokudb@50174 c7de825b-a66e-492c-adef-691d508d4ae1
parent 502bce17
......@@ -5,7 +5,6 @@ set(tokuportability_srcs
memory
os_malloc
portability
toku_affinity
toku_assert
toku_pthread
toku_fair_rwlock
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <stdio.h>
#include <string.h>
#include <toku_assert.h>
#include <toku_os.h>
#include "toku_affinity.h"
int main(void) {
int r;
toku_cpuset_t orig;
TOKU_CPU_ZERO(&orig);
r = toku_getaffinity(toku_os_getpid(), sizeof orig, &orig);
if (r) {
perror("toku_getaffinity");
return r;
}
toku_cpuset_t set;
TOKU_CPU_ZERO(&set);
TOKU_CPU_SET(0, &set);
r = toku_setaffinity(toku_os_getpid(), sizeof set, &set);
if (r) {
perror("toku_setaffinity");
return r;
}
toku_cpuset_t chk;
TOKU_CPU_ZERO(&chk);
r = toku_getaffinity(toku_os_getpid(), sizeof chk, &chk);
if (r) {
perror("toku_getaffinity");
return r;
}
// don't want to expose this api unless we use it somewhere
#if defined(HAVE_CPUSET_GETAFFINITY)
r = CPU_CMP(&set, &chk);
#else
// hope this is good enough on linux
r = memcmp(&set, &chk, sizeof set);
#endif
return r;
}
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "Copyright (c) 2012 Tokutek Inc. All rights reserved."
#ident "$Id$"
#include <config.h>
#include "toku_affinity.h"
#if defined(HAVE_SCHED_GETAFFINITY)
int toku_getaffinity(pid_t pid, size_t cpusetsize, toku_cpuset_t *cpusetp) {
return sched_getaffinity(pid, cpusetsize, cpusetp);
}
int toku_setaffinity(pid_t pid, size_t cpusetsize, const toku_cpuset_t *cpusetp) {
return sched_setaffinity(pid, cpusetsize, cpusetp);
}
#elif defined(HAVE_CPUSET_GETAFFINITY)
int toku_getaffinity(pid_t pid, size_t cpusetsize, toku_cpuset_t *cpusetp) {
return cpuset_getaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_PID, pid, cpusetsize, cpusetp);
}
int toku_setaffinity(pid_t pid, size_t cpusetsize, const toku_cpuset_t *cpusetp) {
return cpuset_setaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_PID, pid, cpusetsize, cpusetp);
}
#else
// dummy implementation to get rid of unused warnings etc
int toku_getaffinity(pid_t pid __attribute__((unused)),
size_t cpusetsize __attribute__((unused)),
toku_cpuset_t *cpusetp) {
TOKU_CPU_ZERO(cpusetp);
return 0;
}
int toku_setaffinity(pid_t pid __attribute__((unused)),
size_t cpusetsize __attribute__((unused)),
const toku_cpuset_t *cpusetp __attribute__((unused))) {
return 0;
}
#endif
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "Copyright (c) 2012 Tokutek Inc. All rights reserved."
#ident "$Id$"
#ifndef TOKU_AFFINITY_H
#define TOKU_AFFINITY_H
#include <config.h>
#include <stddef.h>
#include <sys/types.h>
#if defined(HAVE_SCHED_GETAFFINITY)
# include <sched.h>
typedef cpu_set_t toku_cpuset_t;
# define TOKU_CPU_ZERO(p) CPU_ZERO(p)
# define TOKU_CPU_SET(n, p) CPU_SET(n, p)
#elif defined(HAVE_CPUSET_GETAFFINITY)
# include <sys/param.h>
# include <sys/cpuset.h>
typedef cpuset_t toku_cpuset_t;
# define TOKU_CPU_ZERO(p) CPU_ZERO(p)
# define TOKU_CPU_SET(n, p) CPU_SET(n, p)
#else
// dummy implementation to get rid of unused warnings etc
typedef int toku_cpuset_t;
# define TOKU_CPU_ZERO(p) (*p = 0)
# define TOKU_CPU_SET(n, p) (((void) n, (void) p))
#endif
// see sched_getaffinity(2)
int toku_getaffinity(pid_t pid, size_t cpusetsize, toku_cpuset_t *cpusetp);
// see sched_setaffinity(2)
int toku_setaffinity(pid_t pid, size_t cpusetsize, const toku_cpuset_t *cpusetp);
#endif // TOKU_AFFINITY_H
......@@ -8,7 +8,6 @@
#include "toku_pthread.h"
#include <db.h>
#include <sys/stat.h>
#include "toku_affinity.h"
#include "key-val.h"
enum {NUM_INDEXER_INDEXES=1};
......@@ -213,13 +212,10 @@ static void run_test(void)
// ------------ infrastructure ----------
#include <sched.h>
static inline void
do_args (int argc, char * const argv[]) {
const char *progname=argv[0];
num_rows = NUM_ROWS;
int num_cpus = 0;
argc--; argv++;
while (argc>0) {
if (strcmp(argv[0],"-v")==0) {
......@@ -229,32 +225,12 @@ do_args (int argc, char * const argv[]) {
} else if (strcmp(argv[0],"-r")==0) {
argc--; argv++;
num_rows = atoi(argv[0]);
} else if (strcmp(argv[0], "--ncpus") == 0 && argc+1 > 0) {
argc--; argv++;
num_cpus = atoi(argv[0]);
} else {
fprintf(stderr, "Usage:\n %s [-v] [-q] [-r rows]\n", progname);
exit(1);
}
argc--; argv++;
}
if (num_cpus > 0) {
toku_cpuset_t cpuset;
TOKU_CPU_ZERO(&cpuset);
for (int i = 0; i < num_cpus; i++) {
TOKU_CPU_SET(i, &cpuset);
}
int r;
r = toku_setaffinity(toku_os_getpid(), sizeof cpuset, &cpuset);
assert(r == 0);
toku_cpuset_t use_cpuset;
TOKU_CPU_ZERO(&use_cpuset);
r = toku_getaffinity(toku_os_getpid(), sizeof use_cpuset, &use_cpuset);
assert(r == 0);
assert(memcmp(&cpuset, &use_cpuset, sizeof cpuset) == 0);
}
}
......
......@@ -5,8 +5,6 @@
#include <util/threadpool.h>
#include <portability/toku_affinity.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
......@@ -15,9 +13,8 @@
int verbose = 0;
static int usage(int ncpus, int poolsize) {
static int usage(int poolsize) {
fprintf(stderr, "[-q] [-v] [--verbose] (%d)\n", verbose);
fprintf(stderr, "[--ncpus %d]\n", ncpus);
fprintf(stderr, "[--poolsize %d]\n", poolsize);
return 1;
}
......@@ -46,7 +43,6 @@ static void dotest(int poolsize, int nloops) {
int main(int argc, char *argv[]) {
// defaults
int ncpus = 0;
int poolsize = 1;
int nloops = 100000;
......@@ -56,10 +52,6 @@ int main(int argc, char *argv[]) {
char *arg = argv[i];
if (arg[0] != '-')
break;
if (strcmp(arg, "--ncpus") == 0 && i+1 < argc) {
ncpus = atoi(argv[++i]);
continue;
}
if (strcmp(arg, "--poolsize") == 0 && i+1 < argc) {
poolsize = atoi(argv[++i]);
continue;
......@@ -72,26 +64,10 @@ int main(int argc, char *argv[]) {
verbose = verbose > 0 ? verbose-1 : 0;
continue;
}
return usage(ncpus, poolsize);
}
int starti = i;
if (ncpus > 0) {
toku_cpuset_t cpuset;
TOKU_CPU_ZERO(&cpuset);
for (i = 0; i < ncpus; i++)
TOKU_CPU_SET(i, &cpuset);
int r;
r = toku_setaffinity(getpid(), sizeof cpuset, &cpuset);
assert(r == 0);
toku_cpuset_t use_cpuset;
TOKU_CPU_ZERO(&use_cpuset);
r = toku_getaffinity(getpid(), sizeof use_cpuset, &use_cpuset);
assert(r == 0);
assert(memcmp(&cpuset, &use_cpuset, sizeof cpuset) == 0);
return usage(poolsize);
}
int starti = i;
if (starti == argc) {
dotest(poolsize, nloops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment