# VERY DEADLY bad performance (apache/php/mysql) on FreeBSD 8.1 with Apache/2.2.16



## kenorb (Nov 1, 2010)

I could confirm this thread:
http://forums.freebsd.org/showthread.php?t=5511
That using FreeBSD + Apache/2.2.16 + MySQL 5.2 is deadly slow.

At the beginning I've done the test between different machines (which had similar hardware) with the same website/db. Difference: 1,5sec on Linux (Ubuntu), more than 5sec on FreeBSD.
I've tried to copy the same configs php.ini, my.cfg as I could, the same.

Then I've run VM (Linux Ubuntu) within VirtualBox on FreeBSD 8.1-STABLE on the same machine with the same repository files and database.
(doc - FreeBSD 8.1-"STABLE", doc.local.vm - VM (Linux Ubuntu) run on the same machine)
Here are the results:

1st attempt:

```
> ab -v2 http://doc/
Benchmarking doc (be patient)...INFO: POST header == 
---
GET / HTTP/1.0
Host: doc
User-Agent: ApacheBench/2.3
Accept: */*
---
apr_poll: The timeout specified has expired (70007)
```

2nd attempt:

```
> ab -v2 http://doc/
Benchmarking doc (be patient)...INFO: POST header == 
---
GET / HTTP/1.0
Host: doc
User-Agent: ApacheBench/2.3
Accept: */*
---
LOG: header received:
HTTP/1.1 200 OK
Date: Mon, 01 Nov 2010 17:35:14 GMT
Server: Apache/2.2.16 (FreeBSD) mod_ssl/2.2.16 OpenSSL/0.9.8n DAV/2 PHP/5.2.14 with Suhosin-Patch
X-Powered-By: PHP/5.2.14
X-Drupal-Cache: MISS
Last-Modified: Mon, 01 Nov 2010 17:35:14 +0000
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
ETag: "1288632914"
Connection: close
Content-Type: text/html; charset=utf-8

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
(...here is the source...)

..done


Server Software:        Apache/2.2.16
Server Hostname:        doc
Server Port:            80

Document Path:          /
Document Length:        27201 bytes

Concurrency Level:      1
Time taken for tests:   10.097 seconds
Complete requests:      1
Failed requests:        0
Write errors:           0
Total transferred:      27600 bytes
HTML transferred:       27201 bytes
Requests per second:    0.10 [#/sec] (mean)
Time per request:       10096.841 [ms] (mean)
Time per request:       10096.841 [ms] (mean, across all concurrent requests)
Transfer rate:          2.67 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing: 10097 10097   0.0  10097   10097
Waiting:     9577 9577   0.0   9577    9577
Total:      10097 10097   0.0  10097   10097
```


On VM:

```
> ab -v2 http://doc.local.vm/
Benchmarking doc.local.vm (be patient)...INFO: POST header == 
---
GET / HTTP/1.0
Host: doc.local.vm
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 200 OK
Date: Mon, 01 Nov 2010 17:44:43 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch
X-Powered-By: PHP/5.2.6-1+lenny9
X-Drupal-Cache: MISS
Last-Modified: Mon, 01 Nov 2010 17:44:43 +0000
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
ETag: "1288633483"
Vary: Accept-Encoding
Connection: close
Content-Type: text/html; charset=utf-8

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
<head>
...
..done


Server Software:        Apache/2.2.9
Server Hostname:        doc.local.vm
Server Port:            80

Document Path:          /
Document Length:        27215 bytes

Concurrency Level:      1
Time taken for tests:   1.792 seconds
Complete requests:      1
Failed requests:        0
Write errors:           0
Total transferred:      27615 bytes
HTML transferred:       27215 bytes
Requests per second:    0.56 [#/sec] (mean)
Time per request:       1792.438 [ms] (mean)
Time per request:       1792.438 [ms] (mean, across all concurrent requests)
Transfer rate:          15.05 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    1   0.0      1       1
Processing:  1791 1791   0.0   1791    1791
Waiting:     1662 1662   0.0   1662    1662
Total:       1792 1792   0.0   1792    1792
```

*Difference between 10sec and 1,7sec, how it's possible???
*
Usually it's between 5-10sec, on VM usually less than 2sec.

Some environment details:

```
> uname -a && ./vm_run.sh uname -a
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010     root@kenorb:/usr/obj/usr/src/sys/BRO  amd64
Linux dev32-407350 2.6.26-2-686 #1 SMP Mon Jun 21 05:58:44 UTC 2010 i686 GNU/Linux
> ./vm_run.sh cat /etc/php5/apache2/php.ini | diff -suw /dev/stdin /etc/php.ini
Files /dev/stdin and /etc/php.ini are identical
```
No much difference between my.cnf

The only difference are Apache versions:
Apache/2.2.16 and Apache/2.2.9 (faster?!)

Any suggestion how to diagnose that problem and find the source of this issue?
P.S. I can't spend more hours for compiling or re-installing, changing. I already spend few days looking what's going on, why web performance on FreeBSD is so slow.


----------



## kenorb (Nov 1, 2010)

As workaround I installed APC for PHP with following configuration:

```
extension=apc.so
apc.shm_size = 256
apc.stat = 1
;apc.include_once_override = 1
apc.optimization = 1
apc.num_files_hint = 2000
```
It helps a little. 2sec-5sec


----------



## Alt (Nov 1, 2010)

Maybe there is something with apache config (reverse lookups etc)


----------



## r_t_f_m (Nov 1, 2010)

Could you post at least 
	
	



```
dmesg -a
```


```
pciconf -vl
```
and your my.cnf, httpd.conf and php.ini


----------



## gordon@ (Nov 2, 2010)

