Gg/perf improvement datetime - #21
Open
gerhardgruber wants to merge 6 commits into
Open
Conversation
added 4 commits
May 27, 2026 10:19
Adds -D_POSIX_THREAD_SAFE_FUNCTIONS=1 so that MinGW's <time.h> declares localtime_r/gmtime_r. Required for the upcoming fast timestamp formatter. No-op on glibc.
Adds a libc-backed timestamp formatter with a per-second cache. Replaces the GTimeZone+GDateTime path that callgrind showed consuming ~30 % of docTYPE total runtime. Helper not yet wired into LogEntry.print_out (next commit).
Replaces the per-call DMDateTime/GTimeZone construction with the new format_log_timestamp helper. Output format is byte-identical: [YYYY-MM-DD HH:MM:SS.uuuuuu]. Expected ~30 % wall-clock speedup for log-heavy docTYPE runs (see callgrind.out.61062 analysis).
There was a problem hiding this comment.
Pull request overview
This PR optimizes log timestamp formatting in dm_logger by replacing per-entry DMDateTime construction with a libc-based formatter and a per-second cache.
Changes:
- Adds
format_log_timestamp()withlocaltime_r/strftimeformatting and cached second-level prefixes. - Updates
LogEntry.print_out()to use the new formatter. - Adds timestamp formatter coverage and a MinGW compatibility define for
localtime_r.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/dm_logger.vala |
Adds the timestamp formatting cache/helper and switches console log output to use it. |
tests/test_dm_logger.vala |
Adds a unit test for timestamp prefix formatting and same-second cache behavior. |
src/CMakeLists.txt |
Adds _POSIX_THREAD_SAFE_FUNCTIONS for MinGW localtime_r availability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+85
to
+90
| if ( seconds != _dm_logger_ts_cached_seconds ) | ||
| { | ||
| time_t t = (time_t)seconds; | ||
| Posix.tm tm_local = Posix.tm(); | ||
| if ( _dm_logger_localtime_r( ref t, out tm_local ) != null ) | ||
| { |
Comment on lines
+77
to
+82
| * On success it contains a NUL-terminated string. | ||
| * | ||
| * Single-threaded use only; see comment block above. | ||
| */ | ||
| public void format_log_timestamp( int64 tstamp_usec, char[] buf ) | ||
| { |
added 2 commits
May 27, 2026 12:07
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.
No description provided.