Commit graph

3 commits

Author SHA1 Message Date
Andrew Gallant
f92871a2c7
tests: improve test failure message
Some checks failed
ci / test-core (macos, macos-latest, nightly) (push) Has been cancelled
ci / test-various-feature-combos (macos, macos-latest, nightly) (push) Has been cancelled
ci / test-various-feature-combos (nightly, ubuntu-latest, nightly) (push) Has been cancelled
ci / test-release (push) Has been cancelled
ci / test-doc (push) Has been cancelled
ci / test-bench (push) Has been cancelled
ci / test-miri (push) Has been cancelled
ci / win-msvc (push) Has been cancelled
ci / win-gnu (push) Has been cancelled
ci / msrv (push) Has been cancelled
ci / integrations (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / time-zone-init (macos-latest) (push) Has been cancelled
ci / time-zone-init (ubuntu-24.04-arm) (push) Has been cancelled
ci / time-zone-init (ubuntu-latest) (push) Has been cancelled
ci / time-zone-init (windows-latest) (push) Has been cancelled
ci / cross (aarch64-linux-android) (push) Has been cancelled
ci / cross (aarch64-unknown-linux-gnu) (push) Has been cancelled
ci / cross (i686-unknown-linux-gnu) (push) Has been cancelled
ci / cross (s390x-unknown-linux-gnu) (push) Has been cancelled
ci / cross (x86_64-linux-android) (push) Has been cancelled
ci / cross (powerpc-unknown-linux-gnu) (push) Has been cancelled
ci / cross (powerpc64-unknown-linux-gnu) (push) Has been cancelled
ci / riscv32imc-unknown-none-elf (push) Has been cancelled
ci / wasm32-wasip1 (push) Has been cancelled
ci / wasm32-unknown-emscripten (push) Has been cancelled
ci / wasm32-unknown-uknown (push) Has been cancelled
ci / docsrs (push) Has been cancelled
ci / rustfmt (push) Has been cancelled
ci / generated (push) Has been cancelled
This test is failing intermittently on macOS. Which means that the
initialization of the zoneinfo database is taking more than 500ms. I had
scrutinized the CI logs and timestamps, and it looks like it's just
random I/O delay when traversing the zoneinfo directory. Sigh.
2025-10-23 13:27:12 -04:00
Andrew Gallant
c5c232094c ci: improve tzdb init times and tests
While in #370 my tests indicated that the slowest tzdb init was still
under ~33ms, right after it merged to master, I saw a spike to 300ms.

300ms is... probably still tolerable, but just barely I think. So this
PR bumps up our threshold to 500ms. We also enable logging to hopefully
get a better sense of where time is being spent.

Finally, we just to improve things by skipping the `right` and `posix`
directories in typicaly `/usr/share/zoneinfo` installations. Jiff
doesn't use them and they tend to be confusing outputs of
`TimeZoneDatabase::available()`. If users actually need those
directories, they can do `TZDIR=/usr/share/zoneinfo/posix`.

Ref #366
2025-05-09 17:33:22 -04:00
Andrew Gallant
0f9fdf8ec8 tz: improve performance of initial Zoned::now()
Specifically, this improves performance in the case of
`/usr/share/zoneinfo` being on a slow file system. Namely, #366 reports
cases (in CI) where this initialization could take multiple seconds.

In this commit, we remove the file reads---but keep the directory
traversal---for validating files in `/usr/share/zoneinfo` as TZif data.
Namely, it is common that while _most_ files in a zoneinfo directory are
valid TZif, not all are.

The reason for keeping the initial directory traversal is that it
simplifies the implementation for case insensitive time zone identifier
lookups. Without the IDs in memory, doing a case insensitive lookup on
the file system becomes much harder. Especially since IANA time zone
identifiers use mixed case and I believe there is no algorithmic way to
normalize them. If we do need to get rid of the initial directory scan,
we'll likely need to reframe the `TimeZoneDatabase::available()` API as
potentially returning strings that aren't valid identifiers, or do some
kind of data dependent normalization techniques. (Which may need to be
updated as new releases of tzdb come out.)

In any case, removing the 4-byte file reads seems to dramatically cut
down initialization time. From multiple seconds to 33ms in the slowest
case. In particular, the directory traversal is now done in a way where
the number of syscalls on Unix should be about equivalent to the number
of directories in `/usr/share/zoneinfo` and *not* the number of files.

We also add a test for a slow initial `Zoned::now()` call.

Fixes #366
2025-05-09 16:42:46 -04:00