With HipHop we’ve reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page. Less CPU means fewer servers, which means less overhead. This project has had a tremendous impact on Facebook.
注意:我一开始cmake的时候,总会报Could NOT find TBB library的错误,分析了hiphop-php/CMake/FindTBB.cmake源码后,发现167行为:
set (TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/$ENV{TBB_ARCH_PLATFORM}/lib")
改为
set (TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/lib/$ENV{TBB_ARCH_PLATFORM}")
cmake列表
-- MySQL Include dir: /root/bulid/mysql/include library dir: /root/bulid/mysql/lib/mysql
-- MySQL client libraries: mysqlclient_r
-- Found libevent: /usr/lib64/libevent.so
-- Found GD: /usr/lib64/libgd.so
-- Found ICU header files in /usr/include
-- Found ICU libraries: /usr/lib64/libicuuc.so
-- Skipping TCmalloc
-- Found Intel TBB
-- Found mcrypt: /usr/lib/libmcrypt.so
-- Looking for arpa/inet.h
-- Looking for arpa/inet.h - found
-- Looking for netinet/in.h
-- Looking for netinet/in.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for sys/socket.h
-- Looking for sys/socket.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of size_t
-- Check size of size_t - done
-- Check size of ssize_t
-- Check size of ssize_t - done
-- Check size of uint32_t
-- Check size of uint32_t - done
-- Check size of uint8_t
-- Check size of uint8_t - done
-- Looking for AF_LOCAL
-- Looking for AF_LOCAL - found
-- Looking for PF_LOCAL
-- Looking for PF_LOCAL - found
-- Looking for memset
-- Looking for memset - found
-- Looking for socket
-- Looking for socket - found
-- Looking for strerror
-- Looking for strerror - found
-- Found libevent: /usr/lib64/libevent.so
-- Looking for event_get_version_number
-- Looking for event_get_version_number - found.
-- Performing Test HAVE_LIBEVENT_145
-- Performing Test HAVE_LIBEVENT_145 - Success
-- Found libevent 1.4.5+
-- Looking for include files INCLUDE_CHECK_stdlib.h
-- Looking for include files INCLUDE_CHECK_stdlib.h - found
-- Looking for include files INCLUDE_CHECK_assert.h
-- Looking for include files INCLUDE_CHECK_assert.h - found
-- Looking for strcasecmp
-- Looking for strcasecmp - found
-- Looking for strchr
-- Looking for strchr - found
-- Downloading 8859-1.TXT
-- Downloading 8859-2.TXT
-- Downloading 8859-3.TXT
-- Downloading 8859-4.TXT
-- Downloading 8859-5.TXT
-- Downloading 8859-6.TXT
-- Downloading 8859-7.TXT
-- Downloading 8859-8.TXT
-- Downloading 8859-9.TXT
-- Downloading 8859-10.TXT
-- Downloading 8859-11.TXT
-- Downloading 8859-13.TXT
-- Downloading 8859-14.TXT
-- Downloading 8859-15.TXT
-- Downloading 8859-16.TXT
-- Downloading EastAsianWidth.txt
-- Looking for include files HAVE_SYS_STAT_H
-- Looking for include files HAVE_SYS_STAT_H - found
-- Looking for include files HAVE_STDLIB_H
-- Looking for include files HAVE_STDLIB_H - found
-- Looking for include files HAVE_STRING_H
-- Looking for include files HAVE_STRING_H - found
-- Looking for include files HAVE_MEMORY_H
-- Looking for include files HAVE_MEMORY_H - found
-- Looking for include files HAVE_STRINGS_H
-- Looking for include files HAVE_STRINGS_H - found
-- Looking for include files HAVE_INTTYPES_H
-- Looking for include files HAVE_INTTYPES_H - found
-- Looking for include files HAVE_UNISTD_H
-- Looking for include files HAVE_UNISTD_H - found
-- Looking for include files HAVE_DLFCN_H
-- Looking for include files HAVE_DLFCN_H - found
-- Looking for fdatasync
-- Looking for fdatasync - found
-- Looking for usleep
-- Looking for usleep - found
-- Looking for fullfsync
-- Looking for fullfsync - found
-- Looking for localtime_r
-- Looking for localtime_r - found
-- Looking for gmtime_r
-- Looking for gmtime_r - found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for include files HAVE_LOCALE_H
-- Looking for include files HAVE_LOCALE_H - found
-- Looking for include files HAVE_LIMITS_H
-- Looking for include files HAVE_LIMITS_H - found
-- Check size of int32_t
-- Check size of int32_t - done
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for atoll
-- Looking for atoll - found
-- Looking for strftime
-- Looking for strftime - found
-- Looking for setlocale
-- Looking for setlocale - found
-- Configuring done
-- Generating done
-- Build files have been written to: /root/build/hiphop-php
cmake一般出错就是提示库找不到,原因出了之前说的那种外还有可能是程序找的/usr/lib/libxxx.so,而这个lib本身叫/usr/lib/libxxx.so.1,因此你需要cp一份或是ln,让程序能找得到。 14.make HipHop,离胜利仅仅一步之遥了!
[iyunv@localhost hiphop-php]# make
make的时候很耗cpu和内存的,因此想在vps上玩HipHop的同学要注意了,有可能程序会卡死。
我在make的过程中碰到如下的错误:
追到ext_mysql.cpp的722行后看到有如下语句:
721 static Variant php_mysql_localize_result(MYSQL *mysql) {
722 mysql = mysql->last_used_con;
723 if (!mysql->fields) return true;
724 if (mysql->status != MYSQL_STATUS_GET_RESULT) {
725 // consistent with php_mysql_do_query_general
726 return true;
727 }
我查询了mysql-5.5.3的源码后,发现MYSQL的定义并没有last_used_con,结构如下:
typedef struct st_mysql
{
NET net; /* Communication parameters */
unsigned char *connector_fd; /* ConnectorFd for SSL */
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
char *info, *db;
struct charset_info_st *charset;
MYSQL_FIELD *fields;
MEM_ROOT field_alloc;
my_ulonglong affected_rows;
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
my_ulonglong extra_info; /* Not used */
unsigned long thread_id; /* Id for connection in server */
unsigned long packet_length;
unsigned int port;
unsigned long client_flag,server_capabilities;
unsigned int protocol_version;
unsigned int field_count;
unsigned int server_status;
unsigned int server_language;
unsigned int warning_count;
struct st_mysql_options options;
enum mysql_status status;
my_bool free_me; /* If free in mysql_close */
my_bool reconnect; /* set to 1 if automatic reconnect */
LIST *stmts; /* list of all statements */
const struct st_mysql_methods *methods;
void *thd;
/*
Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag
from mysql_stmt_close if close had to cancel result set of this object.
*/
my_bool *unbuffered_fetch_owner;
/* needed for embedded server - no net buffer to store the 'info' */
char *info_buffer;
void *extension;
} MYSQL;