I’m still cleaning up the astrid cython module, it’s pretty exciting. I
discovered a really bad aspect of the previous architecture that was
difficult to see until I pulled the new Renderer class out
of the catch-all Instrument. Briefly, the instrument cache
was (of course, duh, it feels obvious now) local to the renderer
process.
Meaning, if there’s a renderer pool of 20 renderers, then you’ve really got 20 copies of the cache. The way the cache is populated is by invoking a (user-defined) callback on the instrument module when the module is loaded or reloaded. The actual reloading is lazy, though, and needs to be provoked by a render event. Which means for 20 renderers, the cache will only be warm after all the renderers have done a render.
It’s not a big deal, but when using the cache to store ~1GB of indexed samples, that cache fill causes real latency on the render. It always felt like the cache was weirdly sticky, but of course this was the reason.
I removed it completely in favor of adding support for storing collections of buffers in the new shared resource interfaces. It could work like a graphics sprite, I think, and just use the existing C buffer storage interface. From cython take a collection of buffers and write them into a single shared buffer – storing the offsets alongside in a shared table?
Reads could be pretty efficient this way, even when needing a copy: load the table first, then use the requested index to look up the appropriate offsets, aquire the buffer in shared memory and copy the requested segment into the result.
Doing the feature in C first before I add support for python is becoming a useful way to work on astrid. It’s nice to worry about the implementation first, just get it working, and then think about a nice python interface for it and how to make that work. It’s weird for me since I tend to go the other way around usually: start with the interface I want and work backward from there. For the type of plumbing I’m doing in astrid right now though, coming from the other direction seems a little easier.