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

src: use uv_gettimeofday() #27029

Merged
merged 2 commits into from Apr 22, 2019

Conversation

Projects
None yet
4 participants
@cjihrig
Copy link
Contributor

commented Mar 31, 2019

Labeled as a WIP until the next libuv update (ignore the first commit here).

The next version of libuv will provide uv_gettimeofday() as a cross platform alternative to gettimeofday().

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
@nodejs-github-bot

This comment has been minimized.

@refack

refack approved these changes Mar 31, 2019

Show resolved Hide resolved src/node_perf.cc Outdated
Show resolved Hide resolved src/node_perf.cc Outdated
uv_timeval_t ts;
if (uv_gettimeofday(&ts) == 0) {
writer.json_keyvalue("dumpEventTimeStamp",
std::to_string(ts.tv_sec * 1000 + ts.tv_usec / 1000));

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Apr 1, 2019

Member

This might overflow when tv_sec is a 32 bits long.

(I kind of regret that we didn't use int64_t for uv_timeval_t.tv_sec...)

This comment has been minimized.

Copy link
@refack

refack Apr 1, 2019

Member

Maybe there's still time to change uv_gettimeofday to uint64_t uv_gettimeofday() (or unsigned long long int) and always return microseconds? Seems like uv_timeval_t is a little "legacy" for this API

This comment has been minimized.

Copy link
@cjihrig

cjihrig Apr 1, 2019

Author Contributor

That's not a bad idea. Since uv_gettimeofday() hasn't been released yet, there is time.

This comment has been minimized.

Copy link
@cjihrig

cjihrig Apr 1, 2019

Author Contributor

We can discuss at libuv/libuv#2243.

@cjihrig cjihrig force-pushed the cjihrig:timeofday branch from ec1ff0e to 07abdc8 Apr 15, 2019

@cjihrig

This comment has been minimized.

Copy link
Contributor Author

commented Apr 15, 2019

@bnoordhuis I think I've addressed your nits with the new libuv release.

@cjihrig cjihrig marked this pull request as ready for review Apr 16, 2019

@cjihrig cjihrig force-pushed the cjihrig:timeofday branch from 07abdc8 to adf34d5 Apr 22, 2019

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

Copy link

commented Apr 22, 2019

cjihrig added some commits Mar 31, 2019

report: use uv_gettimeofday for dumpEventTimeStamp
dumpEventTimeStamp was not implemented on Windows, and did not
include any error checking. This commit adds Windows support
and error checking.

PR-URL: #27029
Reviewed-By: Refael Ackermann <refack@gmail.com>
src: use uv_gettimeofday() to get microseconds
Use uv_gettimeofday() in GetCurrentTimeInMicroseconds() to
remove the need for #ifdef logic.

PR-URL: #27029
Reviewed-By: Refael Ackermann <refack@gmail.com>

@cjihrig cjihrig force-pushed the cjihrig:timeofday branch from adf34d5 to 8e1e994 Apr 22, 2019

@cjihrig

This comment has been minimized.

Copy link
Contributor Author

commented Apr 22, 2019

Landed in 90cf2d5...8e1e994.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.