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

JDK-8273979: move some os time related functions to os_posix for POSIX platforms #5582

Closed
wants to merge 2 commits into from

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Sep 20, 2021

There are a couple of time related functions in os_ for Linux, BSD+Mac and AIX that are pretty similar (or identical) across the platforms and can be centralized in os_posix .
While doing so, I noticed that os::supports_vtime() returns always true , on Posix and also on Windows, so we might remove it completely if this prefered ?

Best regards , Matthias


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8273979: move some os time related functions to os_posix for POSIX platforms

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5582/head:pull/5582
$ git checkout pull/5582

Update a local copy of the PR:
$ git checkout pull/5582
$ git pull https://git.openjdk.java.net/jdk pull/5582/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5582

View PR using the GUI difftool:
$ git pr show -t 5582

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5582.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 20, 2021

👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 20, 2021
@openjdk
Copy link

openjdk bot commented Sep 20, 2021

@MBaesken The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Sep 20, 2021
@mlbridge
Copy link

mlbridge bot commented Sep 20, 2021

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Hi Matthias,

Generally this refactoring looks good, though I have a request to restore some of the code - see comments below. Also could you clarify where functions were only "pretty similar" rather than identical as we don't want to introduce subtle incompatibilities.

I think supports_vtime() could probably be removed in a separate RFE.

Thanks,
David

@@ -994,49 +977,6 @@ jlong os::javaTimeNanos() {
}
}

void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
Copy link
Member

Choose a reason for hiding this comment

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

Please restore this. As has been discussed in previous refactorings in this code if there is a platform specific definition of javaTimeNanos then we should keep the platform specific definition of javaTimeNanos_info, even if it happens to be the same as on other platforms. Otherwise if the javaTimeNanos code were changed one would not realise they also may have to change javaTimenanos_info.

@@ -804,52 +784,8 @@ jlong os::javaTimeNanos() {
// See https://blogs.oracle.com/dave/entry/cas_and_cache_trivia_invalidate
return (prev == obsv) ? now : obsv;
}

void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
Copy link
Member

Choose a reason for hiding this comment

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

Please restore as per previous comment.

Comment on lines 94 to 98
#if defined(_ALLBSD_SOURCE)
static int clock_tics_per_sec = CLK_TCK;
#else
static int clock_tics_per_sec = 100;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just defer the conditional initialization to the init() function where we already have to conditionally initialise.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Thanks Matthias - updates look good.

David

@openjdk
Copy link

openjdk bot commented Sep 21, 2021

@MBaesken This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8273979: move some os time related functions to os_posix for POSIX platforms

Reviewed-by: dholmes, lucy

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 44 new commits pushed to the master branch:

  • d9872ba: 8273590: Move helper classes in G1 post evacuation sub tasks to cpp files
  • 688b3fe: 8274070: Rectify problemlist platform for failing test on macos12
  • eeaf43b: 8274114: ProblemList serviceability/sa/TestJhsdbJstackMixed.java on linux-aarch64 in -Xcomp mode
  • 517405e: 8273965: some testlibrary_tests/ir_framework tests fail when c1 disabled
  • 11cddd3: 8272114: Unused _last_state in osThread_windows
  • cbe57e8: 8273684: Replace usages of java.util.Stack with ArrayDeque
  • a72c8aa: 8273921: Refactor NSK/JDI tests to create thread using factory
  • 161fdb4: 8273935: (zipfs) Files.getFileAttributeView() throws UOE instead of returning null when view not supported
  • 0fc47e9: 8266666: Implementation for snippets
  • 6d91a3e: 8269039: Disable SHA-1 Signed JARs
  • ... and 34 more: https://git.openjdk.java.net/jdk/compare/d2388b7a0f4bfb55ea0d5648175e3253f30a4302...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 21, 2021
@MBaesken
Copy link
Member Author

MBaesken commented Sep 21, 2021

Hi David, I brought back os::javaTimeNanos_info following your suggestion and adjusted the initialization of 'clock_tics_per_sec ' in os_posix.

Also could you clarify where functions were only "pretty similar" rather than identical as we don't want to introduce subtle incompatibilities

Sure, went through them and this is what I found
os::elapsedTime() identical except comment
os::elapsed_counter() identical
os::elapsed_frequency() identical
os::supports_vtime() identical
os::getTimesSecs identical
os::local_time_string identical
os::localtime_pd identical

I think supports_vtime() could probably be removed in a separate RFE.

OK, I opened https://bugs.openjdk.java.net/browse/JDK-8274051 .

@@ -171,8 +171,6 @@ os::Linux::mallinfo_func_t os::Linux::_mallinfo = NULL;
os::Linux::mallinfo2_func_t os::Linux::_mallinfo2 = NULL;
#endif // __GLIBC__

static jlong initial_time_count=0;

static int clock_tics_per_sec = 100;

Copy link
Contributor

Choose a reason for hiding this comment

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

In os_linux.cpp, clock_tics_per_sec is used for elapsed time calculations as well as for cpu time calculations. In addition, clock_tics_per_sec is set (reinitialised) in os::init(). Are we sure that _SC_CLK_TCK evaluates to 100? If no, do we then potentially calculate wrong elapsed times after moving the code to os_posix?

Copy link
Contributor

@RealLucy RealLucy left a comment

Choose a reason for hiding this comment

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

My previous comment about clock_ticks_per_sec is obsolete. Just saw the initialisation in os::Posix::init(void) now is the same as in os::init(). The static init value is in effect only for the short time until os::init() is invoked.
Looks good to me.

@MBaesken
Copy link
Member Author

My previous comment about clock_ticks_per_sec is obsolete. Just saw the initialisation in os::Posix::init(void) now is the same as in os::init(). The static init value is in effect only for the short time until os::init() is invoked.
Looks good to me.

Hi Lutz, thanks for the review .
In case of worries about the short time frame between posix and linux init functions, we could introduce 'os::clock_ticks_per_sec()' and move this to os_linux, os_aix os_bsd etc. to have the initialization at one single point.
Not sure if this is worth the effort?

Best regards, Matthias

@RealLucy
Copy link
Contributor

I would not add this complexity. Just leave it as it is.

@MBaesken
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 23, 2021

Going to push as commit 1c6fa11.
Since your change was applied there have been 65 commits pushed to the master branch:

  • 45adc92: 8273578: javax/swing/JMenu/4515762/bug4515762.java fails on macOS 12
  • 0fbbe4c: 8274033: Some tier-4 CDS EpsilonGC tests throw OOM
  • 9d3379b: 8267356: AArch64: Vector API SVE codegen support
  • 6031388: 8273714: jdk/jfr/api/consumer/TestRecordedFrame.java still times out after JDK-8273047
  • 8821b00: 8205137: Remove Applet support from SwingSet2
  • 57fe11c: 8274120: [JVMCI] CompileBroker should resolve parameter types for JVMCI compiles
  • 81d4164: 8272759: (fc) java/nio/channels/FileChannel/Transfer2GPlus.java failed in timeout
  • da38ced: 8271602: Add Math.ceilDiv() family parallel to Math.floorDiv() family
  • d39aad9: 8273924: ArrayIndexOutOfBoundsException thrown in java.util.JapaneseImperialCalendar.add()
  • c9de806: 8274039: codestrings gtest fails when hsdis is present
  • ... and 55 more: https://git.openjdk.java.net/jdk/compare/d2388b7a0f4bfb55ea0d5648175e3253f30a4302...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Sep 23, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 23, 2021
@openjdk
Copy link

openjdk bot commented Sep 23, 2021

@MBaesken Pushed as commit 1c6fa11.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@rvansa
Copy link

rvansa commented Aug 28, 2024

/backport jdk17u-dev

@openjdk
Copy link

openjdk bot commented Aug 28, 2024

@rvansa the backport was successfully created on the branch backport-rvansa-1c6fa113-master in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 1c6fa113 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 23 Sep 2021 and was reviewed by David Holmes and Lutz Schmidt.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-rvansa-1c6fa113-master:backport-rvansa-1c6fa113-master
$ git checkout backport-rvansa-1c6fa113-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-rvansa-1c6fa113-master

⚠️ @rvansa You are not yet a collaborator in my fork openjdk-bots/jdk17u-dev. An invite will be sent out and you need to accept it before you can proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants