Repository navigation
Conversation
vpaturet
force-pushed
the
perf/fast-local-date-time-parser
branch
from
October 7, 2026 08:07
4f64a46 to
ab0d343
Compare
Parsing xs:time, xs:date and xs:dateTime values with a DateTimeFormatter costs 500-900 ns and 1-1.7 KB of garbage per value, spent in the formatter machinery to parse strings that in practice have one fixed shape. NeTEx documents contain millions of such values (10.4M xs:time values in the Norwegian aggregated dataset). Add FastLocalDateTimeParser, a position-based parser for yyyy-MM-dd, HH:mm:ss[.fffffffff] and yyyy-MM-ddTHH:mm:ss[.fffffffff], each with an optional Z or ±HH:MM zone designator that is validated and ignored, as the formatters do. The three adapters try it first and fall back to their existing DateTimeFormatter for any other form or out-of-range field, so results, lenient resolution (e.g. 2023-02-30, 24:00:00) and exceptions are unchanged. LocalTimeISO8601XmlAdapter keeps its ConcurrentHashMap deduplication of whole-second times. Same approach as FastZonedDateTimeParser in siri-java-model.
vpaturet
force-pushed
the
perf/fast-local-date-time-parser
branch
from
October 7, 2026 11:40
c0d7c77 to
7be6066
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Parsing
xs:time,xs:dateandxs:dateTimevalues with aDateTimeFormatteris CPU and memory intensive.This PR adds
FastLocalDateTimeParser, which reads fields at fixed positions. It follows the same approach asFastZonedDateTimeParserin siri-java-model. It supports:xs:dateyyyy-MM-dd[Z|±HH:MM]xs:timeHH:mm:ss[.fffffffff][Z|±HH:MM]xs:dateTimeyyyy-MM-ddTHH:mm:ss[.fffffffff][Z|±HH:MM]The zone designator is validated, then ignored, as the current formatters already do.
The three adapters try the fast parser first. For any other form, any out-of-range field or a
nullinput, they fall back to their existingDateTimeFormatter. That keeps results, lenient resolution (2023-02-30→2023-02-28,24:00:00,10:20:30.) and exceptions unchanged, including the formatter'sNullPointerExceptionfornull.LocalTimeISO8601XmlAdapterkeeps itsConcurrentHashMapdeduplication of whole-second times, so retained heap is unchanged.Results
Measured by unmarshalling the full Norwegian NeTEx export, compared with master:
Tests
FastLocalDateTimeParserTestcovers the supported forms, the inputs the fast parser declines and leaves to the formatter (day overflow,24:00:00, a fraction separator without digits, malformed or out-of-range offsets, extra year digits, ...), andnullhandling in the parser and the three adapters.