From 911670bc237733163252ac7c16b82764ceb92c0d Mon Sep 17 00:00:00 2001 From: Stephan Plepelits Date: Wed, 29 Feb 2012 10:33:33 +0100 Subject: [PATCH 1/2] gen_tile: Instead of two DONE messages write START and DONE messages --- gen_tile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen_tile.cpp b/gen_tile.cpp index f57e6a4b..8ca73fc9 100644 --- a/gen_tile.cpp +++ b/gen_tile.cpp @@ -459,8 +459,6 @@ static enum protoCmd render(struct xmlmapconfig * map, int x, int y, int z, meta tiles.set(xx, yy, save_to_string(vw, "png256")); } } -// std::cout << "DONE TILE " << xmlname << " " << z << " " << x << "-" << x+size-1 << " " << y << "-" << y+size-1 << "\n"; -// syslog(LOG_DEBUG, "DEBUG: DONE TILE %s %d %d-%d %d-%d", xmlname, z, x, x+size-1, y, y+size-1); return cmdDone; // OK } #else //METATILE @@ -588,6 +586,8 @@ void *render_thread(void * arg) timeval tim; gettimeofday(&tim, NULL); long t1=tim.tv_sec*1000+(tim.tv_usec/1000); + syslog(LOG_DEBUG, "DEBUG: START TILE %s %d %d-%d %d-%d", + req->xmlname, req->z, item->mx, item->mx+size-1, item->my, item->my+size-1); ret = render(&(maps[i]), item->mx, item->my, req->z, tiles); From 7028bde54fd5dade5871d2641b1ec3b9fb1cfa64 Mon Sep 17 00:00:00 2001 From: Stephan Plepelits Date: Thu, 1 Mar 2012 19:15:28 +0100 Subject: [PATCH 2/2] Add time of old metatile to item structure, print age when starting rendering - struct item got value 'old_mtime', holding the time of the old metatile (or 0 for new tiles) --- daemon.c | 16 ++++++++++++++++ gen_tile.cpp | 12 ++++++++++-- gen_tile.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/daemon.c b/daemon.c index d7eb60a7..a6b6bb87 100644 --- a/daemon.c +++ b/daemon.c @@ -80,6 +80,20 @@ void send_response(struct item *item, enum protoCmd rsp, int render_time) { } } +void item_load(struct item *item, const struct protocol *req) { + char path[PATH_MAX]; + struct stat buf; + xyz_to_meta(path, sizeof(path), HASH_PATH, req->xmlname, req->x, req->y, req->z); + if(!stat(path, &buf)) { + // save time of old tile + item->old_mtime=buf.st_mtime; + } + else { + // no tile + item->old_mtime=0; + } +} + enum protoCmd rx_request(const struct protocol *req, int fd) { struct protocol *reqnew; @@ -114,6 +128,8 @@ enum protoCmd rx_request(const struct protocol *req, int fd) item->duplicates = NULL; item->fd = (req->cmd == cmdDirty) ? FD_INVALID : fd; + item_load(item, req); + #ifdef METATILE /* Round down request co-ordinates to the neareast N (should be a power of 2) * Note: request path is no longer consistent but this will be recalculated diff --git a/gen_tile.cpp b/gen_tile.cpp index 8ca73fc9..2c9e79eb 100644 --- a/gen_tile.cpp +++ b/gen_tile.cpp @@ -586,15 +586,23 @@ void *render_thread(void * arg) timeval tim; gettimeofday(&tim, NULL); long t1=tim.tv_sec*1000+(tim.tv_usec/1000); - syslog(LOG_DEBUG, "DEBUG: START TILE %s %d %d-%d %d-%d", - req->xmlname, req->z, item->mx, item->mx+size-1, item->my, item->my+size-1); + + if(item->old_mtime==0) + syslog(LOG_DEBUG, "DEBUG: START TILE %s %d %d-%d %d-%d, new metatile", + req->xmlname, req->z, item->mx, item->mx+size-1, item->my, item->my+size-1); + else + syslog(LOG_DEBUG, "DEBUG: START TILE %s %d %d-%d %d-%d, age %.3f days", + req->xmlname, req->z, item->mx, item->mx+size-1, item->my, item->my+size-1, + (tim.tv_sec-item->old_mtime)/86400.0); ret = render(&(maps[i]), item->mx, item->my, req->z, tiles); gettimeofday(&tim, NULL); long t2=tim.tv_sec*1000+(tim.tv_usec/1000); + syslog(LOG_DEBUG, "DEBUG: DONE TILE %s %d %d-%d %d-%d in %.3lf seconds", req->xmlname, req->z, item->mx, item->mx+size-1, item->my, item->my+size-1, (t2 - t1)/1000.0); + render_time = t2 - t1; if (ret == cmdDone) { diff --git a/gen_tile.h b/gen_tile.h index fcc5571c..bd76f13b 100644 --- a/gen_tile.h +++ b/gen_tile.h @@ -20,6 +20,7 @@ struct item { int fd; struct item *duplicates; enum queueEnum inQueue; + time_t old_mtime; }; //int render(Map &m, int x, int y, int z, const char *filename);