Duansg opened a new pull request, #948: URL: https://github.com/apache/fesod/pull/948
## Purpose of the pull request DateUtils and NumberUtils rebuilt a formatter on every cell. This PR caches them per thread, keyed by locale + pattern, so a formatter is built once and reused. The java.util.Date path in the very same class was already cached; the java.time and DecimalFormat paths just never got the same treatment. This PR closes that gap. ## What's changed? Both caches are ThreadLocal (not a shared static map) so they are bounded by thread lifetime and released by the existing cleanup, consistent with the sibling DATE_FORMAT_THREAD_LOCAL. 1. DateUtils — new DATE_TIME_FORMATTER_THREAD_LOCAL cache; all 8 sites resolve through getCacheDateTimeFormat(pattern, locale). Cleared in the existing removeThreadLocalCache(). 2. NumberUtils — new DECIMAL_FORMAT_THREAD_LOCAL cache via getCacheDecimalFormat(pattern, roundingMode), plus a new removeThreadLocalCache() wired into the read/write finish paths (WriteContextImpl, ExcelAnalyserImpl). ## Benchmark ``` mardown Per cell (JMH 1.37, -prof gc, 2 forks; allocation deterministic ±0.001 B/op) ┌──────────────┬─────────────┬────────────┬─────────────┬──────────────┬─────────────┬─────────┐ │ Benchmark │ Time before │ Time after │ Time Δ │ Alloc before │ Alloc after │ Alloc Δ │ ├──────────────┼─────────────┼────────────┼─────────────┼──────────────┼─────────────┼─────────┤ │ dateFormat │ 422.8 ns │ 205.4 ns │ −51% │ 776 B │ 396 B │ −49% │ ├──────────────┼─────────────┼────────────┼─────────────┼──────────────┼─────────────┼─────────┤ │ dateParse │ 680.0 ns │ 631.1 ns │ −7% │ 1272 B │ 880 B │ −31% │ ├──────────────┼─────────────┼────────────┼─────────────┼──────────────┼─────────────┼─────────┤ │ numberFormat │ 905.2 ns │ 749.4 ns │ −17% │ 1656 B │ 480 B │ −71% │ ├──────────────┼─────────────┼────────────┼─────────────┼──────────────┼─────────────┼─────────┤ │ numberParse │ 492.8 ns │ 277.0 ns │ −44% │ 1568 B │ 376 B │ −76% │ └──────────────┴─────────────┴────────────┴─────────────┴──────────────┴─────────────┴─────────┘ End-to-end (500000-row CSV, median of 3) ┌───────┬───────────────────┬──────────┬──────────┬──────┐ │ Phase │ Metric │ Before │ After │ Δ │ ├───────┼───────────────────┼──────────┼──────────┼──────┤ │ Write │ Thread allocation │ 2,386 MB │ 1,593 MB │ −33% │ ├───────┼───────────────────┼──────────┼──────────┼──────┤ │ Read │ Thread allocation │ 1,960 MB │ 1,279 MB │ −35% │ └───────┴───────────────────┴──────────┴──────────┴──────┘ ``` ## Checklist - [x] I have read the [Contributor Guide](https://fesod.apache.org/community/contribution/). - [ ] I have written the necessary doc or comment. - [x] I have added the necessary unit tests and all cases have passed. -- 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]
