Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Only initialize BusinessCalendar caches when data is accessed a…
…nd improve caching performance (#5378) Makes BusinessCalendar caches populate only when accessed to avoid slow worker initialization. Additionally, caching in various operations has been improved to yield better performance. Resolves #5377 Benchmark: ```groovy n = 1_000_000 npart = 10 t = emptyTable(n) .updateView("Part = ii%npart", "Today = todayLocalDate()") tp = t.partitionBy("Part").proxy() c = calendar() timeit = { name, table, query -> c.clearCache() start = System.currentTimeMillis() rst = table.update(query) end = System.currentTimeMillis() println("TIME: ${name}: ${end-start} ms") } istart = parseInstant("2022-01-01T01:01:01 ET") iend = parseInstant("2024-06-01T01:01:01 ET") timeit("calendarDayOld-NORMAL", t, "CD = c.calendarDay(Today)") timeit("calendarDayOld-PART", tp, "CD = c.calendarDay(Today)") timeit("diffBusinessYearsOld-NORMAL", t, "CD = c.diffBusinessYears(istart, iend)") timeit("diffBusinessYearsOld-PART", tp, "CD = c.diffBusinessYears(istart, iend)") println("DONE") ``` Performance: ``` // 1M - NEW //TIME: calendarDayOld-NORMAL: 266 ms //TIME: calendarDayOld-PART: 299 ms //TIME: diffBusinessYearsOld-NORMAL: 5937 ms //TIME: diffBusinessYearsOld-PART: 6664 ms <<<< // 1M - v0.33.3 //TIME: calendarDayOld-NORMAL: 366 ms //TIME: calendarDayOld-PART: 327 ms //TIME: diffBusinessYearsOld-NORMAL: 20384 ms //TIME: diffBusinessYearsOld-PART: 5549 ms <<<< // 10M - NEW //TIME: calendarDayOld-NORMAL: 449 ms //TIME: calendarDayOld-PART: 548 ms //TIME: diffBusinessYearsOld-NORMAL: 58883 ms //TIME: diffBusinessYearsOld-PART: 67362 ms <<<< // 10M - v0.33.3 //TIME: calendarDayOld-NORMAL: 522 ms //TIME: calendarDayOld-PART: 704 ms //TIME: diffBusinessYearsOld-NORMAL: 195916 ms //TIME: diffBusinessYearsOld-PART: 49411 ms <<<< ``` Note1: `v0.33.0` times do not include initialization times, but the new values do. Note2: There appears to be contention or initialization overhead in the partitioned table case yielding slightly worse performance.
- Loading branch information