|
mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
|
Go to the source code of this file.
Classes | |
| struct | qItem |
| Singly linked queue node representing a metatile job to submit to renderd. More... | |
| struct | speed_stat |
| Aggregated rendering latency and throughput counters for a single zoom level. More... | |
| struct | speed_stats |
| Per-zoom-level collection of rendering speed statistics (0 through MAX_ZOOM). More... | |
Functions | |
| int | make_connection (const char *spath) |
| Open a stream connection to renderd over a Unix domain socket or TCP/IP socket. | |
| void | check_load (void) |
| Throttle worker submission while the system 1-minute load average meets or exceeds maxLoad. | |
| void | display_rate (struct timeval start, struct timeval end, int num) |
| Log the elapsed time and average throughput (tiles/sec) for a batch of rendered tiles. | |
| void | enqueue (const char *xmlname, int x, int y, int z) |
| Enqueue a metatile render request onto the bounded worker submission queue. | |
| void | finish_workers (void) |
| Signal all worker threads to finish remaining queued items and join them. | |
| void | print_statistics (void) |
| Log per-zoom-level minimum, average, maximum, and cumulative render times. | |
| void | spawn_workers (int num, const char *socketpath, int maxLoad) |
| Initialize synchronization primitives and spawn the pool of render-client worker threads. | |
| void * | thread_main (void *arg) |
| Worker thread main loop that fetches queued requests and submits them to renderd. | |
| void | wait_for_empty_queue (void) |
| Block the calling thread until all currently queued items have been popped by workers. | |
| void check_load | ( | void | ) |
Throttle worker submission while the system 1-minute load average meets or exceeds maxLoad.
Polls get_load_avg() in a loop and sleeps 5 seconds per iteration until system load drops below maxLoad.
| void display_rate | ( | struct timeval | start, |
| struct timeval | end, | ||
| int | num ) |
Log the elapsed time and average throughput (tiles/sec) for a batch of rendered tiles.
| start | Timestamp captured at the start of the batch. |
| end | Timestamp captured at the end of the batch. |
| num | Total number of tiles/metatiles processed during the interval. |
| void enqueue | ( | const char * | xmlname, |
| int | x, | ||
| int | y, | ||
| int | z ) |
Enqueue a metatile render request onto the bounded worker submission queue.
Allocates a qItem node, blocks on qCondNotFull if the queue has reached qMaxLen, appends the node to the FIFO list, and signals qCondNotEmpty to wake a waiting worker.
| xmlname | Logical map style name (duplicated onto the heap). |
| x | Top-left tile X coordinate of the metatile. |
| y | Top-left tile Y coordinate of the metatile. |
| z | Tile zoom level. |
| void finish_workers | ( | void | ) |
Signal all worker threads to finish remaining queued items and join them.
Sets work_complete = 1, broadcasts qCondNotEmpty so idle workers exit fetch(), joins every worker thread via pthread_join(), and frees the workers handle array.
| int make_connection | ( | const char * | spath | ) |
Open a stream connection to renderd over a Unix domain socket or TCP/IP socket.
Interprets spath based on its leading character:
| spath | Socket path (starting with '/') or TCP host[:port] specification. |
| void print_statistics | ( | void | ) |
Log per-zoom-level minimum, average, maximum, and cumulative render times.
Iterates from zoom 0 through MAX_ZOOM, skipping any zoom levels with zero rendered requests, and formats millisecond timings from performance_stats as seconds.
| void spawn_workers | ( | int | num, |
| const char * | spath, | ||
| int | max_load ) |
Initialize synchronization primitives and spawn the pool of render-client worker threads.
Configures the bounded queue capacity (qMaxLen = num) and system load ceiling (maxLoad), initializes qLock, qStatsLock, qCondNotEmpty, and qCondNotFull, and launches num threads running thread_main().
| num | Number of worker threads to spawn. |
| spath | Socket path or host[:port] string passed to each worker thread. |
| max_load | Maximum system 1-minute load average allowed before throttling workers. |
| void * thread_main | ( | void * | arg | ) |
Worker thread main loop that fetches queued requests and submits them to renderd.
Opens a dedicated connection to renderd via make_connection(), then repeatedly checks system load, pops the next command via fetch(), and submits it via process(). If the connection drops mid-flight, retries connecting every 30 seconds and re-submits the interrupted command until it succeeds.
| arg | const char * socket path or host[:port] string forwarded to make_connection(). |
| void wait_for_empty_queue | ( | void | ) |
Block the calling thread until all currently queued items have been popped by workers.
Waits on qCondNotFull (which is signaled every time fetch() decrements qLen) until qLen reaches 0. Note that the final popped items may still be in flight inside process() when this function returns; call finish_workers() to wait for completion.