nutcracker 0.2.4.12 → 0.3.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +8 -8
  2. data/Rakefile +1 -1
  3. data/ext/nutcracker/ChangeLog +10 -0
  4. data/ext/nutcracker/Makefile.am +2 -0
  5. data/ext/nutcracker/Makefile.in +101 -14
  6. data/ext/nutcracker/README.md +18 -1
  7. data/ext/nutcracker/config.h.in +18 -0
  8. data/ext/nutcracker/configure +196 -25
  9. data/ext/nutcracker/configure.ac +64 -6
  10. data/ext/nutcracker/extconf.rb +1 -1
  11. data/ext/nutcracker/man/nutcracker.8 +76 -0
  12. data/ext/nutcracker/notes/debug.txt +116 -16
  13. data/ext/nutcracker/notes/kqueue.pdf +0 -0
  14. data/ext/nutcracker/notes/recommendation.md +20 -0
  15. data/ext/nutcracker/notes/redis.md +2 -2
  16. data/ext/nutcracker/scripts/nutcracker.spec +1 -1
  17. data/ext/nutcracker/scripts/redis-check.sh +3 -1
  18. data/ext/nutcracker/src/Makefile.am +15 -6
  19. data/ext/nutcracker/src/Makefile.in +39 -36
  20. data/ext/nutcracker/src/event/Makefile.am +16 -0
  21. data/ext/nutcracker/src/event/Makefile.in +492 -0
  22. data/ext/nutcracker/src/event/nc_epoll.c +344 -0
  23. data/ext/nutcracker/src/event/nc_event.h +88 -0
  24. data/ext/nutcracker/src/event/nc_evport.c +420 -0
  25. data/ext/nutcracker/src/event/nc_kqueue.c +412 -0
  26. data/ext/nutcracker/src/hashkit/nc_crc32.c +19 -1
  27. data/ext/nutcracker/src/hashkit/nc_hashkit.h +3 -1
  28. data/ext/nutcracker/src/hashkit/nc_md5.c +257 -315
  29. data/ext/nutcracker/src/nc.c +12 -1
  30. data/ext/nutcracker/src/nc_connection.c +18 -1
  31. data/ext/nutcracker/src/nc_connection.h +1 -0
  32. data/ext/nutcracker/src/nc_core.c +22 -30
  33. data/ext/nutcracker/src/nc_core.h +22 -7
  34. data/ext/nutcracker/src/nc_proxy.c +8 -9
  35. data/ext/nutcracker/src/nc_queue.h +2 -0
  36. data/ext/nutcracker/src/nc_request.c +3 -4
  37. data/ext/nutcracker/src/nc_response.c +25 -8
  38. data/ext/nutcracker/src/nc_server.c +8 -6
  39. data/ext/nutcracker/src/nc_stats.c +46 -43
  40. data/ext/nutcracker/src/nc_stats.h +37 -30
  41. data/ext/nutcracker/src/nc_util.c +6 -1
  42. data/ext/nutcracker/src/proto/nc_redis.c +19 -5
  43. data/lib/nutcracker/version.rb +1 -1
  44. data/lib/nutcracker.rb +1 -1
  45. metadata +10 -4
  46. data/ext/nutcracker/src/nc_event.c +0 -214
  47. data/ext/nutcracker/src/nc_event.h +0 -39
@@ -1,8 +1,8 @@
1
1
  #! /bin/sh
2
2
  # Guess values for system-dependent variables and create Makefiles.
3
- # Generated by GNU Autoconf 2.68 for nutcracker 0.2.4.
3
+ # Generated by GNU Autoconf 2.68 for nutcracker 0.3.0.
4
4
  #
5
- # Report bugs to <manj@twitter.com>.
5
+ # Report bugs to <manj@cs.stanford.edu>.
6
6
  #
7
7
  #
8
8
  # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -246,7 +246,7 @@ fi
246
246
  $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
247
247
  $as_echo "$0: be upgraded to zsh 4.3.4 or later."
248
248
  else
249
- $as_echo "$0: Please tell bug-autoconf@gnu.org and manj@twitter.com about your
249
+ $as_echo "$0: Please tell bug-autoconf@gnu.org and manj@cs.stanford.edu about your
250
250
  $0: system, including any error possibly output before this
251
251
  $0: message. Then install a modern shell, or manually run
252
252
  $0: the script under such a shell if you do have one."
@@ -569,9 +569,9 @@ MAKEFLAGS=
569
569
  # Identity of this package.
570
570
  PACKAGE_NAME='nutcracker'
