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

Deprecate 'Time.getCurrentTime' #21467

Merged
merged 2 commits into from
Feb 1, 2023

Conversation

daviditen
Copy link
Member

Add a deprecation warning for 'Time.getCurrentTime'.

Update the Time and Random modules to use 'Time.timeSinceEpoch' instead. Update tests to use 'Time.timeSinceEpoch' instead. Update a PREDIFF script to look for 'timeSinceEpoch' instead of 'getCurrentTime'.

Add a deprecation test for 'Time.getCurrentTime'.

Closes #14571
Closes https://github.com/Cray/chapel-private/issues/4182

@daviditen
Copy link
Member Author

Passed linux64 paratest.
Passed linux64 CHPL_COMM=gasnet paratest.

Add a deprecation warning for 'Time.getCurrentTime'.

Update the Time and Random modules to use 'Time.timeSinceEpoch' instead.
Update tests to use 'Time.timeSinceEpoch' instead.

Add a deprecation test for 'Time.getCurrentTime'.

Signed-off-by: David Iten <[email protected]>
…entTime

This script uses calls to the timing functions to decide where to insert some
comm-counting code. Switch which timing functions it looks for.

Signed-off-by: David Iten <[email protected]>
@daviditen daviditen force-pushed the deprecate-getCurrentTime branch from 71cf3ff to a0b3a9e Compare January 31, 2023 17:01
Copy link
Contributor

@jeremiah-corrado jeremiah-corrado left a comment

Choose a reason for hiding this comment

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

Looks good!

I just have one concern with the random seed change:

suitable for the NPB RNG since that requires an odd seed.
*/
proc type currentTime: int(64) {
use Time;
const seed = getCurrentTime(unit=TimeUnits.microseconds):int(64);
const seed = (timeSinceEpoch().totalSeconds()*1_000_000):int(64);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm slightly worried about a loss of entropy/resolution in the seed since the last 6 digits will be zero. Is there a way to get the time in microseconds directly instead of multiplying by 1e6?

Specifically, I worry that there might be programs out there with the following assumption:

var sg = new SeedGenerator();

const s1 = sg.currentTime;
// do something that takes <1 second
const s2 = sg.currentTime;

assert(s1 != s2);

Copy link
Member Author

Choose a reason for hiding this comment

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

The last 6 digits won't actually be zero because totalSeconds() returns a real that includes the microseconds part after the decimal point. The main worry I had about this change was that it could lose precision due to the seconds since the Unix epoch being significantly larger than the seconds since midnight.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, my bad, I didn't realize it was a real. I think this change makes sense then. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, thank you!

@daviditen daviditen merged commit d8c412d into chapel-lang:main Feb 1, 2023
@daviditen daviditen deleted the deprecate-getCurrentTime branch February 1, 2023 18:36
jabraham17 added a commit that referenced this pull request Jan 11, 2024
Removes a collection of previously deprecated symbols from the Time
module.

The removed symbols were deprecated in the following PRs:
- #21826
- #22028
- #19955
- #21467
- #21034
- a subset of the symbols in #23114

Testing
- [x] paratest without comm
- [x] paratest with comm
- [x] built and checked docs

[Reviewd by @riftEmber]
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.

Time.getCurrentTime behavior isn't generally useful
2 participants