GWphua commented on code in PR #18477:
URL: https://github.com/apache/druid/pull/18477#discussion_r2328603280
##########
processing/src/main/java/org/apache/druid/java/util/common/Intervals.java:
##########
@@ -25,13 +25,17 @@
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.joda.time.chrono.ISOChronology;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.ISODateTimeFormat;
import javax.annotation.Nullable;
public final class Intervals
{
public static final Interval ETERNITY = utc(JodaUtils.MIN_INSTANT,
JodaUtils.MAX_INSTANT);
public static final ImmutableList<Interval> ONLY_ETERNITY =
ImmutableList.of(ETERNITY);
+ private static final DateTimeFormatter FAST_ISO_UTC_FORMATTER =
Review Comment:
Hi @kfaraz
Got quite a bit of time to kill, so I did a benchmark for the formatters...
Seems `DateTimes.ISO_DATE_TIME` is a bit slower than the current
optimization because `ISO_DATE_TIME` tries to create `DateTime` unnecessary
objects. The current implementation creates an `Interval` directly using `long`
via`Intervals#utc` and hence performs faster.
On the topic of using other data formats, seems like we can look for
`DateTimes.ISO_DATE_OPTIONAL_TIME` to improve the deserialization, but the
improvement is quite small.
```
Benchmark
(numValues) Mode Cnt Score Error Units
JodaIntervalDeserializationBenchmark.deserializeLegacy
20000 avgt 50 20.858 ± 0.035 ms/op
JodaIntervalDeserializationBenchmark.deserializeOptimized
20000 avgt 50 11.940 ± 0.009 ms/op
JodaIntervalDeserializationBenchmark.deserializeDateTime
20000 avgt 50 12.524 ± 0.025 ms/op
JodaIntervalDeserializationBenchmark.deserializeDateTimeOffset
20000 avgt 50 23.505 ± 0.050 ms/op
JodaIntervalDeserializationBenchmark.deserializeOptionalDateTime
20000 avgt 50 20.663 ± 0.111 ms/op
JodaIntervalDeserializationBenchmark.deserializeLegacyFallback
20000 avgt 50 19.035 ± 0.032 ms/op
JodaIntervalDeserializationBenchmark.deserializeOptimizedFallback
20000 avgt 50 33.782 ± 0.105 ms/op
JodaIntervalDeserializationBenchmark.deserializeDateTimeFallback
20000 avgt 50 36.642 ± 0.065 ms/op
JodaIntervalDeserializationBenchmark.deserializeDateTimeOffsetFallback
20000 avgt 50 22.067 ± 0.046 ms/op
JodaIntervalDeserializationBenchmark.deserializeOptionalDateTimeFallback
20000 avgt 50 18.861 ± 0.012 ms/op
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]