Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clamp the iomatrix size to IOV_MAX to fix Solaris

  • Loading branch information...
commit f74c685fced8e95bddc9ca8381d7dcc359e0b870 1 parent cf77690
@stash authored
Showing with 37 additions and 9 deletions.
  1. +24 −8 Feersum.xs
  2. +13 −1 Makefile.PL
View
32 Feersum.xs
@@ -7,13 +7,10 @@
#include <ctype.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
+#include <sys/uio.h>
#include "ppport.h"
-#include "picohttpparser-git/picohttpparser.c"
-
-#include "rinq.c"
-
#ifdef __GNUC__
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
@@ -101,13 +98,21 @@
#define trace3(...)
#endif
-#include <sys/uio.h>
-#define IOMATRIX_SIZE 64
+#include "picohttpparser-git/picohttpparser.c"
+#include "rinq.c"
+
+// Check FEERSUM_IOMATRIX_SIZE against what's actually usable on this
+// platform. See $iomatrix_size in Makefile.PL for the default.
+#if FEERSUM_IOMATRIX_SIZE > IOV_MAX
+# undef FEERSUM_IOMATRIX_SIZE
+# define FEERSUM_IOMATRIX_SIZE IOV_MAX
+#endif
+
struct iomatrix {
unsigned offset;
unsigned count;
- struct iovec iov[IOMATRIX_SIZE];
- SV *sv[IOMATRIX_SIZE];
+ struct iovec iov[FEERSUM_IOMATRIX_SIZE];
+ SV *sv[FEERSUM_IOMATRIX_SIZE];
};
struct feer_req {
@@ -2613,4 +2618,15 @@ BOOT:
Zero(&psgix_io_vtbl, 1, MGVTBL);
psgix_io_vtbl.svt_get = psgix_io_svt_get;
+
+ trace3("Feersum booted, iomatrix %lu "
+ "(IOV_MAX=%u, FEERSUM_IOMATRIX_SIZE=%u), "
+ "feer_req %lu, "
+ "feer_conn %lu\n",
+ (long unsigned int)sizeof(struct iomatrix),
+ (unsigned int)IOV_MAX,
+ (unsigned int)FEERSUM_IOMATRIX_SIZE,
+ (long unsigned int)sizeof(struct feer_req),
+ (long unsigned int)sizeof(struct feer_conn)
+ );
}
View
14 Makefile.PL
@@ -58,6 +58,17 @@ if ($convert_deps) {
use Config;
my $steal = ($] >= 5.012 && !defined($Config{useithreads}));
+# Control the size of the main write-buffer structure in feersum. Making this
+# value lower will use slightly less memory per connection at the cost of
+# speed and vice-versa. It's most noticeable when you're app is buffering a
+# lot of sparce writes. The default of 64 generally keeps usage under 4k per
+# connection on full 64-bit when you take into account the other connection
+# and request structures.
+# NOTE: If your OS defines IOV_MAX or UIO_MAXIOV then this value will be
+# forced to be at most that size with a #define. Solaris defines IOV_MAX to
+# be 16. Linux and OSX generally have IOV_MAX as 1024.
+my $iomatrix_size = 64;
+
WriteMakefile(ev_args(
NAME => 'Feersum',
VERSION_FROM => 'lib/Feersum.pm',
@@ -92,7 +103,8 @@ WriteMakefile(ev_args(
},
LIBS => [''],
EXE_FILES => ['bin/feersum'],
- DEFINE => ($steal ? '-DFEERSUM_STEAL' : ''),
+ DEFINE => "-DFEERSUM_IOMATRIX_SIZE=$iomatrix_size ".
+ ($steal ? '-DFEERSUM_STEAL' : ''),
INC => '-I.',
dynamic_lib => {OTHERLDFLAGS => $otherldflags},
));
Please sign in to comment.
Something went wrong with that request. Please try again.