git: 9b1521f73360 - main - benchmarks/ipc-bench: Add new port

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Fri, 08 Mar 2024 22:52:43 UTC
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9b1521f73360a038e32fe7c5951079b019751f7f

commit 9b1521f73360a038e32fe7c5951079b019751f7f
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2024-03-08 22:49:25 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2024-03-08 22:51:08 +0000

    benchmarks/ipc-bench: Add new port
    
    Benchmarks for various inter-process-communication (IPC) methods.
    
    Sponsored by:   Netflix
---
 benchmarks/Makefile                                |  1 +
 benchmarks/ipc-bench/Makefile                      | 39 +++++++++++++++++++
 benchmarks/ipc-bench/distinfo                      |  3 ++
 .../ipc-bench/files/patch-source_CMakeLists.txt    | 10 +++++
 .../ipc-bench/files/patch-source_common_process.c  | 44 ++++++++++++++++++++++
 benchmarks/ipc-bench/pkg-descr                     |  3 ++
 benchmarks/ipc-bench/pkg-plist                     | 25 ++++++++++++
 7 files changed, 125 insertions(+)

diff --git a/benchmarks/Makefile b/benchmarks/Makefile
index 554da41fe93d..28f1fe955405 100644
--- a/benchmarks/Makefile
+++ b/benchmarks/Makefile
@@ -35,6 +35,7 @@
     SUBDIR += iorate
     SUBDIR += iozone
     SUBDIR += iozone21
+    SUBDIR += ipc-bench
     SUBDIR += iperf
     SUBDIR += iperf3
     SUBDIR += kdiskmark
