[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 01/02: service: Reduce heap allocations while logging.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 01/02: service: Reduce heap allocations while logging. |
Date: |
Wed, 2 Nov 2022 09:25:28 -0400 (EDT) |
civodul pushed a commit to branch master
in repository shepherd.
commit 9bda2eb405460b48a34fdb54bd64b9770b482545
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Oct 20 12:46:23 2022 +0200
service: Reduce heap allocations while logging.
* modules/shepherd/service.scm (%service-file-logger): Use 'display'
and 'newline' instead of 'format' ('format' allocates a string port, etc.).
(service-builtin-logger): Use 'simple-format'.
---
modules/shepherd/service.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 08547de..9d0ade6 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -895,7 +895,10 @@ not exist."
(line
(let ((prefix (strftime default-logfile-date-format
(localtime (current-time)))))
- (format output "~a~a~%" prefix line)
+ ;; Avoid (ice-9 format) to reduce heap allocations.
+ (display prefix output)
+ (display line output)
+ (newline output)
(loop))))))))))
(define (service-file-logger file input)
@@ -925,8 +928,8 @@ FILE."
;; TODO: Print the PID of COMMAND. The actual PID is potentially
;; not known until after 'read-pid-file' has completed, so it would
;; need to be communicated.
- (format (log-output-port) "~a[~a] ~a~%"
- prefix command line))
+ (simple-format (log-output-port) "~a[~a] ~a~%"
+ prefix command line))
(loop))))))
(define (format-supplementary-groups supplementary-groups)