-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-39582: Decrease memory usage and load times when reading graphs #348
Changes from 5 commits
b7b3cc3
1b8f686
d5cad86
a9fc5e0
11053de
fc3e73f
628e539
4f276c9
44f5f6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Deprecated reconstituteDimensions argument from QuantumNode.from_simple | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The back-end to quantum graph loading has been optimized such that duplicate objects are not created in | ||
memory, but create shared references. This results in a large decrease in memory usage, and decrease in load | ||
times. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,10 @@ | |
from typing import TYPE_CHECKING, BinaryIO | ||
from uuid import UUID | ||
|
||
from lsst.daf.butler import DimensionUniverse | ||
from lsst.daf.butler import DimensionUniverse, PersistenceContextVars | ||
from lsst.resources import ResourceHandleProtocol, ResourcePath | ||
|
||
|
||
if TYPE_CHECKING: | ||
from ._versionDeserializers import DeserializerBase | ||
from .graph import QuantumGraph | ||
|
@@ -219,7 +220,11 @@ def load( | |
_readBytes = self._readBytes | ||
if universe is None: | ||
universe = headerInfo.universe | ||
return self.deserializer.constructGraph(nodeSet, _readBytes, universe) | ||
# use the daf butler context vars to aid in ensuring deduplication in | ||
# object instantiation. | ||
runner = PersistenceContextVars() | ||
graph = runner.run(self.deserializer.constructGraph, nodeSet, _readBytes, universe) | ||
return graph # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not entirely understand PersistenceContextVars/context vars, would it be nice if it could work like a regular context manager, e.g.:
but may be it's not possible? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I worked on that for a while, and the outcome kept coming out more awkward, and not at all nice like that. I think it is mostly because context vars are more geared toward asyncio, callback programming style. |
||
|
||
def _readBytes(self, start: int, stop: int) -> bytes: | ||
"""Load the specified byte range from the ResourcePath object | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably
removal.md
instead ofapi.md
?