Module Name:    src
Committed By:   christos
Date:           Fri May  3 15:50:42 UTC 2024

Modified Files:
        src/external/cddl/osnet/dist/tools/ctf/cvt: ctfmerge.c

Log Message:
add an environment variable to override the number ot threads.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 \
    src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c
diff -u src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c:1.18 src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c:1.19
--- src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c:1.18	Tue May 23 14:54:58 2023
+++ src/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c	Fri May  3 11:50:42 2024
@@ -712,6 +712,7 @@ static void
 wq_init(workqueue_t *wq, int nfiles)
 {
 	int throttle, nslots, i;
+	const char *e;
 
 	if (getenv("CTFMERGE_MAX_SLOTS"))
 		nslots = atoi(getenv("CTFMERGE_MAX_SLOTS"));
@@ -728,17 +729,21 @@ wq_init(workqueue_t *wq, int nfiles)
 
 	wq->wq_wip = xcalloc(sizeof (wip_t) * nslots);
 	wq->wq_nwipslots = nslots;
+	e = getenv("CTFMERGE_NUM_THREADS");
+	if (e) {
+		wq->wq_nthreads = atoi(e);
+	} else {
 #ifdef _SC_NPROCESSORS_ONLN
-	wq->wq_nthreads = MIN(sysconf(_SC_NPROCESSORS_ONLN) * 3 / 2, nslots);
+		wq->wq_nthreads = MIN(sysconf(_SC_NPROCESSORS_ONLN) * 3 / 2,
+		    nslots);
 #else
-	wq->wq_nthreads = 2;
+		wq->wq_nthreads = 2;
 #endif
+	}
 	wq->wq_thread = xmalloc(sizeof (pthread_t) * wq->wq_nthreads);
 
-	if (getenv("CTFMERGE_INPUT_THROTTLE"))
-		throttle = atoi(getenv("CTFMERGE_INPUT_THROTTLE"));
-	else
-		throttle = MERGE_INPUT_THROTTLE_LEN;
+	e = getenv("CTFMERGE_INPUT_THROTTLE");
+	throttle = e ? atoi(e) : MERGE_INPUT_THROTTLE_LEN;
 	wq->wq_ithrottle = throttle * wq->wq_nthreads;
 
 	debug(1, "Using %d slots, %d threads\n", wq->wq_nwipslots,

Reply via email to