Can you please confirm that your httpd.conf's are the same?

Also, make sure your DNS resolution is working correctly.

Lastly, you could try using ktrace() to do a system call trace on the web server.


----------



## kenorb (Nov 2, 2010)

My hardware environment amd dmesg:

```
> pciconf -vl | grep -ve subclass
hostb0@pci0:0:0:0:      class=0x060000 card=0x3014103c chip=0x25c08086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000X Chipset Memory Controller Hub'
    class      = bridge
pcib1@pci0:0:2:0:       class=0x060400 card=0x00000000 chip=0x25e28086 rev=0x12 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset PCIe x4 Port 2'
    class      = bridge
pcib6@pci0:0:3:0:       class=0x060400 card=0x00000000 chip=0x25e38086 rev=0x12 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset PCIe x4 Port 3'
    class      = bridge
pcib7@pci0:0:4:0:       class=0x060400 card=0x00000000 chip=0x25fa8086 rev=0x12 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '5000X Chipset PCIe x16 Port 4-7'
    class      = bridge
pcib8@pci0:0:5:0:       class=0x060400 card=0x00000000 chip=0x25e58086 rev=0x12 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset PCIe x4 Port 5'
    class      = bridge
pcib9@pci0:0:6:0:       class=0x060400 card=0x00000000 chip=0x25e68086 rev=0x12 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset PCIe x4 Port 6'
    class      = bridge
pcib10@pci0:0:7:0:      class=0x060400 card=0x00000000 chip=0x25e78086 rev=0x12 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset PCIe x4 Port 7'
    class      = bridge
hostb1@pci0:0:16:0:     class=0x060000 card=0x3014103c chip=0x25f08086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset Error Reporting Registers'
    class      = bridge
hostb2@pci0:0:16:1:     class=0x060000 card=0x3014103c chip=0x25f08086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset Error Reporting Registers'
    class      = bridge
hostb3@pci0:0:16:2:     class=0x060000 card=0x3014103c chip=0x25f08086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset Error Reporting Registers'
    class      = bridge
hostb4@pci0:0:17:0:     class=0x060000 card=0x3014103c chip=0x25f18086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset Reserved Registers'
    class      = bridge
hostb5@pci0:0:19:0:     class=0x060000 card=0x3014103c chip=0x25f38086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset Reserved Registers'
    class      = bridge
hostb6@pci0:0:21:0:     class=0x060000 card=0x3014103c chip=0x25f58086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset FBD Registers'
    class      = bridge
hostb7@pci0:0:22:0:     class=0x060000 card=0x3014103c chip=0x25f68086 rev=0x12 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '5000 Series Chipset FBD Registers'
    class      = bridge
none0@pci0:0:27:0:      class=0x040300 card=0x3014103c chip=0x269a8086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Enterprise Southbridge High Definition Audio'
    class      = multimedia
pcib11@pci0:0:28:0:     class=0x060400 card=0x3014103c chip=0x26908086 rev=0x09 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB/3100 PCIe Root Port 1'
    class      = bridge
uhci0@pci0:0:29:0:      class=0x0c0300 card=0x3014103c chip=0x26888086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB/3100 Chipset USB Universal Host Controller *1'
    class      = serial bus
uhci1@pci0:0:29:1:      class=0x0c0300 card=0x3014103c chip=0x26898086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB/3100 Chipset USB Universal Host Controller *2'
    class      = serial bus
uhci2@pci0:0:29:2:      class=0x0c0300 card=0x3014103c chip=0x268a8086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB/3100 Chipset USB Universal Host Controller *3'
    class      = serial bus
uhci3@pci0:0:29:3:      class=0x0c0300 card=0x3014103c chip=0x268b8086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB/3100 Chipset USB Universal Host Controller *4'
    class      = serial bus
ehci0@pci0:0:29:7:      class=0x0c0320 card=0x3014103c chip=0x268c8086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB/3100 Chipset USB2 Enhanced Host Controller'
    class      = serial bus
pcib12@pci0:0:30:0:     class=0x060401 card=0x3014103c chip=0x244e8086 rev=0xd9 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '82801 Family (ICH2/3/4/5/6/7/8/9,63xxESB) Hub Interface to PCI Bridge'
    class      = bridge
isab0@pci0:0:31:0:      class=0x060100 card=0x3014103c chip=0x26708086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'LPC Interface Controller (631xESB/6321ESB/3100 )'
    class      = bridge
atapci0@pci0:0:31:1:    class=0x01018a card=0x3014103c chip=0x269e8086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB/3100 Ultra ATA Storage Controller'
    class      = mass storage
atapci1@pci0:0:31:2:    class=0x010400 card=0x3014103c chip=0x26828086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Enterprise Southbridge SATA cc=RAID'
    class      = mass storage
pcib2@pci0:16:0:0:      class=0x060400 card=0x3014103c chip=0x35008086 rev=0x01 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB PCIe Upstream Port'
    class      = bridge
pcib5@pci0:16:0:3:      class=0x060400 card=0x3014103c chip=0x350c8086 rev=0x01 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB PCIe to PCI-X Bridge'
    class      = bridge
pcib3@pci0:30:0:0:      class=0x060400 card=0x3014103c chip=0x35108086 rev=0x01 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB PCIe Downstream Port E1'
    class      = bridge
pcib4@pci0:30:1:0:      class=0x060400 card=0x3014103c chip=0x35148086 rev=0x01 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = '631xESB/632xESB PCIe Downstream Port E2'
    class      = bridge
bge0@pci0:31:0:0:       class=0x020000 card=0x3014103c chip=0x160014e4 rev=0x01 hdr=0x00
    vendor     = 'Broadcom Corporation'
    device     = 'NetXtreme BCM5752 Gigabit Ethernet PCI Express (BCM5752)'
    class      = network
vgapci0@pci0:64:0:0:    class=0x030000 card=0x032c10de chip=0x029e10de rev=0xa1 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'NVIDIA Quadro FX 1500 (G71)'
    class      = display
fwohci0@pci0:1:4:0:     class=0x0c0010 card=0x05151799 chip=0x581111c1 rev=0x61 hdr=0x00
    vendor     = 'Lucent/Agere Systems (Was: AT&T MicroElectronics)'
    device     = '1394A PCI PHY/Link Open Host Ctrlr I/F (FW322)'
    class      = serial bus
> dmesg -a | tail
Nov  2 09:58:58 kenorb pulseaudio[27326]: main.c: Failed to initialize daemon.
Nov  2 09:58:58 kenorb pulseaudio[27325]: main.c: Daemon startup failed.
Nov  2 09:59:03 kenorb pulseaudio[27328]: module.c: Failed to load  module "module-detect" (argument: ""): initialization failed.
Nov  2 09:59:03 kenorb pulseaudio[27328]: main.c: Module load failed.
Nov  2 09:59:03 kenorb pulseaudio[27328]: main.c: Failed to initialize daemon.
Nov  2 09:59:03 kenorb pulseaudio[27327]: main.c: Daemon startup failed.
Nov  2 09:59:08 kenorb pulseaudio[27333]: module.c: Failed to load  module "module-detect" (argument: ""): initialization failed.
Nov  2 09:59:08 kenorb pulseaudio[27333]: main.c: Module load failed.
Nov  2 09:59:08 kenorb pulseaudio[27333]: main.c: Failed to initialize daemon.
Nov  2 09:59:08 kenorb pulseaudio[27332]: main.c: Daemon startup failed.
Nothing more.
```


