fate of TimeValue

Hello all,

in line with the “deinventing the wheel” movement, I’d like to remove the TimeValue class from LLDB. I’ve done some research on a flight this week, and as far as I can tell all functionality can be easily replaced with appropriate usage of std::chrono::duration and time_point.

The only parts that are missing are the ability to convert to/from legacy C types (struct timevalue, struct timespec), which can be replaced by utility functions.

Also, I’ve found one use case particularly cumbersome to write in the c++ way: writing out a duration as a fractional number of units (e.g. milliseconds). So, I’d propose adding the following utility function as well (unless someone knows a cleaner way to write this):

template<typename DurOut, typename DurIn>
double float_duration(DurIn dur) {
return std::chrono::duration_cast<std::chrono::duration<double, DurOut::period>>(dur).count();
}

Then, you can write float_duration(dur) to get the duration as a fractional number of milliseconds (used in printing time deltas in a human readable fashion).

Any thoughts or objections?

pl

I’d love to move over to chrono. For Utility functions such as those you propose probably we should consider whether they should go into llvm. Does llvm currently use anything from chrono or have any chrono support functions yet?

I see one usage of of chrono in the Fuzzer, and that’s about it.

The llvm-dev thread seems to have fizzed out - I would assume they are
not interested in std::chrono. In any case, I've put the more
interesting patches I have in my stack up for review, so you have a
better idea of what I have in mind. and then we can decide what is the
fate of the utility functions there.

cheers,
pl

I suggest a totally different course of action: any utility (except specific to the debugger for some reason) should be submitted into LLVM (Support?).
I may be happy to have it available next months in LLVM, and I may not think about looking in every subproject.

The question is not if “they” (I rather have you guys say “we”) are not interested, but rather “is anyone opposing to having utilities wrapping / manipulating std::chrono in LLVM”.

Thanks,

I like that idea. I've added you to the reviews so you can see what
kind of utility functions I am talking about. BTW, LLVM seems to have
a TimeValue class as well (presumably because not all compilers used
to support std::chrono) - one possibility would be to start using that
instead, although I would prefer std::chrono.

The llvm-dev thread seems to have fizzed out - I would assume they are
not interested in std::chrono.

I suggest a totally different course of action: any utility (except specific to the debugger for some reason) should be submitted into LLVM (Support?).
I may be happy to have it available next months in LLVM, and I may not think about looking in every subproject.

The question is not if “they” (I rather have you guys say “we”) are not interested, but rather “is anyone opposing to having utilities wrapping / manipulating std::chrono in LLVM”.

I like that idea. I've added you to the reviews so you can see what
kind of utility functions I am talking about. BTW, LLVM seems to have
a TimeValue class as well (presumably because not all compilers used
to support std::chrono)

I believe TimeValue was created before std::chrono was standardized (first committed in 2004!)

- one possibility would be to start using that
instead, although I would prefer std::chrono.

Indeed, I believe we tend to move to the standard version of our utilities when the feature is complete in the compiler versions we support.

It is also possible that not all of TimeValue features are supported by std::chrono, I haven't compared in detail.

I am fine with TimeValue going away. I would love to just use STL std::chrono stuff if we can get away with it. If there is a bunch of code that gets re-written all of the time, then using the LLVM TimeValue class is fine if it is needed.

Greg

My current plan is to first clean up the usage of llvm::TimeValue and
replace it with std::chrono, then proceed on to LLDB. I have the llvm
stuff mostly done locally, I just need to find a bit of time to test
it out on windows. Will update when that is done.

pl

Hi all,

I have removed llvm and lldb TimeValues, and ported the remaining
usages of raw timeout values I found to std::chrono (SB API excluded).
If you find any that are left, let me know, and I can get to them as
well.

pl

(Or if you see any other code that looks like it's work-in-progress,
and it's timeout related. I don't want to leave stuff half-finished.)