Skip to content
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-25923: Cache result from yamlCamera.makeCamera #275

Merged
merged 1 commit into from Jul 14, 2020
Merged

Conversation

timj
Copy link
Member

@timj timj commented Jul 13, 2020

Constructing a camera from YAML can take a long time (10 seconds for imsim) but the resulting object is immutable. Caching can significantly speed up code that creates multiple cameras (in particular gen2 to 3 conversion code).

Copy link
Contributor

@SimonKrughoff SimonKrughoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small point of clarification.

@@ -31,6 +32,7 @@
__all__ = ["makeCamera"]


@lru_cache(maxsize=20)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why maxsize is altered from the default of 128. I guess you'll say that we won't have more than 20 cameras anyway, but if that's the argument leaving the default would seem to be OK. If we did use the default, would holding 128 cameras in memory be an issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was sort of thinking "20 is more cameras than could ever be wanted in a single process" so picked that. I can definitely remove it if it's confusing. Cameras are quite large in general but I can't really foresee a situation where we have 128 instruments in one process and that's our only concern about memory.

Constructing a camera from YAML can take a long time
(10 seconds for imsim) but the resulting object is
immutable.  Caching can significantly speed up code
that creates multiple cameras (in particular gen2 to 3
conversion code).
@timj timj merged commit 935fffe into master Jul 14, 2020
@timj timj deleted the tickets/DM-25923 branch July 14, 2020 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants