Skip to content

Gg/perf improvement datetime - #21

Open
gerhardgruber wants to merge 6 commits into
masterfrom
gg/perf_improvement_datetime
Open

Gg/perf improvement datetime#21
gerhardgruber wants to merge 6 commits into
masterfrom
gg/perf_improvement_datetime

Conversation

@gerhardgruber

Copy link
Copy Markdown
Contributor

No description provided.

Gerhard Gruber 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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() with localtime_r/strftime formatting 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 thread src/dm_logger.vala Outdated
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 thread src/dm_logger.vala
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 )
{

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants