Skip to content

Commit

Permalink
speed up bind function for Variant
Browse files Browse the repository at this point in the history
Summary: The bind function for Variant is frequently called. For instance,
         every rvalAt returns a Variant and therefore involves a call to
         bind(). I did some manual inline to speed up bind especially when
         the type is primitive. For the following test case, the speed up is
         about 12.6%.
         <?php
         function foo($a) {
           for ($i = 0; $i < 10000; $i++) {
             for ($j = 0; $j < 10000; $j++) {
               $b = $a[0];
             }
           }
         }
         $a = array(1, 2, 3);
         foo($a);
         
         time test.old
         
         real    0m3.990s
         user    0m3.948s
         sys     0m0.009s
         time test.new
         
         real    0m3.487s
         user    0m3.447s
         sys     0m0.008s

Reviewed By: hzhao

Test Plan: This change passed fast_tests and slow_tests
           Also made www and browsed the site

Revert: OK

DiffCamp Revision: 87941

git-svn-id: http://svn.facebook.net/hiphop/fbomb/branches/hphp-dev/fbcode/hphp@21199 2248de34-8caa-4a3c-bc55-5e52d9d7b73a
  • Loading branch information
myang committed Feb 3, 2010
0 parents commit b0eb74a
Show file tree
Hide file tree
Showing 6,163 changed files with 884,076 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
17 changes: 17 additions & 0 deletions Makefile
@@ -0,0 +1,17 @@

fast_tests:
$(MAKE) -C src
cd src && test/test "" "" QuickTests
cd src && test/test "" "" TestExt
cd src && test/test TestCodeRunEval

slow_tests:
$(MAKE) -C src
cd src && NO_DISTCC=1 time test/test TestCodeRun
cd src && NO_DISTCC=1 time test/test TestServer

clobber:
$(MAKE) -C src clobber
$(MAKE) -C facebook clobber

clean: clobber
88 changes: 88 additions & 0 deletions bin/hdf.el
@@ -0,0 +1,88 @@

;; Better HDF read/write experience in emacs (9/25/09 hzhao@facebook.com)

(require 'font-lock)

(defvar hdf-mode-hook nil)
(add-to-list 'auto-mode-alist '("\\.hdf\\'" . hdf-mode))

(defvar hdf-indent-level 2
"Defines 2 spaces for HDF indentation.")

;; syntax coloring
;; http://www.gnu.org/software/emacs/elisp/html_node/Faces-for-Font-Lock.html
(defconst hdf-font-lock-keywords
(list
'("^[ \t]*\\([\\#\\-]include\\)[ \t]+\\(.*\\)"
(1 font-lock-keyword-face)
(2 font-lock-string-face)) ;; include
'("^[ \t]*#.*$" . font-lock-comment-face) ;; comments
'("^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*\\(!=\\)[ \t]*\\(.*\\)"
(1 font-lock-variable-name-face)
(2 font-lock-function-name-face)) ;; shell commands
'("^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*\\(:=\\)[ \t]*\\([a-z0-9\\.]+\\)[ \t]*$"
(1 font-lock-variable-name-face)
(2 font-lock-function-name-face)
(3 font-lock-variable-name-face)) ;; node copying
'("^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*=[ \t]*\\(true\\|false\\|yes\\|no\\|on\\|off\\)[ \t]*$"
(1 font-lock-variable-name-face)
(2 font-lock-keyword-face)) ;; booleans
'("^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*=[ \t]*\\([0-9]+\\)[ \t]*$"
(1 font-lock-variable-name-face)
(2 font-lock-constant-face)) ;; numbers
'("^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*=[ \t]*\\(.*\\)"
(1 font-lock-variable-name-face)) ;; strings
'("^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*[{=][ \t]*$"
(1 font-lock-variable-name-face)) ;; nodes
'("^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*\\(:\\)[ \t]*\\([a-z0-9\\.]+\\)[ \t]*$"
(1 font-lock-variable-name-face)
(2 font-lock-function-name-face)
(3 font-lock-variable-name-face)) ;; node aliases
'("^[ \t]*\\(@\\)\\([a-z0-9_\\.]+\\)[ \t]*$"
(1 font-lock-function-name-face)
(2 font-lock-variable-name-face)) ;; node inheritance
)
"Hdf Keywords")