571
571
  PACKAGE_TARNAME='nutcracker'
572
- PACKAGE_VERSION='0.2.4'
573
- PACKAGE_STRING='nutcracker 0.2.4'
574
- PACKAGE_BUGREPORT='manj@twitter.com'
572
+ PACKAGE_VERSION='0.3.0'
573
+ PACKAGE_STRING='nutcracker 0.3.0'
574
+ PACKAGE_BUGREPORT='manj@cs.stanford.edu'
575
575
  PACKAGE_URL=''
576
576
 
577
577
  ac_unique_file="src/nc.c"
@@ -616,6 +616,12 @@ ac_subst_vars='am__EXEEXT_FALSE
616
616
  am__EXEEXT_TRUE
617
617
  LTLIBOBJS
618
618
  subdirs
619
+ OS_SOLARIS_FALSE
620
+ OS_SOLARIS_TRUE
621
+ OS_BSD_FALSE
622
+ OS_BSD_TRUE
623
+ OS_LINUX_FALSE
624
+ OS_LINUX_TRUE
619
625
  LIBOBJS
620
626
  CXXCPP
621
627
  OTOOL64
@@ -1301,7 +1307,7 @@ if test "$ac_init_help" = "long"; then
1301
1307
  # Omit some internal or obsolete options to make the list less imposing.
1302
1308
  # This message is too long to be a string in the A/UX 3.1 sh.
1303
1309
  cat <<_ACEOF
1304
- \`configure' configures nutcracker 0.2.4 to adapt to many kinds of systems.
1310
+ \`configure' configures nutcracker 0.3.0 to adapt to many kinds of systems.
1305
1311
 
1306
1312
  Usage: $0 [OPTION]... [VAR=VALUE]...
1307
1313
 
@@ -1371,7 +1377,7 @@ fi
1371
1377
 
1372
1378
  if test -n "$ac_init_help"; then
1373
1379
  case $ac_init_help in
1374
- short | recursive ) echo "Configuration of nutcracker 0.2.4:";;
1380
+ short | recursive ) echo "Configuration of nutcracker 0.3.0:";;
1375
1381
  esac
1376
1382
  cat <<\_ACEOF
1377
1383
 
@@ -1417,7 +1423,7 @@ Some influential environment variables:
1417
1423
  Use these variables to override the choices made by `configure' or to help
1418
1424
  it to find libraries and programs with nonstandard names/locations.
1419
1425
 
1420
- Report bugs to <manj@twitter.com>.
1426
+ Report bugs to <manj@cs.stanford.edu>.
1421
1427
  _ACEOF
1422
1428
  ac_status=$?
1423
1429
  fi
@@ -1480,7 +1486,7 @@ fi
1480
1486
  test -n "$ac_init_help" && exit $ac_status
1481
1487
  if $ac_init_version; then
1482
1488
  cat <<\_ACEOF
1483
- nutcracker configure 0.2.4
1489
+ nutcracker configure 0.3.0
1484
1490
  generated by GNU Autoconf 2.68
1485
1491
 
1486
1492
  Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2127,9 +2133,9 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
2127
2133
  $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
2128
2134
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
2129
2135
  $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