----------



## kenorb (Nov 2, 2010)

Basically structure of Apache between Linux and FreeBSD is completely different, even if it's similar version.

```
> ls
apache2.conf  conf.d  envvars  httpd.conf  mods-available  mods-enabled  ports.conf  sites-available  sites-enabled
> ls /usr/local/etc/apache22/
Includes	envvars.d	extra		httpd.conf	magic		mime.types
```
So it's difficult to compare. Basically config is default as it was.

Compiled Apache modules on VM:

```
> ./vm_run.sh sudo apache2ctl -l 
Compiled in modules:
  core.c
  mod_log_config.c
  mod_logio.c
  prefork.c
  http_core.c
  mod_so.c
Compiled Apache modules on FreeBSD:
> apachectl -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c
```

Ubuntu VM:

```
> ./vm_run.sh /usr/sbin/apache2ctl -V
Server version: Apache/2.2.9 (Debian)
Server built:   Apr 19 2010 19:57:58
Server's Module Magic Number: 20051115:15
Server loaded:  APR 1.2.12, APR-Util 1.2.12
Compiled using: APR 1.2.12, APR-Util 1.2.12
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types" -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
```

FreeBSD

```
> apachectl -V
Server version: Apache/2.2.16 (FreeBSD)
Server built:   Oct 19 2010 12:20:32
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.4.2, APR-Util 1.3.10
Compiled using: APR 1.4.2, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE  -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr/local" -D SUEXEC_BIN="/usr/local/bin/suexec" -D DEFAULT_PIDLOG="/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="/var/run/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="etc/apache22/mime.types" -D SERVER_CONFIG_FILE="etc/apache22/httpd.conf"
```

MORE STATS:


```
1st time on FreeBSD after reboot (APC enabled):

> ab http://doc/
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing: 20478 20478   0.0  20478   20478
Waiting:    20194 20194   0.0  20194   20194
Total:      20478 20478   0.0  20478   20478

1st time after reboot on VM (APC disabled)
> ab http://doc.local.vm/ | tail -n3
Processing:  2052 2052   0.0   2052    2052
Waiting:     1921 1921   0.0   1921    1921
Total:       2053 2053   0.0   2053    2053

2nd time on FreeBSD is ok (because of APC cache):
> time ab http://doc/ | tail -n4
Connect:        0    0   0.0      0       0
Processing:  1010 1010   0.0   1010    1010
Waiting:      876  876   0.0    876     876
Total:       1010 1010   0.0   1010    1010

3rd time on FreeBSD (APC disabled):
> ab http://doc/
Processing:  4458 4458   0.0   4458    4458
Waiting:     4174 4174   0.0   4174    4174
Total:       4458 4458   0.0   4458    4458

---
Running many times on fbsd, it improving to 2,5sec.
> ab http://doc/ | tail -n3
Processing:  2413 2413   0.0   2413    2413
Waiting:     2111 2111   0.0   2111    2111
Total:       2413 2413   0.0   2413    2413

Running on VM still under 2sec:
> ab http://doc.local.vm/ | tail -n3
Processing:  1386 1386   0.0   1386    1386
Waiting:     1275 1275   0.0   1275    1275
Total:       1386 1386   0.0   1386    1386
```


No delay requesting local hosts (included in /etc/hosts)

```
> dig doc | grep Query
;; Query time: 0 msec
> dig doc.local.vm | grep Query
;; Query time: 0 msec
```


----------



## kenorb (Nov 2, 2010)

I've done final test excluding possibility of DNS, MySQL and file cache problem.

Here is my example torture php code:

```
<?php
$then = microtime();
for ($j = 0; $j < pow(2, 16); $j++) {
  for ($i = 0; $i < pow(2, 8); $i++) { $d=rand(1,30)%2; $rchar = $d ? chr(rand(65,90)) : chr(rand(48,57)); } // generate random char
  $hw = "Hello\n World! " . $rchar . $i . $j;
  preg_match('/^[ -~\xA\xD]{0,65535}$/i', $hw . $rchar);
  $pattern = "#^http:\/\/(.*)\.($rchar|$rchar|$rchar)$#i";
  preg_match_all($pattern, $hw . $rchar, $match);
}
$now = microtime();

echo sprintf("Elapsed:  %f\n", $now-$then);
```

Results on FreeBSD:

```
> time php test.php
Elapsed:  -0.492310
162.137u 0.015s 2:42.57 99.7%	3434+837k 0+0io 0pf+0w
```

Results on VM (Ubuntu):

```
vmworker@dev32-407350:src$ time php test.php
Elapsed:  -0.688484
real	0m44.456s
user	0m43.787s
sys	0m0.248s
```

FreeBSD: 2:42min
VM Ubuntu: 0:44min!


----------



## kenorb (Nov 2, 2010)

I've downloaded and compiled nbench from here:
http://www.tux.org/~mayer/linux/bmark.html


FreeBSD:

```
> ./nbench -v

BYTEmark* Native Mode Benchmark ver. 2 (10/95)
Index-split by Andrew D. Balsa (11/97)
Linux/Unix* port by Uwe F. Mayer (12/96,11/97)

============================== ALL STATISTICS ===============================
**Date and time of benchmark run: Tue Nov  2 10:37:56 2010
**Sizeof: char:1 short:2 int:4 long:8 u8:1 u16:2 u32:4 int32:4
**System used for compilation:
**FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010 
**C compiler: gcc version 4.2.1 20070719  [FreeBSD]
**libc: /lib/libc.so.7
**Date of compilation: Tue Nov  2 10:37:02 GMT 2010
=============================================================================

TEST                : Iterations/sec.  : Old Index   : New Index
                    :                  : Pentium 90* : AMD K6/233*
--------------------:------------------:-------------:------------
NUMERIC SORT        :          858.29  :      22.01  :       7.23
  Absolute standard deviation: 32.4055
  Relative standard deviation: 3.77558 %
  Number of runs: 5
  Number of arrays: 388
  Array size: 8111
Done with NUMERIC SORT    

STRING SORT         :          96.041  :      42.91  :       6.64
  Absolute standard deviation: 4.10535
  Relative standard deviation: 4.27457 %
  Number of runs: 6
  Number of arrays: 48
  Array size: 8111
Done with STRING SORT     

BITFIELD            :      3.0989e+08  :      53.16  :      11.10
  Absolute standard deviation: 1.16141e+07
  Relative standard deviation: 3.74783 %
  Number of runs: 5
  Operations array size: 2130
  Bitfield array size: 16384
Done with BITFIELD        

FP EMULATION        :           165.5  :      79.41  :      18.32
  Absolute standard deviation: 6.24404
  Relative standard deviation: 3.77294 %
  Number of runs: 5
  Number of loops: 128
  Array size: 3000
Done with FP EMULATION    

FOURIER             :           16727  :      19.02  :      10.68
  Absolute standard deviation: 653.655
  Relative standard deviation: 3.90775 %
  Number of runs: 5
  Number of coefficients: 3800
Done with FOURIER         

ASSIGNMENT          :          24.382  :      92.78  :      24.06
  Absolute standard deviation: 0.62426
  Relative standard deviation: 2.56034 %
  Number of runs: 5
  Number of arrays: 11
Done with ASSIGNMENT      

IDEA                :          4079.6  :      62.40  :      18.53
  Absolute standard deviation: 186.304
  Relative standard deviation: 4.56676 %
  Number of runs: 6
  Array size: 4000
 Number of loops: 1970
Done with IDEA            

HUFFMAN             :          1648.8  :      45.72  :      14.60
  Absolute standard deviation: 50.4658
  Relative standard deviation: 3.06072 %
  Number of runs: 5
  Array size: 5000
  Number of loops: 770
Done with HUFFMAN         

NEURAL NET          :          26.427  :      42.45  :      17.86
  Absolute standard deviation: 0.812975
  Relative standard deviation: 3.07627 %
  Number of runs: 5
  Number of loops: 14
Done with NEURAL NET      

LU DECOMPOSITION    :          1131.9  :      58.64  :      42.34
  Absolute standard deviation: 43.9596
  Relative standard deviation: 3.88353 %
  Number of runs: 5
  Number of arrays: 511
Done with LU DECOMPOSITION

==========================ORIGINAL BYTEMARK RESULTS==========================
INTEGER INDEX       : 52.195
FLOATING-POINT INDEX: 36.179
Baseline (MSDOS*)   : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0
==============================LINUX DATA BELOW===============================
CPU                 : 
L2 Cache            : 
OS                  : FreeBSD 8.1-STABLE
C compiler          : gcc version 4.2.1 20070719  [FreeBSD]
libc                : /lib/libc.so.7
MEMORY INDEX        : 12.107
INTEGER INDEX       : 13.758
FLOATING-POINT INDEX: 20.066
Baseline (LINUX)    : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38
```

Ubuntu VM:

```
vmworker@dev32-407350:~/Downloads/nbench-byte-2.2.3$ ./nbench -v

BYTEmark* Native Mode Benchmark ver. 2 (10/95)
Index-split by Andrew D. Balsa (11/97)
Linux/Unix* port by Uwe F. Mayer (12/96,11/97)

============================== ALL STATISTICS ===============================
**Date and time of benchmark run: Tue Nov  2 10:49:00 2010
**Sizeof: char:1 short:2 int:4 long:4 u8:1 u16:2 u32:4 int32:4
**System used for compilation:
**Linux dev32-407350 2.6.26-2-686 #1 SMP Mon Jun 21 05:58:44 UTC 2010 i686 GNU/L
**C compiler: gcc version 4.3.2 (Debian 4.3.2-1.1) 
**libc: libc-2.7.so
**Date of compilation: Tue Nov  2 10:36:50 GMT 2010
=============================================================================

TEST                : Iterations/sec.  : Old Index   : New Index
                    :                  : Pentium 90* : AMD K6/233*
--------------------:------------------:-------------:------------
NUMERIC SORT        :          678.47  :      17.40  :       5.71
  Absolute standard deviation: 40.6185
  Relative standard deviation: 5.9868 %
  Number of runs: 9
  Number of arrays: 3
  Array size: 8111
Done with NUMERIC SORT    

STRING SORT         :           101.4  :      45.31  :       7.01
  Absolute standard deviation: 5.07806
  Relative standard deviation: 5.00795 %
  Number of runs: 7
  Number of arrays: 1
  Array size: 8111
Done with STRING SORT     

BITFIELD            :       3.119e+08  :      53.50  :      11.18
  Absolute standard deviation: 1.06074e+07
  Relative standard deviation: 3.40089 %
  Number of runs: 5
  Operations array size: 30
  Bitfield array size: 32768
Done with BITFIELD        

FP EMULATION        :          106.36  :      51.04  :      11.78
  Absolute standard deviation: 2.93053
  Relative standard deviation: 2.75529 %
  Number of runs: 5
  Number of loops: 1
  Array size: 3000
Done with FP EMULATION    

FOURIER             :           18563  :      21.11  :      11.86
  Absolute standard deviation: 730.956
  Relative standard deviation: 3.93776 %
  Number of runs: 5
  Number of coefficients: 100
Done with FOURIER         

ASSIGNMENT          :          23.994  :      91.30  :      23.68
  Absolute standard deviation: 0.934271
  Relative standard deviation: 3.89374 %
  Number of runs: 5
  Number of arrays: 1
Done with ASSIGNMENT      

IDEA                :          4274.1  :      65.37  :      19.41
  Absolute standard deviation: 221.15
  Relative standard deviation: 5.17422 %
  Number of runs: 8
  Array size: 4000
 Number of loops: 100
Done with IDEA            

HUFFMAN             :          1573.7  :      43.64  :      13.94
  Absolute standard deviation: 13.2104
  Relative standard deviation: 0.839443 %
  Number of runs: 5
  Array size: 5000
  Number of loops: 100
Done with HUFFMAN         

NEURAL NET          :          28.958  :      46.52  :      19.57
  Absolute standard deviation: 2.02044
  Relative standard deviation: 6.97708 %
  Number of runs: 11
  Number of loops: 1
Done with NEURAL NET      

LU DECOMPOSITION    :          1081.4  :      56.02  :      40.45
  Absolute standard deviation: 65.8748
  Relative standard deviation: 6.0915 %
  Number of runs: 9
  Number of arrays: 7
Done with LU DECOMPOSITION

==========================ORIGINAL BYTEMARK RESULTS==========================
INTEGER INDEX       : 47.685
FLOATING-POINT INDEX: 38.033
Baseline (MSDOS*)   : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0
==============================LINUX DATA BELOW===============================
CPU                 : GenuineIntel Intel(R) Xeon(R) CPU           E5320  @ 1.86GHz 1843MHz
L2 Cache            : 6144 KB
OS                  : Linux 2.6.26-2-686
C compiler          : gcc version 4.3.2 (Debian 4.3.2-1.1) 
libc                : libc-2.7.so
MEMORY INDEX        : 12.289
INTEGER INDEX       : 11.615
FLOATING-POINT INDEX: 21.094
Baseline (LINUX)    : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38
```

It's also weird, that some of the system operations within VM are faster than on the real machine.
STRING SORT (96int/sec and 101int/sec), BITFIELD, FOURIER, IDEA, NEURAL NET.

Overall:

```
OS                  : FreeBSD 8.1-STABLE
MEMORY INDEX        : 12.107
INTEGER INDEX       : 13.758
FLOATING-POINT INDEX: 20.066
--
OS                  : Linux 2.6.26-2-686
MEMORY INDEX        : 12.289 (better)
INTEGER INDEX       : 11.615
FLOATING-POINT INDEX: 21.094 (better)
```
In real machine, Linux could be much faster. But even on VM, MEMORY INDEX and FLOATING-POINT INDEX are faster.

*It's because I've FreeBSD compiled as amd64? It shouldn't be faster than Linux 32bits?*
Should I then work on Linux installed in VM for better stability and performance?
I've removed Ubuntu and installed specially recent FreeBSD only because of performance, but it's worse than it was. I need performance for my web development work and I can't work if the homepage loads 10-20sec after each change;/ It really works on 32bit Linux faster and there is nothing about wrong configuration as I proven above.
The only think it could be some performance issue/bug on binaries compiled under x64.

BTW: I've compiled kernel without debugging and HAMMER cpu:

```
# makeoptions   DEBUG=-g                # Build kernel with gdb(1) debug symbols
cpu             HAMMER
```
No any other changes. Should I increase something there?
Maybe kern.hz?

My loader.conf:

```
kern.ipc.shmseg=1024
kern.ipc.shmmni=1024
vboxdrv="YES"
vboxnetflt="YES"
vboxnetadp="YES"
sem_load=YES
...
```

make.conf

```
> head -n3 /etc/make.conf 
CPUTYPE?=core2
KERNCONF=BRO
MAKEOPTS="-j8"
```


----------



## quintessence (Nov 9, 2010)

kenorb said:
			
		

