summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wildemann <gta04@metalstrolche.de>2019-08-04 20:50:35 +0200
committerStefan Wildemann <gta04@metalstrolche.de>2019-08-04 20:50:35 +0200
commit72d975cb9677c96e9316dfe8705a90bff3d50fe6 (patch)
treec162fb88323099d59fad7b96eccf513b376b7a57
parent38cc16079fd9f923da483dbcb0b577830927a9ff (diff)
downloadnavit-72d975cb9677c96e9316dfe8705a90bff3d50fe6.tar.gz
Add T parameter to maptool commandline. Optimize multipolygon speed
-rw-r--r--navit/maptool/maptool.c17
-rw-r--r--navit/maptool/maptool.h1
-rw-r--r--navit/maptool/osm.c7
3 files changed, 18 insertions, 7 deletions
diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c
index 4594c4528..12aa50eda 100644
--- a/navit/maptool/maptool.c
+++ b/navit/maptool/maptool.c
@@ -52,6 +52,7 @@
long long slice_size=SLIZE_SIZE_DEFAULT_GB*1024ll*1024*1024;
int attr_debug_level=1;
int ignore_unknown = 0;
+int thread_count=8; /* good default even on single cores */
GHashTable *dedupe_ways_hash;
int phase;
int slices;
@@ -301,6 +302,7 @@ static void usage(void) {
"-S (--slice-size) <size> : limit memory to use for some large internal buffers, in bytes. Default is %dGB.\n",
SLIZE_SIZE_DEFAULT_GB);
fprintf(f,"-t (--timestamp) <y-m-dTh:m:s> : Set zip timestamp\n");
+ fprintf(f,"-T (--threads) <count> : Set number of threads (for some operations)\n");
fprintf(f,
"-w (--dedupe-ways) : ensure no duplicate ways or nodes. useful when using several input files\n");
fprintf(f,"-W (--ways-only) : process only ways\n");
@@ -377,6 +379,7 @@ static int parse_option(struct maptool_params *p, char **argv, int argc, int *op
{"protobuf", 0, 0, 'P'},
{"start", 1, 0, 's'},
{"timestamp", 1, 0, 't'},
+ {"threads", 1, 0, 'T'},
{"input-file", 1, 0, 'i'},
{"rule-file", 1, 0, 'r'},
{"ignore-unknown", 0, 0, 'n'},
@@ -391,7 +394,7 @@ static int parse_option(struct maptool_params *p, char **argv, int argc, int *op
#ifdef HAVE_POSTGRESQL
"d:"
#endif
- "e:hi:knm:p:r:s:t:wu:z:Ux:", long_options, option_index);
+ "e:hi:knm:p:r:s:t:T:wu:z:Ux:", long_options, option_index);
if (c == -1)
return 1;
switch (c) {
@@ -493,6 +496,9 @@ static int parse_option(struct maptool_params *p, char **argv, int argc, int *op
case 't':
p->timestamp=optarg;
break;
+ case 'T':
+ thread_count=atoi(optarg);
+ break;
case 'w':
dedupe_ways_hash=g_hash_table_new(NULL, NULL);
break;
@@ -727,18 +733,19 @@ static void osm_process_turn_restrictions(struct maptool_params *p, char *suffix
}
static void osm_process_multipolygons(struct maptool_params *p, char *suffix) {
- FILE *ways_split, *ways_split_index, *relations, *coords;
+ FILE *ways_split, *ways_split_index, *relations/*, *coords*/;
p->osm.multipolygons=tempfile(suffix,"multipolygons",0);
if(!p->osm.multipolygons)
return;
relations=tempfile(suffix,"multipolygons_out", 1);
- coords=fopen("coords.tmp", "rb");
+ /* no coords in multipolygons. */
+ //coords=fopen("coords.tmp", "rb");
ways_split=tempfile(suffix,"ways_split",0);
ways_split_index=tempfile(suffix,"ways_split_index",0);
- process_multipolygons(p->osm.multipolygons,coords,ways_split,ways_split_index,relations);
+ process_multipolygons(p->osm.multipolygons,/*coords*/NULL,ways_split,ways_split_index,relations);
fclose(ways_split_index);
fclose(ways_split);
- fclose(coords);
+ //fclose(coords);
fclose(relations);
fclose(p->osm.multipolygons);
if(!p->keep_tmpfiles)
diff --git a/navit/maptool/maptool.h b/navit/maptool/maptool.h
index aef344031..f0aee6fdf 100644
--- a/navit/maptool/maptool.h
+++ b/navit/maptool/maptool.h
@@ -235,6 +235,7 @@ extern struct item_bin *tmp_item_bin;
/* maptool.c */
extern long long slice_size;
+extern int thread_count;
extern int attr_debug_level;
extern char *suffix;
extern int ignore_unknown;
diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c
index 3610e4f25..2ec3ec667 100644
--- a/navit/maptool/osm.c
+++ b/navit/maptool/osm.c
@@ -2894,7 +2894,7 @@ static inline void dump_sequence(const char * string, int loop_count, int*scount
static void process_multipolygons_finish(GList *tr, FILE *out) {
GList *l=tr;
- fprintf(stderr,"process_multipolygons_finish\n");
+ //fprintf(stderr,"process_multipolygons_finish\n");
while(l) {
int a;
int b;
@@ -3226,7 +3226,7 @@ static GList ** process_multipolygons_setup(FILE *in, int thread_count, struct r
}
void process_multipolygons(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out) {
- int thread_count = 4;
+ /* thread count is from maptool.c as commandline parameter */
int i;
struct relations **relations;
GList **multipolygons = NULL;
@@ -3235,6 +3235,7 @@ void process_multipolygons(FILE *in, FILE *coords, FILE *ways, FILE *ways_index,
for(i=0; i < thread_count; i ++)
relations[i] = relations_new();
fseek(in, 0, SEEK_SET);
+ fprintf(stderr,"process_multipolygons:setup (threads %d)\n", thread_count);
multipolygons=process_multipolygons_setup(in,thread_count,relations);
/* Here we get an array of resulting relations structures and resultin
* GLists.
@@ -3248,7 +3249,9 @@ void process_multipolygons(FILE *in, FILE *coords, FILE *ways, FILE *ways_index,
fseek(coords, 0,SEEK_SET);
if(ways)
fseek(ways, 0,SEEK_SET);
+ fprintf(stderr,"process_multipolygons:process (thread %d)\n", i);
relations_process(relations[i], coords, ways);
+ fprintf(stderr,"process_multipolygons:finish (thread %d)\n", i);
process_multipolygons_finish(multipolygons[i], out);
relations_destroy(relations[i]);
}