* [PATCH] libuuid: improve cache handling
@ 2022-04-22 8:07 Michael Trapp
2022-04-29 11:11 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Michael Trapp @ 2022-04-22 8:07 UTC (permalink / raw)
To: util-linux; +Cc: kzak, d032747
From: d032747 <michael.trapp@sap.com>
Short running applications with a few UUID request don't need
a large cache. Therefore increment the cache size over runtime.
---
libuuid/src/gen_uuid.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index 76d5371ea..805b40d90 100644
--- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c
@@ -443,6 +443,7 @@ int __uuid_generate_time(uuid_t out, int *num)
static int uuid_generate_time_generic(uuid_t out) {
#ifdef HAVE_TLS
THREAD_LOCAL int num = 0;
+ THREAD_LOCAL int cache_size = 1;
THREAD_LOCAL struct uuid uu;
THREAD_LOCAL time_t last_time = 0;
time_t now;
@@ -453,7 +454,15 @@ static int uuid_generate_time_generic(uuid_t out) {
num = 0;
}
if (num <= 0) {
- num = 1000000;
+ /*
+ * num + OP_BULK provides a local cache in each application.
+ * Start with a small cache size to cover short running applications
+ * and increment the cache size over the runntime.
+ */
+ if (cache_size < 1000000)
+ cache_size *= 10;
+ num = cache_size;
+
if (get_uuid_via_daemon(UUIDD_OP_BULK_TIME_UUID,
out, &num) == 0) {
last_time = time(NULL);
--
2.32.0 (Apple Git-132)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libuuid: improve cache handling
2022-04-22 8:07 [PATCH] libuuid: improve cache handling Michael Trapp
@ 2022-04-29 11:11 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2022-04-29 11:11 UTC (permalink / raw)
To: Michael Trapp; +Cc: util-linux
On Fri, Apr 22, 2022 at 10:07:46AM +0200, Michael Trapp wrote:
> libuuid/src/gen_uuid.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
This is simple and elegant optimization :) Applied, thanks.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-29 11:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 8:07 [PATCH] libuuid: improve cache handling Michael Trapp
2022-04-29 11:11 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).