> As workaround I installed APC for PHP with following configuration:
> 
> ```
> extension=apc.so
> ...



Hello,

If you installed APC from ports it is version 3.x 
In 3.x version there is no apc.optimization regarding documentation .
Also apc.shm_size uses M/G suffixes , i.e you have to set it as 256M .

Please , post php -v
If you need caching , better to use XCache instead of pecl-APC beta versions ( personal testing on amd64 XCache has better performance than pecl-APC ) .
If you need caching + optimization , you can try eaccelerator ( but have a look at ticket 432 from eaccelerator's ticket system, because there is a bug in the optimizer part in the latest 0.9.6.1 version which is also in ports , in current svn version of eaccelerator bug is fixed ) .


----------



## kenorb (Nov 10, 2010)

quintessence said:
			
		

> If you need caching , better to use XCache instead of pecl-APC beta versions ( personal testing on amd64 XCache has better performance than pecl-APC ) .
> If you need caching + optimization , you can try eaccelerator ( but have a look at ticket 432 from eaccelerator's ticket system, because there is a bug in the optimizer part in the latest 0.9.6.1 version which is also in ports , in current svn version of eaccelerator bug is fixed ) .



Thank you, I've installed xcache.
I installed eaccelerator, added the line:

```
zend_extension="/usr/local/lib/php/20060613-debug/eaccelerator.so"
```
But probably doesn't work.
My php.ini: http://pastebin.com/tT0TjSyW

It looks better for anonymous user:

```
Processing:  1313 1313   0.0   1313    1313
Waiting:     1313 1313   0.0   1313    1313
Total:       1313 1313   0.0   1313    1313
> ab http://doc/ | tail -n3
Processing:  1271 1271   0.0   1271    1271
Waiting:     1270 1270   0.0   1270    1270
Total:       1271 1271   0.0   1271    1271
> ab http://doc/admin | tail -n3
Processing:  1383 1383   0.0   1383    1383
Waiting:     1383 1383   0.0   1383    1383
Total:       1383 1383   0.0   1383    1383
```

BUT not for authenticated users:

```
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin | tail -n3
Processing: 14185 14185   0.0  14185   14185
Waiting:    13645 13645   0.0  13645   13645
Total:      14186 14186   0.0  14186   14186
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin | tail -n3
Processing: 12543 12543   0.0  12543   12543
Waiting:    12092 12092   0.0  12092   12092
Total:      12543 12543   0.0  12543   12543
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
apr_poll: The timeout specified has expired (70007)
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
Processing: 25422 25422   0.0  25422   25422
Waiting:    24858 24858   0.0  24858   24858
Total:      25422 25422   0.0  25422   25422
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
Processing: 26649 26649   0.0  26649   26649
Waiting:    26073 26073   0.0  26073   26073
Total:      26649 26649   0.0  26649   26649
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
Processing: 26347 26347   0.0  26347   26347
Waiting:    25760 25760   0.0  25760   25760
Total:      26347 26347   0.0  26347   26347
```
1,2sec to 25sec

Let's test on VM (VBoxManage startvm Ubuntu):

```
> ab http://doc.local.vm/ | tail -n3
Processing:  2003 2003   0.0   2003    2003
Waiting:     1850 1850   0.0   1850    1850
Total:       2003 2003   0.0   2003    2003
> ab http://doc.local.vm/node | tail -n3
Processing:  1559 1559   0.0   1559    1559
Waiting:     1431 1431   0.0   1431    1431
Total:       1560 1560   0.0   1560    1560
> ab http://doc.local.vm/admin | tail -n3
Processing:  2196 2196   0.0   2196    2196
Waiting:     2076 2076   0.0   2076    2076
Total:       2197 2197   0.0   2197    2197
> ab -H "Cookie: SESSd1f131194554751427f71bdf6d0bee3f=a23f6d387ffa830e38f2178613939152" http://doc.local.vm/ | tail -n3
Processing:  3477 3477   0.0   3477    3477
Waiting:     3270 3270   0.0   3270    3270
Total:       3478 3478   0.0   3478    3478
> ab -H "Cookie: SESSd1f131194554751427f71bdf6d0bee3f=a23f6d387ffa830e38f2178613939152" http://doc.local.vm/admin | tail -n3
Processing:  6471 6471   0.0   6471    6471
Waiting:     6191 6191   0.0   6191    6191
Total:       6471 6471   0.0   6471    6471
> ab -H "Cookie: SESSd1f131194554751427f71bdf6d0bee3f=a23f6d387ffa830e38f2178613939152" http://doc.local.vm/admin/build/modules | tail -n3
Processing: 23964 23964   0.0  23964   23964
Waiting:    23602 23602   0.0  23602   23602
Total:      23965 23965   0.0  23965   23965
> ab -H "Cookie: SESSd1f131194554751427f71bdf6d0bee3f=a23f6d387ffa830e38f2178613939152" http://doc.local.vm/admin/build/modules | tail -n3
Processing: 11351 11351   0.0  11351   11351
Waiting:    11073 11073   0.0  11073   11073
Total:      11352 11352   0.0  11352   11352
> ab -H "Cookie: SESSd1f131194554751427f71bdf6d0bee3f=a23f6d387ffa830e38f2178613939152" http://doc.local.vm/admin/build/modules | tail -n3
Processing: 10260 10260   0.0  10260   10260
Waiting:     9955 9955   0.0   9955    9955
Total:      10261 10261   0.0  10261   10261
> ab -H "Cookie: SESSd1f131194554751427f71bdf6d0bee3f=a23f6d387ffa830e38f2178613939152" http://doc.local.vm/admin/build/modules | tail -n3
Processing: 10686 10686   0.0  10686   10686
Waiting:    10365 10365   0.0  10365   10365
Total:      10687 10687   0.0  10687   10687
```
When repeated test on admin/build/modules, on VM second time is twice faster.


```
> time php test.php
^T load: 1.19  cmd: php 41357 [running] 305.08r 227.15u 77.01s 100% 13548k
^T load: 1.13  cmd: php 41357 [running] 320.23r 238.51u 80.74s 100% 13548k
^T load: 1.34  cmd: php 41357 [running] 385.84r 287.20u 97.48s 100% 13548k
305.416u 103.942s 6:50.59 99.6%	3664+893k 1+0io 0pf+0w
# with disabled xdebug
> time php test.php
Elapsed:  0.723229
164.300u 0.007s 2:44.85 99.6%	3656+891k 0+0io 0pf+0w
vmworker@dev32-407350$ time php test.php 
Elapsed:  -0.149166
real	0m47.299s
user	0m45.911s
sys	0m0.336s
```
2:44min vs. 0:47min
So cache is working fine, but still there is something wrong with speed processing performance.


----------



## kenorb (Nov 10, 2010)

Other performance issue is XDebug, it's really slowing down the website almost by half.
I was using it all the time before, I'd no problem with so much as now.

Without xdebug extension:

```
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
Processing: 16951 16951   0.0  16951   16951
Waiting:    16363 16363   0.0  16363   16363
Total:      16951 16951   0.0  16951   16951
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
Processing: 17278 17278   0.0  17278   17278
Waiting:    16682 16682   0.0  16682   16682
Total:      17278 17278   0.0  17278   17278
```

With xdebug extension:

```
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
Processing: 29793 29793   0.0  29793   29793
Waiting:    29160 29160   0.0  29160   29160
Total:      29793 29793   0.0  29793   29793
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" http://doc/admin/build/modules | tail -n3
Processing: 29955 29955   0.0  29955   29955
Waiting:    29358 29358   0.0  29358   29358
Total:      29955 29955   0.0  29955   29955
```

P.S. I don't have profiler or auto_trace enabled. By default I've always disabled.


----------



## quintessence (Nov 10, 2010)

Hello , 

What do you mean with "doesn't work" about eaccelerator ? 
It seems you have some kind of old installed packages. I see you have PHP 5.2 installed , so it seems you had to try eaccelerator 0.9.5.3 version ( which isn't with broken optimizer ) .

There is a simple example file with settings: /usr/local/share/examples/eaccelerator/eaccelerator.ini that you have to place in /usr/local/etc/php or to edit your php.ini and add eaccelerator settings . Default settings is almost enough for testing , but you can play with it with different values .

Could you please paste the output from:
`$ pkg_info | grep php`


----------



## kenorb (Nov 10, 2010)

quintessence said:
			
		

> Hello ,
> 
> What do you mean with "doesn't work" about eaccelerator ?
> It seems you have some kind of old installed packages. I see you have PHP 5.2 installed , so it seems you had to try eaccelerator 0.9.5.3 version ( which isn't with broken optimizer ) .
> ...




```
> time php test.php
Failed loading /usr/local/lib/php/20060613-debug/eaccelerator.so:  /usr/local/lib/php/20060613-debug/eaccelerator.so: Undefined symbol "_zval_ptr_dtor_wrapper"

