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

U/danielsf/rmjarvis/cut gsco #67

Merged
merged 7 commits into from
Oct 10, 2018
Merged

Conversation

danielsf
Copy link
Contributor

@danielsf danielsf commented Oct 8, 2018

This adds a unit test on top of @rmjarvis 's PR storing floats in a numpy array in GalSimCelestialObject

@@ -120,9 +142,32 @@ def galSimType(self, value):
raise RuntimeError("You should not be setting galSimType on the fly; " \
+ "just instantiate a new GalSimCelestialObject")

@property
def npoints(self):
return self._float_values[15]
Copy link
Contributor

Choose a reason for hiding this comment

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

npoints is an int. Probably should either (a) leave that out of _float_values and keep it as a regular attribute or (b) explicitly cast back to an int here in the getter.

Double precision should be fine to capture any int value we would use without weird rounding errors, so (b) is probably fine. But it might cause problems if it's allowed to turn into a float.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like Francois already casts it into an int when it gets used

https://github.com/lsst/sims_GalSimInterface/blob/master/python/lsst/sims/GalSimInterface/galSimInterpreter.py#L465

I'm not sure how zealous we want to be in cutting every possible bit of python overhead from our memory footprint. If you still think it would be safer to go back to storing self._npoints as an int, I can do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be slightly paranoid of me, but if you want to be absolutely sure that we're safe, I'd make the getter here return int(self._float_values[15] + 0.5). Just to make sure some floating point imprecision doesn't convert an int into something like 3.3999999999987e1 and get messed up by the (implicit) floor in the conversion back to int.

Copy link
Contributor

Choose a reason for hiding this comment

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

But again, I do think that we would be safe even without that. I'm just not 100% positive. But rounding will definitely be safe over the range of npoints values we'll ever be using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented your suggestion.

@danielsf
Copy link
Contributor Author

danielsf commented Oct 9, 2018

I will run this through Jenkins. If it passes (and no one objects) I will merge this at the end of the day.

@jchiang87
Copy link
Contributor

I ran my little test of the memory profile just for the GSCO creation and added the profile curve I get using this code:
gsco_mj_refactor
For the fixed and mj_gsco cases, the memory devoted to the GSCOs is the vertical extent of the corresponding curve starting from the base of that double peaked feature to the maximum (i.e., that linear ramp is the loop over the objects to make the GSCOs). Using the original GSCO class, the uss memory is 0.77GB while using Mike's new version it's 0.50GB--a ~35% savings. BTW, I accidentally overwrote the data for the baseline curve, so I reran it, and it looks a little different from the original figure in my talk yesterday. The relative slowdown before the double peaked feature is just from variation in disk access speed as that part of the curve is reading in the data.

Copy link
Contributor

@jchiang87 jchiang87 left a comment

Choose a reason for hiding this comment

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

lgtm

@cwwalter
Copy link
Member

cwwalter commented Oct 9, 2018

Great... confused by one thing though: are the differences in run time from other speed changes? Or is this really only the GSCO change?

@jchiang87
Copy link
Contributor

The only runtime variation that's apparent to me is the disk access part. The linear ramp for the fixed and mj_gsco are the same since they are processing the same number of objects. The corresponding ramp in the baseline case is longer because it is processing almost twice as many objects as the other two cases.

@cwwalter
Copy link
Member

cwwalter commented Oct 9, 2018

OK that explains it. Thanks.

@rmjarvis
Copy link
Contributor

rmjarvis commented Oct 9, 2018

The corresponding ramp in the baseline case is longer because it is processing almost twice as many objects as the other two cases.

And that is not an input catalog difference -- that's because of your reordering, right? I think you said it used to process a bunch of things that ended up getting cut out at the end, so were actually wasted. So that's a real speedup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants