Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use the fast SOCK_SEQPACKET where available
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Apr 2023 22:03:40 +0000 (00:03 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Apr 2023 22:05:45 +0000 (00:05 +0200)
Maybe SOCK_SEQPACKET is not faster than SOCK_STREAM per se, I don't
know, but streams force us to re-bufferize the data that we receive in
excess, leading to many useless data copies.

src/mc/api/RemoteApp.cpp
src/mc/remote/AppSide.cpp
src/mc/remote/CheckerSide.cpp

index 86e55f5..3d63a21 100644 (file)
@@ -49,11 +49,11 @@ RemoteApp::RemoteApp(const std::vector<char*>& args, bool need_memory_introspect
 #endif
   } else {
     master_socket_ = socket(AF_UNIX,
-                            SOCK_STREAM
-#ifdef SOCK_CLOEXEC
-                                | SOCK_CLOEXEC /* MacOSX does not have it */
+#ifdef __APPLE__
+                            SOCK_STREAM, /* Mac OSX does not have AF_UNIX + SOCK_SEQPACKET, even if that's faster*/
+#else
+                            SOCK_SEQPACKET,
 #endif
-                            ,
                             0);
     xbt_assert(master_socket_ != -1, "Cannot create the master socket: %s", strerror(errno));
 
index df1e06d..71d8414 100644 (file)
@@ -156,11 +156,11 @@ void AppSide::handle_fork(const s_mc_message_int_t* msg)
 
   if (pid == 0) { // Child
     int sock = socket(AF_UNIX,
-                      SOCK_STREAM
-#ifdef SOCK_CLOEXEC
-                          | SOCK_CLOEXEC /* MacOSX does not have it */
+#ifdef __APPLE__
+                      SOCK_STREAM, /* Mac OSX does not have AF_UNIX + SOCK_SEQPACKET, even if that's faster*/
+#else
+                      SOCK_SEQPACKET,
 #endif
-                      ,
                       0);
 
     struct sockaddr_un addr = {};
index b88d7e2..dd29fc9 100644 (file)
@@ -182,7 +182,14 @@ CheckerSide::CheckerSide(const std::vector<char*>& args, bool need_memory_info)
   // Create an AF_UNIX socketpair used for exchanging messages between the model-checker process (ancestor)
   // and the application process (child)
   int sockets[2];
-  xbt_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) != -1, "Could not create socketpair: %s", strerror(errno));
+  xbt_assert(socketpair(AF_UNIX,
+#ifdef __APPLE__
+                        SOCK_STREAM, /* Mac OSX does not have AF_UNIX + SOCK_SEQPACKET, even if that's faster*/
+#else
+                        SOCK_SEQPACKET,
+#endif
+                        0, sockets) != -1,
+             "Could not create socketpair: %s", strerror(errno));
 
   pid_ = fork();
   xbt_assert(pid_ >= 0, "Could not fork application process");