> pkg_info | grep php
php-xdebug-2.1.0    Xdebug extension for PHP
php52-5.2.14_1      PHP Scripting Language
php52-ctype-5.2.14_1 The ctype shared extension for php
php52-curl-5.2.14_1 The curl shared extension for php
php52-dom-5.2.14_1  The dom shared extension for php
php52-extensions-1.3_1 A "meta-port" to install PHP extensions
php52-filter-5.2.14_1 The filter shared extension for php
php52-gd-5.2.14_1   The gd shared extension for php
php52-hash-5.2.14_1 The hash shared extension for php
php52-iconv-5.2.14_1 The iconv shared extension for php
php52-json-5.2.14_1 The json shared extension for php
php52-mysql-5.2.14_1 The mysql shared extension for php
php52-pcre-5.2.14_1 The pcre shared extension for php
php52-pdo-5.2.14_1  The pdo shared extension for php
php52-pdo_mysql-5.2.14_1 The pdo_mysql shared extension for php
php52-pdo_sqlite-5.2.14_1 The pdo_sqlite shared extension for php
php52-posix-5.2.14_1 The posix shared extension for php
php52-pspell-5.2.14_1 The pspell shared extension for php
php52-session-5.2.14_1 The session shared extension for php
php52-simplexml-5.2.14_1 The simplexml shared extension for php
php52-spl-5.2.14_1  The spl shared extension for php
php52-sqlite-5.2.14_1 The sqlite shared extension for php
php52-tokenizer-5.2.14_1 The tokenizer shared extension for php
php52-xml-5.2.14_1  The xml shared extension for php
php52-xmlreader-5.2.14_1 The xmlreader shared extension for php
php52-xmlwriter-5.2.14_1 The xmlwriter shared extension for php
php52-zip-5.2.14_1  The zip shared extension for php
php52-zlib-5.2.14_1 The zlib shared extension for php
xcache-1.3.0_1      A fast and stable php opcode cacher
```


----------



## kenorb (Nov 10, 2010)

quintessence said:
			
		

> If you need caching , better to use XCache instead of pecl-APC beta versions ( personal testing on amd64 XCache has better performance than pecl-APC ) .
> If you need caching + optimization , you can try eaccelerator ( but have a look at ticket 432 from eaccelerator's ticket system, because there is a bug in the optimizer part in the latest 0.9.6.1 version which is also in ports , in current svn version of eaccelerator bug is fixed ) .




```
PHP Warning:  Cannot load module 'XCache' because conflicting module 'eAccelerator' is already loaded in Unknown on line 0
```
Sorry, I thought I can use it both.
Now it works.

```
eaccelerator.enable => 1 => 1
```


----------



## kenorb (Nov 10, 2010)

After struggling more than 2 weeks with FreeBSD configuration of my web dev machine, I've very big progress Home page less than 1sec, instead of 20sec!

```
> ab [url]http://doc/[/url] | tail -n3
Processing:   812  812   0.0    812     812
Waiting:      812  812   0.0    812     812
Total:        812  812   0.0    812     812
> ab [url]http://doc/node[/url] | tail -n3
Processing:   792  792   0.0    792     792
Waiting:      792  792   0.0    792     792
Total:        793  793   0.0    793     793
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d" [url]http://doc/[/url] | tail -n3
Processing:   920  920   0.0    920     920
Waiting:      920  920   0.0    920     920
Total:        920  920   0.0    920     920
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d" [url]http://doc/admin/build/modules[/url] | tail -n3
Processing:   975  975   0.0    975     975
Waiting:      975  975   0.0    975     975
Total:        975  975   0.0    975     975
> ab -v4 -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" [url]http://doc/admin/build/modules[/url]
Processing: 17160 17160   0.0  17160   17160
Waiting:    16896 16896   0.0  16896   16896
Total:      17160 17160   0.0  17160   17160
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" [url]http://doc/admin/build/modules[/url] | tail -n3
Processing: 15313 15313   0.0  15313   15313
Waiting:    15010 15010   0.0  15010   15010
Total:      15313 15313   0.0  15313   15313
...
Processing: 12433 12433   0.0  12433   12433
Waiting:    12140 12140   0.0  12140   12140
Total:      12433 12433   0.0  12433   12433
> ab -H "Cookie: SESS9a09b4dfda82e3e665e31092d1c3ec8d=f4402f88ce331d3ab8d0d932e91c423b" [url]http://doc/admin[/url] | tail -n3
Processing:  6400 6400   0.0   6400    6400
Waiting:     6162 6162   0.0   6162    6162
Total:       6400 6400   0.0   6400    6400
```
It's enough to say that this thread is Solved.
Loads between 0,8sec and 17sec.

Summary what I did:
Basically I recompiled everything from scratch (with BUILD_OPTIMIZED=yes and no any debugging):
Recompiled php and all php-extension, Apache, MySQL (downgraded from 5.5 into mysql-server-5.1.x, to be able to use GUI tool).
Uninstalled APC and XCache, and installed eAccelerator instead.
Still using XDebug.

My list of php modules:

```
> php -m | xargs
[url=http://forums.freebsd.org/showthread.php?t=19226]Failed loading /usr/local/lib/php/20060613-debug/eaccelerator.so:  Cannot open "/usr/local/lib/php/20060613-debug/eaccelerator.so"[/URL]
PHP Warning:  Xdebug MUST be loaded as a Zend extension in Unknown on line 0
[PHP Modules] ctype curl date dom eAccelerator filter gd hash iconv json libxml [url=http://forums.freebsd.org/showthread.php?t=19222]memcache[/URL] 
mysql mysqli pcre PDO pdo_mysql pdo_sqlite posix pspell Reflection session SimpleXML SPL 
SQLite standard tokenizer xdebug xml xmlreader xmlwriter zip zlib [Zend Modules] eAccelerator
```
Xdebug doesn't impact on performance, that's great.
Played a little with XProf, to make some performance tests.

Having following lines in make.conf (based on this and this):

```
.if ${.CURDIR:M*/lang/php*}
BUILD_OPTIMIZED=yes
.endif
.if ${.CURDIR:M*/apache22*}
MAKE_ARGS+="-DWITH_MYSQL -DWITHOUT_IPV6 -DWITH_THREADS"
.endif
```

My torture test still slow:

```
> time php test.php 
139.740u 95.690s 3:55.99 99.7%	2885+1673k 0+0io 0pf+0w
```
But anyway, page loads faster.
The rest performance settings will be in php.ini and my.cfg
Thanks for your patience and help, now I could use my UAMP (unix/apache/mysql/php) environment normally with my MySQL client (no alternatives?


----------



## quintessence (Nov 10, 2010)

Hello , 

Cannot open eaccelerator.so ... it cannot be loaded 

Please , check your modules dir is /usr/local/lib/php/20060613-debug/ 
Also there is a warning you *must* load Xdebug as Zend extension 

Btw , I used to test eaccelerator loaded as Zend extension on amd64 for a couple of hours , but I didn't saw any difference as it is loaded as normal extension , so I always load it as in default eaccelerator.ini from examples .

You can test as I suggest you before with default eaccelerator.ini after you load Xdebug as Zend extension . If you place default eaccelerator.ini in /usr/local/etc/php you have to remove line from php.ini which loads eaccelerator as Zend extension .


----------



## DutchDaemon (Nov 17, 2010)

This topic has been closed. Issues as technical or detailed as this should not be discussed in general user-oriented forums like The FreeBSD Forums. These forums are intended for end-user support with installing and/or running FreeBSD and/or applications from the ports tree, not for routinely resolving low-level problems with the operating system or add-on applications. Developers and port maintainers usually do not spend much time here, and we routinely refer technically detailed questions to them.

Consider opening this topic elsewhere, e.g.:

In the case of *the FreeBSD base system*:

1) by posting to one of the relevant mailing lists
2) by opening a bug report

In the case of *ported applications*:

1) by contacting the port maintainer (run make maintainer in the port directory)
2) by opening a bug report


----------

