-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Split OffsetDateTime
back into PrimitiveDateTime
and an offset?
#369
Comments
Not currently, no. What's the use case here? |
Actually, what I want is to just get the internal UTC datetime, there already is a getter for the offset. I have some highly optimized routines that just need the UTC datetime, and the overhead of And it seems I'm not the only one that needs that, as seen here: https://github.com/sfackler/rust-postgres/blob/master/postgres-types/src/time_03.rs#L51-L55 Seems like such a waste of cycles when the UTC datetime is just sitting there, inside the struct, unable to be used directly. |
Right now it's stored in that manner. It's not guaranteed that that will always be the case; on the contrary there is a reasonable future where it's not. |
I don't see how that would affect a public API method, for example |
The representation that I've looked at would use I honestly don't see the performance concern here. It's basically nothing, which you've acknowledged. |
Death by a thousand cuts; performance-rot is real. The overhead of
|
Would you mind sharing the benchmarks? I suspect they're not measuring properly if you're getting a 20% overhead on whatever you're doing. You said it takes "tens of nanoseconds". That's only a few clock cycles. |
It's for a closed-source project, so I cannot share the code. It was for an ISO 8061 formatter (UTC only), which my implementation takes about 35ns on The entire reason this began is because I initially thought I couldn't stick to Furthermore, for the record, a clock cycle on my system is about 0.27 nanoseconds, and not every instruction uses a single clock cycle. Integer multiplications takes about about 3-5 cycles and modulus/division taking upwards of 50-100 cycles, though with instruction-level parallelism and such deep pipelines on modern CPUs it's hard to tell at times. |
It sounds more like you were benchmarking the formatting rather than obtaining the value. Comparing formatting between versions is futile given that it was rewritten from scratch. The conversions to and from I feel that this issue was opened largely due to the internal data structure, which as I've mentioned is not stable. Feel free to leave it open, but I'd really need more than just one instance of it being used (or a notable performance difference on this alone) to be convinced. |
It was my custom formatting routine. The only thing from |
That's still not a benchmark of just the overhead for this. |
I am dismissing the benchmarks as flawed, and I don't feel the desired use case and motivation aligns with the guarantees of the time crate (namely the internal representation of |
Is there a way to split
OffsetDateTime
back intoPrimitiveDateTime
and an offset?The text was updated successfully, but these errors were encountered: