Cache VertexOnlyMesh for cross-mesh interpolation#4860
Cache VertexOnlyMesh for cross-mesh interpolation#4860leo-collins wants to merge 3 commits intomainfrom
Conversation
connorjward
left a comment
There was a problem hiding this comment.
Sorry for the negativity, but caching correctly is really hard.
| """Return the symbolic ``Interpolate`` expressions for point evaluation and | ||
| re-ordering into the input-ordering VertexOnlyMesh. | ||
| @staticmethod | ||
| def _vom_cache_key(target_space, source_mesh, allow_missing_dofs): |
There was a problem hiding this comment.
Can't this just be a cached property?
| self.allow_missing_dofs, | ||
| ) | ||
| try: | ||
| return _vom_cache[key] |
There was a problem hiding this comment.
I don't really like this. The communicator is only implicitly part of this cache key so I think deadlocks could well happen.
Also you are using source_mesh as the key, creating a reference to it and meaning that it will never be cleared from the memory.
There was a problem hiding this comment.
What's the correct way to do this then?
There was a problem hiding this comment.
Step 1 is choosing an object to tie the lifetime of the VoM to. It's probably best to use source_mesh here.
I have implemented a fair amount of caching support that would easily handle this in pyop3, so you may want to wait for that or just port the (small) amount of code over that you need.
Cache the vom used for cross-mesh interpolation. Consider the following
The assembly of
h2previously took ~5s on my machine, with caching it now takes ~0.012s