Rewrite canvas caching
Complete rewrite of the caching mechanism (fixes #86 (closed))
Old system stored the entire canvas as a redis key, which is incredibly wasteful as changes would block any other modifications while saving
The canvas is split into 100x100 sections of pixels as redis keys, allowing each of them to be generated simultaneously
Features:
-
Canvas cached in 100x100 sections under the key CANVAS:PIXELS:x1,y1:x2,y2
(x1,y1 being the start of the area & x2,y2 being the end) -
Caching split into worker threads -
Pixel write queues are now stored in redis and split by worker (key: CANVAS:CACHE_QUEUE:worker_id
-- worker_id being the... worker id) -
Worker amount is controlled by environment variable CACHE_WORKERS
and defaults to1
if not specified -
Client correctly renders chunks in worker thread (if workers are available)
TODO:
-
Fix memory leak in CanvasRenderer#usePixels
-- there's no replace, upon reconnect sections could build up -- proposed solution: convert pixel storage into Map instead of array
Edited by Grant