;; indentation
(defun hdf-indent-line ()
"Indent current line as HDF code."
(interactive)
(beginning-of-line)
(if (bobp)
(indent-line-to 0)
(progn
(if (looking-at "^[ \t]*}")
(save-excursion
(forward-line -1)
(while (and (not (bobp)) (looking-at "^[ \t]*$"))
(forward-line -1))
(if (looking-at "^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*{")
(setq cur-indent (current-indentation))
(progn
(setq cur-indent (- (current-indentation) hdf-indent-level))
(if (< cur-indent 0)
(indent-line-to 0)))))
(save-excursion
(forward-line -1)
(while (and (not (bobp)) (looking-at "^[ \t]*$"))
(forward-line -1))
(if (looking-at "^[ \t]*\\([a-z0-9_\\.\\*]+\\)[ \t]*{")
(setq cur-indent (+ (current-indentation) hdf-indent-level))
(setq cur-indent (current-indentation)))))
(if cur-indent
(indent-line-to cur-indent)
(indent-line-to 0)))))

(defun hdf-mode ()
"Mode for editing HDF files"
(interactive)
(kill-all-local-variables)
(set (make-local-variable 'font-lock-defaults)
'(hdf-font-lock-keywords nil, 1))
(setq major-mode 'hdf-mode)
(setq mode-name "HDF")
(run-hooks 'hdf-mode-hook)
(set (make-local-variable 'indent-line-function) 'hdf-indent-line)
)
(provide 'hdf-mode)
32 changes: 32 additions & 0 deletions bin/run.mk
@@ -0,0 +1,32 @@

PROJECT_ROOT = $(HPHP_HOME)

ifndef PROJECT_NAME
PROJECT_NAME = program
endif

# We want files to be sorted by size, so that larger files are dispatched by
# distcc earlier
CXX_NOOPT_SOURCES = $(shell echo `find . -name "*.no.cpp"`)
RECURSIVE_SOURCES = $(shell echo `find . -name "*.cpp"`)
SIZE_SORTED_SOURCES = $(wildcard ./sys/*.cpp) \
$(shell echo `if [ -e cpp/ ]; then ls -S ./cpp/*.cpp; fi`)
CXX_SOURCES = $(filter-out $(CXX_NOOPT_SOURCES), $(SIZE_SORTED_SOURCES) \
$(filter-out $(SIZE_SORTED_SOURCES), $(RECURSIVE_SOURCES)))

CPPFLAGS += -I.
LIBS = $(HPHP_LIB)/libhphp_runtime.a $(ALL_LIBS)

include $(HPHP_HOME)/src/rules.mk

ifdef HPHP_BUILD_LIBRARY
TARGETS = $(STATIC_LIB) $(SHARED_LIB)
else
TARGETS = $(APP_TARGET)
endif

all: $(TARGETS)

ifdef HPHP_BUILD_FFI
EXTERNAL += $(HPHP_LIB)/libhphp_java.so
endif
10 changes: 10 additions & 0 deletions bin/run.sh
@@ -0,0 +1,10 @@
#!/bin/sh
#$1: output directory
#$2: program name
#$3: extra flags, for exmaple, RELEASE=1
if [ ${#SHOW_COMPILE} -gt 0 ] ; then
echo cp $HPHP_HOME/bin/run.mk $1/Makefile
echo make -j $3 PROJECT_NAME=$2 TIME_LINK=1 -C $1
fi
cp $HPHP_HOME/bin/run.mk $1/Makefile
make -j $3 PROJECT_NAME=$2 TIME_LINK=1 -C $1
28 changes: 28 additions & 0 deletions bin/time_build.php
@@ -0,0 +1,28 @@
<?php

$lines = file_get_contents($argv[1]);
$lines = preg_split('/\n/', $lines);

$times = array();
foreach ($lines as $line) {
if (preg_match('/^([0-9\.]+) .* ([^ ]+\.cpp|c)$/', $line, $matches)) {
$time = $matches[1];
$file = $matches[2];
$times[$file] = $time;
} else if (preg_match('/^([0-9\.]+) (g\+\+ -o|ar -crs)/', $line, $matches)) {
$linktime = $matches[1];
} else {
print "Unknown output: $line";
}
}

asort($times);
foreach ($times as $file => $time) {
print format_time($time)." compiling $file\n";
}
print format_time($linktime)." linking\n";

function format_time($time) {
return (int)($time / 60) . "'" .
(($time % 60) > 9 ? '':'0'). ($time % 60) . '"';
}
160 changes: 160 additions & 0 deletions bin/valgrind.suppression
@@ -0,0 +1,160 @@
{
Socket-1
Memcheck:Param
write(buf)
fun:__write_nocancel
fun:_IO_file_write@@GLIBC_2.2.5
fun:_IO_do_write@@GLIBC_2.2.5
fun:_IO_file_close_it@@GLIBC_2.2.5
fun:fclose@@GLIBC_2.2.5
fun:RAND_write_file
fun:_ZN14SSLInitializerC1Ev
fun:_Z41__static_initialization_and_destruction_0ii
}
{
Socket-2
Memcheck:Param
socketcall.sendto(msg)
fun:__sendto_nocancel
fun:__check_pf
fun:getaddrinfo
}
{
pthread-1
Memcheck:Leak
fun:calloc
fun:_dl_allocate_tls
fun:pthread_create@@GLIBC_2.2.5
}
{
backtrace-1
Memcheck:Param
msync(start)
obj:/lib64/libpthread-2.3.5.so
fun:access_mem
}

{
FBML-2
Memcheck:Leak
fun:*
fun:*
fun:_ZN10nsHTMLTags11AddRefTableEv
}
{
FBML-3
Memcheck:Leak
fun:*
fun:*
fun:*
fun:_ZN10nsHTMLTags11AddRefTableEv
}
{
FBML-4
Memcheck:Leak
fun:*
fun:*
fun:*
fun:*
fun:_ZN10nsHTMLTags11AddRefTableEv
}
{
FBML-5
Memcheck:Leak
fun:*
fun:*
fun:*
fun:*
fun:*
fun:_ZN10nsHTMLTags11AddRefTableEv
}
{
FBML-6
Memcheck:Leak
fun:*
fun:*
fun:*
fun:*
fun:*
fun:*
fun:_ZN10nsHTMLTags11AddRefTableEv
}
{
FBML-7
Memcheck:Leak
fun:*
fun:*
fun:*
fun:*
fun:*
fun:*
fun:*
fun:_ZN10nsHTMLTags11AddRefTableEv
}
{
FBML-8
Memcheck:Leak
fun:malloc
fun:PL_NewHashTable
fun:_ZN11nsHTMLAttrs11AddRefTableEv
}
{
hdf-1
Memcheck:Leak
fun:calloc
fun:uListInit
fun:nerr_init
fun:hdf_init
}
{
hdf-2
Memcheck:Leak
fun:realloc
fun:check_resize
fun:uListAppend
fun:nerr_register
fun:nerr_init
fun:hdf_init
}
{
SharedMemroyInit-1
Memcheck:Leak
fun:_Znwm
fun:_ZN4HPHP19SharedMemoryManager4InitEib
}
{
inet_ntoa-1
Memcheck:Leak
fun:malloc
fun:inet_ntoa
}

{
pthread-2
Memcheck:Leak
fun:*
fun:*
fun:pthread_once
}
{
boost-1
Memcheck:Leak
fun:*
fun:*
fun:*
obj:*
fun:*
obj:/usr/local/lib/libboost_program_options-gcc40-mt-1_35.so.1.35.0
}
{
mcrypt-1
Memcheck:Overlap
fun:memcpy
fun:mcrypt_dlsym
}
{
zlib-1
Memcheck:Cond
fun:deflate_slow
fun:deflate
}
14 changes: 14 additions & 0 deletions doc/Makefile
@@ -0,0 +1,14 @@

help:
@echo "'make daemon' to start up doc server daemon"
@echo "'make server' to start up doc server"
@echo "'make clobber' to clean up directory"

daemon:
sudo ../src/hphpi/hphpi -m daemon

server:
sudo ../src/hphpi/hphpi -m server

clobber:
@rm -f *~

0 comments on commit b0eb74a

Please sign in to comment.