diff --git a/benchmarks/ipc-bench/Makefile b/benchmarks/ipc-bench/Makefile
new file mode 100644
index 000000000000..80806e497baa
--- /dev/null
+++ b/benchmarks/ipc-bench/Makefile
@@ -0,0 +1,39 @@
+PORTNAME=	ipc-bench
+DISTVERSION=	1.0
+CATEGORIES=	benchmarks
+
+MAINTAINER=	olivier@FreeBSD.org
+COMMENT=	Benchmarks for various inter-process-communication (IPC)
+WWW=		https://github.com/intel/uintr-ipc-bench
+
+LICENSE=	MIT
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		cmake:noninja pkgconfig
+USE_GITHUB=	yes
+GH_ACCOUNT=	goldsborough
+GH_PROJECT=	ipc-bench
+GH_TAGNAME=	589146a
+
+BINARIES=	domain fifo mmap mq shm signal tcp
+
+OPTIONS_DEFINE=	ZMQ
+OPTIONS_SUB=	yes
+ZMQ_DESC=	Enable ZeroMQ benches via libzmq${ZMQ_VERSION}
+ZMQ_LIB_DEPENDS=	libzmq.so:net/libzmq${ZMQ_VERSION}
+ZMQ_VERSION?=	4
+
+.include <bsd.port.options.mk>
+.if ${PORT_OPTIONS:MZMQ}
+BINARIES+=	zeromq
+.endif
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKDIR}/.build/source/pipe/pipe ${STAGEDIR}${PREFIX}/bin
+.for f in ${BINARIES}
+	${INSTALL_PROGRAM} ${WRKDIR}/.build/source/${f}/${f} ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKDIR}/.build/source/${f}/${f}-client ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKDIR}/.build/source/${f}/${f}-server ${STAGEDIR}${PREFIX}/bin
+.endfor
+
+.include <bsd.port.mk>
diff --git a/benchmarks/ipc-bench/distinfo b/benchmarks/ipc-bench/distinfo
new file mode 100644
index 000000000000..11e7ce8c16a2
--- /dev/null
+++ b/benchmarks/ipc-bench/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1709854860
+SHA256 (goldsborough-ipc-bench-1.0-589146a_GH0.tar.gz) = 734b25b219c35b4818693501b399f66b1739c31b395ced7f7050ffbc78576762
+SIZE (goldsborough-ipc-bench-1.0-589146a_GH0.tar.gz) = 347091
diff --git a/benchmarks/ipc-bench/files/patch-source_CMakeLists.txt b/benchmarks/ipc-bench/files/patch-source_CMakeLists.txt
new file mode 100644
index 000000000000..e6f2eea6ac07
--- /dev/null
+++ b/benchmarks/ipc-bench/files/patch-source_CMakeLists.txt
@@ -0,0 +1,10 @@
+--- source/CMakeLists.txt.orig	2024-03-08 21:54:22 UTC
++++ source/CMakeLists.txt
+@@ -39,7 +39,6 @@ add_subdirectory(signal)
+ add_subdirectory(domain)
+ add_subdirectory(mq)
+ add_subdirectory(signal)
+-add_subdirectory(shm-sync)
+ 
+ if (NOT APPLE)
+ 	add_subdirectory(eventfd)
diff --git a/benchmarks/ipc-bench/files/patch-source_common_process.c b/benchmarks/ipc-bench/files/patch-source_common_process.c
new file mode 100644
index 000000000000..661d21c74e48
--- /dev/null
+++ b/benchmarks/ipc-bench/files/patch-source_common_process.c
@@ -0,0 +1,44 @@
+--- source/common/process.c.orig	2022-04-28 15:09:32 UTC
++++ source/common/process.c
+@@ -55,7 +55,7 @@ pid_t start_process(char *argv[]) {
+ 		// second is an array of arguments, where the
+ 		// command path has to be included as well
+ 		// (that's why argv[0] first)
+-		if (execv(argv[0], argv) == -1) {
++		if (execvp(argv[0], argv) == -1) {
+ 			throw("Error opening child process");
+ 		}
+ 	}
+@@ -83,24 +83,18 @@ void start_children(char *prefix, int argc, char *argv
+ 	char server_name[100];
+ 	char client_name[100];
+ 
+-	char *build_path = find_build_path();
+-
+ 	// clang-format off
+ 	sprintf(
+ 		server_name,
+-		"%s/%s/%s-%s",
+-		build_path,
++		"%s-%s",
+ 		prefix,
+-		prefix,
+ 		"server"
+ 	);
+ 
+ 	sprintf(
+ 		client_name,
+-		"%s/%s/%s-%s",
+-		build_path,
++		"%s-%s",
+ 		prefix,
+-		prefix,
+ 		"client"
+ 	);
+ 	// clang-format on
+@@ -111,5 +105,4 @@ void start_children(char *prefix, int argc, char *argv
+ 	waitpid(c1_id, NULL, WUNTRACED);
+ 	waitpid(c2_id, NULL, WUNTRACED);
+ 
+-	free(build_path);
+ }
diff --git a/benchmarks/ipc-bench/pkg-descr b/benchmarks/ipc-bench/pkg-descr
new file mode 100644
index 000000000000..ddb24c0fb193
--- /dev/null
+++ b/benchmarks/ipc-bench/pkg-descr
@@ -0,0 +1,3 @@
+Benchmarks for various inter-process-communication (IPC) methods:
+ZeroMQ, TCP socket (tcp), domain socket (domain), named pipes (fifo), signal,
+memory mapped file (mmap), message queues (mq), pipe, shared memory (shm).
diff --git a/benchmarks/ipc-bench/pkg-plist b/benchmarks/ipc-bench/pkg-plist
new file mode 100644
index 000000000000..dbe9d4bc703e
--- /dev/null
+++ b/benchmarks/ipc-bench/pkg-plist
@@ -0,0 +1,25 @@
+bin/domain
+bin/domain-client
+bin/domain-server
+bin/fifo
+bin/fifo-client
+bin/fifo-server
+bin/mmap
+bin/mmap-client
+bin/mmap-server
+bin/mq
+bin/mq-client
+bin/mq-server
+bin/pipe
+bin/shm
+bin/shm-client
+bin/shm-server
+bin/signal
+bin/signal-client
+bin/signal-server
+bin/tcp
+bin/tcp-client
+bin/tcp-server
+%%ZMQ%%bin/zeromq
+%%ZMQ%%bin/zeromq-client
+%%ZMQ%%bin/zeromq-server