More calculation about how many fds are available

This commit is contained in:
Eric Fischer
2016-04-01 15:31:34 -07:00
parent 24deae5a43
commit 560add2ccd
+29 -29
View File
@@ -1135,11 +1135,13 @@ void radix(struct reader *reader, int nreaders, int *indexfd, int *geomfd) {
printf("you have %lld files and %lld memory\n", (long long) rl.rlim_cur, mem); printf("you have %lld files and %lld memory\n", (long long) rl.rlim_cur, mem);
long long availfiles = rl.rlim_cur long long availfiles = rl.rlim_cur - 2 * nreaders // each reader has a geom and an index
- 2 * nreaders // each reader has a geom and an index - 3 // pool, meta, mbtiless
- 3; // stdin, stdout, stderr - 3; // stdin, stdout, stderr
int splitbits = log(availfiles) / log(2); int splitbits = log(availfiles / 2) / log(2);
printf("can skim off %d bits\n", splitbits);
int geomfds[nreaders]; int geomfds[nreaders];
int indexfds[nreaders]; int indexfds[nreaders];
@@ -1597,7 +1599,7 @@ int read_json(int argc, struct source **sourcelist, char *fname, const char *lay
} }
} }
radix(reader, CPUS, NULL, NULL); // XXX radix(reader, CPUS, NULL, NULL); // XXX
/* Join the sub-indices together */ /* Join the sub-indices together */
@@ -2256,31 +2258,29 @@ int main(int argc, char **argv) {
layer = optarg; layer = optarg;
break; break;
case 'L': case 'L': {
{ char *cp = strchr(optarg, ':');
char *cp = strchr(optarg, ':'); if (cp == NULL || cp == optarg) {
if (cp == NULL || cp == optarg) { fprintf(stderr, "%s: -L requires layername:file\n", argv[0]);
fprintf(stderr, "%s: -L requires layername:file\n", argv[0]); exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
struct source *src = malloc(sizeof(struct source));
if (src == NULL) {
perror("Out of memory");
exit(EXIT_FAILURE);
}
src->layer = strdup(optarg);
src->file = strdup(cp + 1);
if (src->layer == NULL || src->file == NULL) {
perror("Out of memory");
exit(EXIT_FAILURE);
}
src->layer[cp - optarg] = '\0';
src->next = sources;
sources = src;
nsources++;
} }
break; struct source *src = malloc(sizeof(struct source));
if (src == NULL) {
perror("Out of memory");
exit(EXIT_FAILURE);
}
src->layer = strdup(optarg);
src->file = strdup(cp + 1);
if (src->layer == NULL || src->file == NULL) {
perror("Out of memory");
exit(EXIT_FAILURE);
}
src->layer[cp - optarg] = '\0';
src->next = sources;
sources = src;
nsources++;
} break;
case 'z': case 'z':
maxzoom = atoi(optarg); maxzoom = atoi(optarg);