Bug 240517 - [PATCH] devel/glib20: syscall flood on every time*() function call
Summary: [PATCH] devel/glib20: syscall flood on every time*() function call
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-gnome mailing list
URL: https://gitlab.gnome.org/GNOME/glib/m...
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-11 22:54 UTC by rozhuk.im
Modified: 2020-04-16 07:57 UTC (History)
3 users (show)

See Also:
rozhuk.im: maintainer-feedback-


Attachments
tzcache patch (993 bytes, patch)
2019-09-11 22:54 UTC, rozhuk.im
no flags Details | Diff
fix possible mem leak (1.01 KB, patch)
2019-09-12 02:53 UTC, rozhuk.im
no flags Details | Diff
optimized version (1.41 KB, patch)
2019-09-12 23:45 UTC, rozhuk.im
no flags Details | Diff
patch (1.92 KB, patch)
2019-11-02 02:45 UTC, rozhuk.im
rozhuk.im: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rozhuk.im 2019-09-11 22:54:48 UTC
Created attachment 207400 [details]
tzcache patch

truss show that GTK app do many times:
...
27100: openat(AT_FDCWD,"/etc/localtime",O_RDONLY,00) = 114 (0x72)
27100: fstat(114,{ mode=-r--r--r-- ,inode=1845941,size=1518,blksize=32768 }) = 0 (0x0)
27100: mmap(0x0,1518,PROT_READ,MAP_PRIVATE,114,0x0) = 34458873856 (0x805e8b000)
27100: close(114)				 = 0 (0x0)
27100: munmap(0x805e8b000,1518)			 = 0 (0x0)
...

I found article: https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-save-thousands-of-system-calls/
and try to set:
env TZ=":/etc/localtime" truss -fD geany
or
env TZ="Europe/Moscow" truss -fD geany
without success.

I discovered that glib time zone cache is does not work properly:
==========================================================
GDateTime *
g_date_time_new_from_unix_local (gint64 t)
{
  GDateTime *datetime;
  GTimeZone *local;

  local = g_time_zone_new_local ();
  datetime = g_date_time_new_from_unix (local, t);
  g_time_zone_unref (local);

  return datetime;
}

GTimeZone *
g_time_zone_new_local (void)
{
  return g_time_zone_new (getenv ("TZ"));
}
==========================================================

g_time_zone_new() load and add time zone to cache if arg is not NULL.
g_time_zone_unref() - remove time zone from cache.
As you can see time zone in most cases removed from cache after short time.

Patch add_ref() for time zone "getenv ("TZ")" and "UTC", all other calls g_time_zone_new() leave without changes.
After apply patch and set TZ=":/etc/localtime" / TZ="Europe/Moscow" no more syscall flood happen.
Comment 1 rozhuk.im 2019-09-12 02:53:54 UTC
Created attachment 207403 [details]
fix possible mem leak
Comment 2 rozhuk.im 2019-09-12 23:45:31 UTC
Created attachment 207446 [details]
optimized version
Comment 4 rozhuk.im 2020-02-19 16:29:46 UTC
ping
Comment 5 rozhuk.im 2020-04-16 07:57:28 UTC
maintainer timeout