-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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-8266536: Provide a variant of os::iso8601_time which works with arbitrary timestamps #3869
JDK-8266536: Provide a variant of os::iso8601_time which works with arbitrary timestamps #3869
Conversation
👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into |
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.
The API change looks good to me. I understand that this is prerequisite of your logdecoration change. make sense.
I don't understand your change in harfbuzz header.
@@ -375,7 +375,7 @@ hb_iter_with_fallback_t<machine_index_t<Iter>, | |||
typename Iter::item_t> | |||
{ | |||
machine_index_t (const Iter& it) : it (it) {} | |||
machine_index_t (const machine_index_t& o) : it (o.it) {} | |||
machine_index_t (const machine_index_t& o) : hb_iter_with_fallback_t<machine_index_t<Iter>, typename Iter::item_t>(o), it (o.it) {} |
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.
is it relevant?
I feel it belongs to a separated issue.
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.
Sorry, forgot to mention. Unrelated harfbuzz build fix for gcc 8 and earlier. Will remove before the final push.
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.
The API change looks good to me. I understand that this is prerequisite of your logdecoration change. make sense.
I don't understand your change in harfbuzz header.
Thanks for your review, Xin.
Webrevs
|
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.
Change looks good. I have just two minor questions (see inline).
Thanks for adding the gtest!
static bool very_simple_string_matcher(const char* pattern, const char* s) { | ||
const size_t lp = strlen(pattern); | ||
const size_t ls = strlen(s); | ||
if (ls < lp) { |
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.
Shouldn't this be !=
?
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.
I wanted to be able to give prefix pattern which do not cover the whole string.
result = os::iso8601_time(buffer, sizeof(buffer), false); | ||
tty->print_cr("%s", result); | ||
EXPECT_EQ(result, buffer); | ||
EXPECT_TRUE(very_simple_string_matcher(pattern, result)); |
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.
Do you intentionally repeat this same test for a second time? Does it provide any benefit?
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.
Oops, no, this is an oversight. I'll remove the second test, thanks for catching this.
Thanks Volker! |
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.
Looks good, thanks.
@tstuefe 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:
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 20 new commits pushed to the
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 |
Thank you Volker! |
src/hotspot/share/runtime/os.hpp
Outdated
// Fill in buffer with an ISO-8601 string corresponding to the given javaTimeMillis value | ||
// E.g., YYYY-MM-DDThh:mm:ss.mmm+zzzz. | ||
// Returns buffer, or NULL if it failed. | ||
static char* iso8601_time(jlong milliseconds_since_19700101, char buffer[29], |
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.
You are supposed to get a compiler warning on this char buffer[29]. ISO C/C++ can't pass in array type as a function argument. As a result, the type buffer automatically casts to char* here.
Further, the function signature is different from its implementation, which use char* buffer instead.
I see that you do enforce length checking in implementation.
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.
Oh, good catch, this is a stray edit I thought I reverted. See below.
ISO C/C++ can't pass in array type as a function argument. As a result, the type buffer automatically casts to char* here.
No, it can, that's totally fine. It gets automatically translated to pointer type, but its a valid expression nonetheless.
It is usually done to indicate that a function expects an output array of a particular length instead of letting the caller guess the right length - and letting him to deal with truncation if he guesses wrong.
I originally planned to define the function as
iso8601_time(jlong milliseconds_since_19700101, char buffer[29]);
to indicate that the only output value length which makes sense is 29, but then I refrained because I wanted to keep the patch simple.
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.
C/C++ allow you to write code like that, but they won't check the length of argument <=29 for you.
I think you sanity check inside of iso8601_time() is good enough.
Thanks @navyxliu and @simonis and @YaSuenag for your reviews. Last change:
@YaSuenag could you please officially approve this PR? Unfortunately, Xin is no committer yet, so I need a second reviewer. Thanks, Thomas |
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.
Looks good!
I think needed_buffer
in os::iso8601_time()
is no longer needed, but it's ok if it is left.
Thanks Yasumasa! I changed the code a bit and removed needed_buffer. |
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.
Thank you for fixing it! It still looks good.
/integrate |
@tstuefe Since your change was applied there have been 21 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 94c6177. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
We have os::iso8601_time(), which gives an ISO8601 timestamp of the current time. It would be very useful to have a second variant which can be fed an arbitrary numerical timestamp.
This is useful in the context of making asynchronous UL logging cheaper (see JDK-8229517)
This patch provides an additional API:
char* os::iso8601_time(jlong milliseconds_since_19700101, char* buffer, size_t buffer_length, bool utc);
alongside the existing
char* os::iso8601_time(char* buffer, size_t buffer_length, bool utc);
and implements the latter using the former. Not much code added.
In addition, it adds a regression gtest for these APIs.
Please ignore the harfbuzz change, its a build fix needed for older gcc, will be removed before final push.
Testing: GHA, manual gtests, SAP nightlies on all our platforms.
Thanks, Thomas
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3869/head:pull/3869
$ git checkout pull/3869
Update a local copy of the PR:
$ git checkout pull/3869
$ git pull https://git.openjdk.java.net/jdk pull/3869/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3869
View PR using the GUI difftool:
$ git pr show -t 3869
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3869.diff