2130
- ( $as_echo "## ------------------------------- ##
2131
- ## Report this to manj@twitter.com ##
2132
- ## ------------------------------- ##"
2136
+ ( $as_echo "## ----------------------------------- ##
2137
+ ## Report this to manj@cs.stanford.edu ##
2138
+ ## ----------------------------------- ##"
2133
2139
  ) | sed "s/^/$as_me: WARNING: /" >&2
2134
2140
  ;;
2135
2141
  esac
@@ -2151,7 +2157,7 @@ cat >config.log <<_ACEOF
2151
2157
  This file contains any messages produced by compilers while
2152
2158
  running configure, to aid debugging if configure makes a mistake.
2153
2159
 
2154
- It was created by nutcracker $as_me 0.2.4, which was
2160
+ It was created by nutcracker $as_me 0.3.0, which was
2155
2161
  generated by GNU Autoconf 2.68. Invocation command line was
2156
2162
 
2157
2163
  $ $0 $@
@@ -2972,7 +2978,7 @@ fi
2972
2978
 
2973
2979
  # Define the identity of the package.
2974
2980
  PACKAGE='nutcracker'
2975
- VERSION='0.2.4'
2981
+ VERSION='0.3.0'
2976
2982
 
2977
2983
 
2978
2984
  cat >>confdefs.h <<_ACEOF
@@ -3018,13 +3024,13 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
3018
3024
  $as_echo "#define NC_VERSION_MAJOR 0" >>confdefs.h
3019
3025
 
3020
3026
 
3021
- $as_echo "#define NC_VERSION_MINOR 2" >>confdefs.h
3027
+ $as_echo "#define NC_VERSION_MINOR 3" >>confdefs.h
3022
3028
 
3023
3029
 
3024
- $as_echo "#define NC_VERSION_PATCH 4" >>confdefs.h
3030
+ $as_echo "#define NC_VERSION_PATCH 0" >>confdefs.h
3025
3031
 
3026
3032
 
3027
- $as_echo "#define NC_VERSION_STRING \"0.2.4\"" >>confdefs.h
3033
+ $as_echo "#define NC_VERSION_STRING \"0.3.0\"" >>confdefs.h
3028
3034
 
3029
3035
 
3030
3036
  # Checks for language
@@ -16191,6 +16197,20 @@ fi
16191
16197
 
16192
16198
  done
16193
16199
 
16200
+ for ac_header in execinfo.h
16201
+ do :
16202
+ ac_fn_c_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default"
16203
+ if test "x$ac_cv_header_execinfo_h" = xyes; then :
16204
+ cat >>confdefs.h <<_ACEOF
16205
+ #define HAVE_EXECINFO_H 1
16206
+ _ACEOF
16207
+
16208
+ $as_echo "#define HAVE_BACKTRACE 1" >>confdefs.h
16209
+
16210
+ fi
16211
+
16212
+ done
16213
+
16194
16214
  for ac_header in sys/epoll.h
16195
16215
  do :
16196
16216
  ac_fn_c_check_header_mongrel "$LINENO" "sys/epoll.h" "ac_cv_header_sys_epoll_h" "$ac_includes_default"
@@ -16199,8 +16219,18 @@ if test "x$ac_cv_header_sys_epoll_h" = xyes; then :
16199
16219
  #define HAVE_SYS_EPOLL_H 1
16200
16220
  _ACEOF
16201
16221
 
16202
- else
16203
- as_fn_error $? "required sys/epoll.h header file is missing" "$LINENO" 5
16222
+ fi
16223
+
16224
+ done
16225
+
16226
+ for ac_header in sys/event.h
16227
+ do :
16228
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/event.h" "ac_cv_header_sys_event_h" "$ac_includes_default"
16229
+ if test "x$ac_cv_header_sys_event_h" = xyes; then :
16230
+ cat >>confdefs.h <<_ACEOF
16231
+ #define HAVE_SYS_EVENT_H 1
16232
+ _ACEOF
16233
+
16204
16234
  fi
16205
16235
 
16206
16236
  done
@@ -16739,13 +16769,141 @@ fi
16739
16769
  $as_echo "$ac_cv_epoll_works" >&6; }
16740
16770
  if test "x$ac_cv_epoll_works" = "xyes"; then :
16741
16771
 
16772
+ $as_echo "#define HAVE_EPOLL 1" >>confdefs.h
16773
+
16774
+ fi
16775
+
16776
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if kqueue works" >&5
16777
+ $as_echo_n "checking if kqueue works... " >&6; }
16778
+ if ${ac_cv_kqueue_works+:} false; then :
16779
+ $as_echo_n "(cached) " >&6
16780
+ else
16781
+ if test "$cross_compiling" = yes; then :
16782
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
16783
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
16784
+ as_fn_error $? "cannot run test program while cross compiling
16785
+ See \`config.log' for more details" "$LINENO" 5; }
16786
+ else
16787
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16788
+ /* end confdefs.h. */
16789
+
16790
+ #include <stdio.h>
16791
+ #include <stdlib.h>
16792
+ #include <sys/types.h>
16793
+ #include <sys/event.h>
16794
+ #include <sys/time.h>
16795
+ int
16796
+ main(int argc, char **argv)
16797
+ {
16798
+ int fd;
16799
+
16800
+ fd = kqueue();
16801
+ if (fd < 0) {
16802
+ perror("kqueue:");
16803
+ exit(1);
16804
+ }
16805
+ exit(0);
16806
+ }
16807
+
16808
+ _ACEOF
16809
+ if ac_fn_c_try_run "$LINENO"; then :
16810
+ ac_cv_kqueue_works=yes
16811
+ else
16812
+ ac_cv_kqueue_works=no
16813
+ fi
16814
+ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
16815
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
16816
+ fi
16817
+
16818
+ fi
16819
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_kqueue_works" >&5
16820
+ $as_echo "$ac_cv_kqueue_works" >&6; }
16821
+ if test "x$ac_cv_kqueue_works" = "xyes"; then :
16822
+
16823
+ $as_echo "#define HAVE_KQUEUE 1" >>confdefs.h
16824
+
16825
+ fi
16826
+
16827
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if event ports works" >&5
16828
+ $as_echo_n "checking if event ports works... " >&6; }
16829
+ if ${ac_cv_evports_works+:} false; then :
16830
+ $as_echo_n "(cached) " >&6
16742
16831
  else
16832
+ if test "$cross_compiling" = yes; then :
16743
16833
  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
16744
16834
  $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
16745
- as_fn_error $? "Linux epoll(7) API is missing
16835
+ as_fn_error $? "cannot run test program while cross compiling
16746
16836
  See \`config.log' for more details" "$LINENO" 5; }
16837
+ else
16838
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16839
+ /* end confdefs.h. */
16840
+
16841
+ #include <stdio.h>
16842
+ #include <stdlib.h>
16843
+ #include <port.h>
16844
+ int
16845
+ main(int argc, char **argv)
16846
+ {
16847
+ int fd;
16848
+
16849
+ fd = port_create();
16850
+ if (fd < 0) {
16851
+ perror("port_create:");
16852
+ exit(1);
16853
+ }
16854
+ exit(0);
16855
+ }
16856
+
16857
+ _ACEOF
16858
+ if ac_fn_c_try_run "$LINENO"; then :
16859
+ ac_cv_evports_works=yes
16860
+ else
16861
+ ac_cv_evports_works=no
16862
+ fi
16863
+ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
16864
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
16865
+ fi
16866
+
16867
+ fi
16868
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_evports_works" >&5
16869
+ $as_echo "$ac_cv_evports_works" >&6; }
16870
+ if test "x$ac_cv_evports_works" = "xyes"; then :
16871
+
16872
+ $as_echo "#define HAVE_EVENT_PORTS 1" >>confdefs.h
16873
+
16874
+ fi
16875
+
16876
+ if test "x$ac_cv_epoll_works" = "xno" &&
16877
+ test "x$ac_cv_kqueue_works" = "xno" &&
16878
+ test "x$ac_cv_evports_works" = "xno"; then :
16879
+ as_fn_error $? "either epoll or kqueue or event ports support is required" "$LINENO" 5
16880
+ fi
16881
+
16882
+ if test "x$ac_cv_epoll_works" = "xyes"; then
16883
+ OS_LINUX_TRUE=
16884
+ OS_LINUX_FALSE='#'
16885
+ else
16886
+ OS_LINUX_TRUE='#'
16887
+ OS_LINUX_FALSE=
16747
16888
  fi
16748
16889
 
16890
+ if test "x$ac_cv_kqueue_works" = "xyes"; then
16891
+ OS_BSD_TRUE=
16892
+ OS_BSD_FALSE='#'
16893
+ else
16894
+ OS_BSD_TRUE='#'
16895
+ OS_BSD_FALSE=
16896
+ fi
16897
+
16898
+ if test "x$ac_cv_evports_works" = "xyes"; then
16899
+ OS_SOLARIS_TRUE=
16900
+ OS_SOLARIS_FALSE='#'
16901
+ else
16902
+ OS_SOLARIS_TRUE='#'
16903
+ OS_SOLARIS_FALSE=
16904
+ fi
16905
+
16906
+
16749
16907
  # Package options
16750
16908
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable debug logs and asserts" >&5
16751
16909
  $as_echo_n "checking whether to enable debug logs and asserts... " >&6; }
@@ -16817,7 +16975,7 @@ subdirs="$subdirs contrib/yaml-0.1.4"
16817
16975
 
16818
16976
 
16819
16977
  # Define Makefiles
16820
- ac_config_files="$ac_config_files Makefile contrib/Makefile src/Makefile src/hashkit/Makefile src/proto/Makefile"
16978
+ ac_config_files="$ac_config_files Makefile contrib/Makefile src/Makefile src/hashkit/Makefile src/proto/Makefile src/event/Makefile"
16821
16979
 
16822
16980
 
16823
16981
  # Generate the "configure" script
@@ -16950,6 +17108,18 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
16950
17108
  as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
16951
17109
  Usually this means the macro was only invoked conditionally." "$LINENO" 5
16952
17110
  fi
17111
+ if test -z "${OS_LINUX_TRUE}" && test -z "${OS_LINUX_FALSE}"; then
17112
+ as_fn_error $? "conditional \"OS_LINUX\" was never defined.
17113
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
17114
+ fi
17115
+ if test -z "${OS_BSD_TRUE}" && test -z "${OS_BSD_FALSE}"; then
17116
+ as_fn_error $? "conditional \"OS_BSD\" was never defined.
17117
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
17118
+ fi
17119
+ if test -z "${OS_SOLARIS_TRUE}" && test -z "${OS_SOLARIS_FALSE}"; then
17120
+ as_fn_error $? "conditional \"OS_SOLARIS\" was never defined.
17121
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
17122
+ fi
16953
17123
  tar xvfz contrib/yaml-0.1.4.tar.gz -C contrib
16954
17124
 
16955
17125
  : "${CONFIG_STATUS=./config.status}"
@@ -17360,7 +17530,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
17360
17530
  # report actual input values of CONFIG_FILES etc. instead of their
17361
17531
  # values after options handling.
17362
17532
  ac_log="
17363
- This file was extended by nutcracker $as_me 0.2.4, which was
17533
+ This file was extended by nutcracker $as_me 0.3.0, which was
17364
17534
  generated by GNU Autoconf 2.68. Invocation command line was
17365
17535
 
17366
17536
  CONFIG_FILES = $CONFIG_FILES
@@ -17420,13 +17590,13 @@ $config_headers
17420
17590
  Configuration commands:
17421
17591
  $config_commands
17422
17592
 
17423
- Report bugs to <manj@twitter.com>."
17593
+ Report bugs to <manj@cs.stanford.edu>."
17424
17594
 
17425
17595
  _ACEOF
17426
17596
  cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
17427
17597
  ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
17428
17598
  ac_cs_version="\\
17429
- nutcracker config.status 0.2.4
17599
+ nutcracker config.status 0.3.0
17430
17600
  configured by $0, generated by GNU Autoconf 2.68,
17431
17601
  with options \\"\$ac_cs_config\\"
17432
17602
 
@@ -17938,6 +18108,7 @@ do
17938
18108
  "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
17939
18109
  "src/hashkit/Makefile") CONFIG_FILES="$CONFIG_FILES src/hashkit/Makefile" ;;
17940
18110
  "src/proto/Makefile") CONFIG_FILES="$CONFIG_FILES src/proto/Makefile" ;;
18111
+ "src/event/Makefile") CONFIG_FILES="$CONFIG_FILES src/event/Makefile" ;;
17941
18112
 
17942
18113
  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
17943
18114
  esac
@@ -1,8 +1,8 @@
1
1
  # Define the package version numbers and the bug reporting address
2
2
  m4_define([NC_MAJOR], 0)
3
- m4_define([NC_MINOR], 2)
4
- m4_define([NC_PATCH], 4)
5
- m4_define([NC_BUGS], [manj@twitter.com])
3
+ m4_define([NC_MINOR], 3)
4
+ m4_define([NC_PATCH], 0)
5
+ m4_define([NC_BUGS], [manj@cs.stanford.edu])
6
6
 
7
7
  # Initialize autoconf
8
8
  AC_PREREQ([2.64])
@@ -67,7 +67,10 @@ AC_CHECK_HEADERS([fcntl.h float.h limits.h stddef.h stdlib.h string.h unistd.h])
67
67
  AC_CHECK_HEADERS([inttypes.h stdint.h])
68
68
  AC_CHECK_HEADERS([sys/ioctl.h sys/time.h sys/uio.h])
69
69
  AC_CHECK_HEADERS([sys/socket.h sys/un.h netinet/in.h arpa/inet.h netdb.h])
70
- AC_CHECK_HEADERS([sys/epoll.h], [], [AC_MSG_ERROR([required sys/epoll.h header file is missing])])
70
+ AC_CHECK_HEADERS([execinfo.h],
71
+ [AC_DEFINE(HAVE_BACKTRACE, [1], [Define to 1 if backtrace is supported])], [])
72
+ AC_CHECK_HEADERS([sys/epoll.h], [], [])
73
+ AC_CHECK_HEADERS([sys/event.h], [], [])
71
74
 
72
75
  # Checks for libraries
73
76
  AC_CHECK_LIB([m], [pow])
@@ -100,7 +103,61 @@ main(int argc, char **argv)
100
103
  exit(0);
101
104
  }
102
105
  ], [ac_cv_epoll_works=yes], [ac_cv_epoll_works=no]))
103
- AS_IF([test "x$ac_cv_epoll_works" = "xyes"], [], [AC_MSG_FAILURE([Linux epoll(7) API is missing])])
106
+ AS_IF([test "x$ac_cv_epoll_works" = "xyes"],
107
+ [AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is supported])], [])
108
+
109
+ AC_CACHE_CHECK([if kqueue works], [ac_cv_kqueue_works],
110
+ AC_TRY_RUN([
111
+ #include <stdio.h>
112
+ #include <stdlib.h>
113
+ #include <sys/types.h>
114
+ #include <sys/event.h>
115
+ #include <sys/time.h>
116
+ int
117
+ main(int argc, char **argv)
118
+ {
119
+ int fd;
120
+
121
+ fd = kqueue();
122
+ if (fd < 0) {
123
+ perror("kqueue:");
124
+ exit(1);
125
+ }
126
+ exit(0);
127
+ }
128
+ ], [ac_cv_kqueue_works=yes], [ac_cv_kqueue_works=no]))
129
+ AS_IF([test "x$ac_cv_kqueue_works" = "xyes"],
130
+ [AC_DEFINE([HAVE_KQUEUE], [1], [Define to 1 if kqueue is supported])], [])
131
+
132
+ AC_CACHE_CHECK([if event ports works], [ac_cv_evports_works],
133
+ AC_TRY_RUN([
134
+ #include <stdio.h>
135
+ #include <stdlib.h>
136
+ #include <port.h>
137
+ int
138
+ main(int argc, char **argv)
139
+ {
140
+ int fd;
141
+
142
+ fd = port_create();
143
+ if (fd < 0) {
144
+ perror("port_create:");
145
+ exit(1);
146
+ }
147
+ exit(0);
148
+ }
149
+ ], [ac_cv_evports_works=yes], [ac_cv_evports_works=no]))
150
+ AS_IF([test "x$ac_cv_evports_works" = "xyes"],
151
+ [AC_DEFINE([HAVE_EVENT_PORTS], [1], [Define to 1 if event ports is supported])], [])
152
+
153
+ AS_IF([test "x$ac_cv_epoll_works" = "xno" &&
154
+ test "x$ac_cv_kqueue_works" = "xno" &&
155
+ test "x$ac_cv_evports_works" = "xno"],
156
+ [AC_MSG_ERROR([either epoll or kqueue or event ports support is required])], [])
157
+
158
+ AM_CONDITIONAL([OS_LINUX], [test "x$ac_cv_epoll_works" = "xyes"])
159
+ AM_CONDITIONAL([OS_BSD], [test "x$ac_cv_kqueue_works" = "xyes"])
160
+ AM_CONDITIONAL([OS_SOLARIS], [test "x$ac_cv_evports_works" = "xyes"])
104
161
 
105
162
  # Package options
106
163
  AC_MSG_CHECKING([whether to enable debug logs and asserts])
@@ -149,7 +206,8 @@ AC_CONFIG_FILES([Makefile
149
206
  contrib/Makefile
150
207
  src/Makefile
151
208
  src/hashkit/Makefile
152
- src/proto/Makefile])
209
+ src/proto/Makefile
210
+ src/event/Makefile])
153
211
 
154
212
  # Generate the "configure" script
155
213
  AC_OUTPUT
@@ -1,5 +1,5 @@
1
1
 
2
- raise "no support for #{RUBY_PLATFORM}" if RUBY_PLATFORM =~ /darwin|mswin|mingw/
2
+ #raise "no support for #{RUBY_PLATFORM}" if RUBY_PLATFORM =~ /darwin|mswin|mingw/
3
3
  system "./configure --prefix=#{File.expand_path('..',__FILE__)}"
4
4
  system 'make'
5
5
 
@@ -0,0 +1,76 @@
1
+ .TH NUTCRACKER 8 "June 13, 2013"
2
+ .SH NAME
3
+ nutcracker \- Fast, light-weight proxy for memcached and Redis
4
+ .SH SYNOPSIS
5
+ .B nutcracker
6
+ .RI [ options ]
7
+ .SH DESCRIPTION
8
+ \fBnutcracker\fP, also known as \fBtwemproxy\fP (pronounced "two-em-proxy"), is
9
+ a fast and lightweight proxy for the memcached and Redis protocols.
10
+ .PP
11
+ It was primarily built to reduce the connection count on backend caching
12
+ servers, but it has a number of features, such as:
13
+ .IP \[bu]
14
+ Maintains persistent server connections to backend servers.
15
+ .IP \[bu]
16
+ Enables pipelining of requests and responses.
17
+ .IP \[bu]
18
+ Supports multiple server pools simultaneously.
19
+ .IP \[bu]
20
+ Shard data automatically across multiple servers.
21
+ .IP \[bu]
22
+ Supports multiple hashing modes including consistent hashing and
23
+ distribution.
24
+ .IP \[bu]
25
+ High-availability by disabling nodes on failures.
26
+ .IP \[bu]
27
+ Observability through stats exposed on stats monitoring port.
28
+ .SH OPTIONS
29
+ .TP
30
+ .BR \-h ", " \-\-help
31
+ Show usage information and exit.
32
+ .TP
33
+ .BR \-V ", " \-\-version
34
+ Show version and exit.
35
+ .TP
36
+ .BR \-t ", " \-\-test-conf
37
+ Test configuration for syntax errors and exit.
38
+ .TP
39
+ .BR \-D ", " \-\-describe-stats
40
+ Print stats description and exit.
41
+ .TP
42
+ .BR \-v ", " \-\-verbosity=\fIN\fP
43
+ Set logging level to \fIN\fP. (default: 5, min: 0, max: 11)
44
+ .TP
45
+ .BR \-o ", " \-\-output=\fIfilename\fP
46
+ Set logging file to \fIfilename\fP.
47
+ .TP
48
+ .BR \-c ", " \-\-conf-file=\fIfilename\fP
49
+ Set configuration file to \fIfilename\fP.
50
+ .TP
51
+ .BR \-s ", " \-\-stats-port=\fIport\fP
52
+ Set stats monitoring port to \fIport\fP.
53
+ (default: 22222)
54
+ .TP
55
+ .BR \-a ", " \-\-stats-addr=\fIaddress\fP
56
+ Set stats monitoring IP to \fIaddress\fP.
57
+ (default: 0.0.0.0)
58
+ .TP
59
+ .BR \-i ", " \-\-stats-interval=\fIinterval\fP
60
+ Set stats aggregation interval in msec to \fIinterval\fP.
61
+ (default: 30000 msec)
62
+ .TP
63
+ .BR \-m ", " \-\-mbuf-size=\fIsize\fP
64
+ Set size of mbuf chunk in bytes to \fIsize\fP. (default: 16384 bytes)
65
+ .TP
66
+ .BR \-d ", " \-\-daemonize
67
+ Run as a daemon.
68
+ .TP
69
+ .BR \-p ", " \-\-pid-file=\fIfilename\fP
70
+ Set pid file to \fIfilename\fP.
71
+ .SH SEE ALSO
72
+ .BR memcached (8),
73
+ .BR redis-server (1)
74
+ .br
75
+ .SH AUTHOR
76
+ nutcracker was written by Twitter, Inc.
@@ -1,22 +1,6 @@
1
1
  - strace
2
2
  strace -o strace.txt -ttT -s 1024 -p `pgrep nutcracker`
3
3
 
4
- - epoll
5
-
6
- EPOLLIN = 0x001,
7
- EPOLLPRI = 0x002,
8
- EPOLLOUT = 0x004,
9
- EPOLLERR = 0x008,
10
- EPOLLHUP = 0x010,
11
- EPOLLRDNORM = 0x040,
12
- EPOLLRDBAND = 0x080,
13
- EPOLLWRNORM = 0x100,
14
- EPOLLWRBAND = 0x200,
15
- EPOLLMSG = 0x400,
16
- EPOLLRDHUP = 0x2000,
17
- EPOLLONESHOT = (1 << 30),
18
- EPOLLET = (1 << 31)
19
-
20
4
  - libyaml (yaml-0.1.4)
21
5
 
22
6
  - yaml tokens:
@@ -94,3 +78,119 @@
94
78
  http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_2.html
95
79
  /usr/include/asm-generic/errno-base.h
96
80
  /usr/include/asm-generic/errno.h
81
+
82
+ - epoll (linux)
83
+
84
+ union epoll_data {
85
+ void *ptr;
86
+ int fd;
87
+ uint32_t u32;
88
+ uint64_t u64;
89
+ };
90
+
91
+ struct epoll_event {
92
+ uint32_t events; /* epoll events */
93
+ struct epoll_data data; /* user data variable */
94
+ };
95
+
96
+ /* events */
97
+ EPOLLIN = 0x001,
98
+ EPOLLPRI = 0x002,
99
+ EPOLLOUT = 0x004,
100
+ EPOLLERR = 0x008,
101
+ EPOLLHUP = 0x010,
102
+ EPOLLRDNORM = 0x040,
103
+ EPOLLRDBAND = 0x080,
104
+ EPOLLWRNORM = 0x100,
105
+ EPOLLWRBAND = 0x200,
106
+ EPOLLMSG = 0x400,
107
+ EPOLLRDHUP = 0x2000,
108
+ EPOLLONESHOT = (1 << 30),
109
+ EPOLLET = (1 << 31)
110
+
111
+ /* opcodes */
112
+ EPOLL_CTL_ADD = 1 /* add a file decriptor to the interface */
113
+ EPOLL_CTL_DEL = 2 /* remove a file decriptor from the interface */
114
+ EPOLL_CTL_MOD = 3 /* change file decriptor epoll_event structure */
115
+
116
+ - kqueue (bsd)
117
+
118
+ struct kevent {
119
+ uintptr_t ident; /* identifier for this event */
120
+ int16_t filter; /* filter for event */
121
+ uint16_t flags; /* general flags */
122
+ uint32_t fflags; /* filter-specific flags */
123
+ intptr_t data; /* filter-specific data */
124
+ void *udata; /* opaque user data identifier */
125
+ };
126
+
127
+ /* flags / events */
128
+ EV_ADD = 0x0001 /* action - add event to kq (implies enable) */
129
+ EV_DELETE = 0x0002 /* action - delete event from kq */
130
+ EV_ENABLE = 0x0004 /* action - enable event */
131
+ EV_DISABLE = 0x0008 /* action - disable event (not reported) */
132
+ EV_RECEIPT = 0x0040 /* action - force EV_ERROR on success, data == 0 */
133
+
134
+ EV_ONESHOT = 0x0010 /* flags - only report one occurrence */
135
+ EV_CLEAR = 0x0020 /* flags - clear event state after reporting */
136
+ EV_DISPATCH = 0x0080 /* flags - disable event after reporting */
137
+ EV_SYSFLAGS = 0xF000 /* flags - reserved by system */
138
+ EV_FLAG0 = 0x1000 /* flags - filter-specific flag */
139
+ EV_FLAG1 = 0x2000 /* flags - filter-specific flag */
140
+
141
+ EV_EOF = 0x8000 /* returned values - EOF detected */
142
+ EV_ERROR = 0x4000 /* returned values - error, data contains errno */
143
+
144
+ /* filters */
145
+ EVFILT_READ (-1) /* readable */
146
+ EVFILT_WRITE (-2) /* writable */
147
+ EVFILT_AIO (-3) /* attached to aio requests */
148
+ EVFILT_VNODE (-4) /* attached to vnodes */
149
+ EVFILT_PROC (-5) /* attached to struct proc */
150
+ EVFILT_SIGNAL (-6) /* attached to struct proc */
151
+ EVFILT_TIMER (-7) /* timers */
152
+ EVFILT_MACHPORT (-8) /* mach portsets */
153
+ EVFILT_FS (-9) /* filesystem events */
154
+ EVFILT_USER (-10) /* user events */
155
+ EVFILT_VM (-12) /* virtual memory events */
156
+
157
+ EV_CLEAR behaves like EPOLLET because it resets the event after it is
158
+ returned; without this flag, the event would be repeatedly returned.
159
+
160
+ - poll (unix)
161
+
162
+ POLLIN 0x001 /* there is data to read */
163
+ POLLPRI 0x002 /* there is urgent data to read */
164
+ POLLOUT 0x004 /* writing now will not block */
165
+
166
+ POLLRDNORM 0x040 /* normal data may be read */
167
+ POLLRDBAND 0x080 /* priority data may be read */
168
+ POLLWRNORM 0x100 /* writing now will not block */
169
+ POLLWRBAND 0x200 /* priority data may be written */
170
+
171
+ POLLMSG 0x400
172
+ POLLREMOVE 0x1000
173
+ POLLRDHUP 0x2000
174
+
175
+ POLLERR 0x008 /* error condition */
176
+ POLLHUP 0x010 /* hung up */
177
+ POLLNVAL 0x020 /* invalid polling request */
178
+
179
+ - event ports (solaris)
180
+
181
+ typedef struct port_event {
182
+ int portev_events; /* event data is source specific */
183
+ ushort_t portev_source; /* event source */
184
+ ushort_t portev_pad; /* port internal use */
185
+ uintptr_t portev_object; /* source specific object */
186
+ void *portev_user; /* user cookie */
187
+ } port_event_t;
188
+
189
+ /* port sources */
190
+ PORT_SOURCE_AIO 1
191
+ PORT_SOURCE_TIMER 2
192
+ PORT_SOURCE_USER 3
193
+ PORT_SOURCE_FD 4
194
+ PORT_SOURCE_ALERT 5
195
+ PORT_SOURCE_MQ 6
196
+ PORT_SOURCE_FILE 7
Binary file