PHP performance on Xen domU with mulitple vcpu

Emmanuel Dreyfus <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
Hello

On NetBSD-10.0/amd64 Xen domU with two vcpu PHP's uniqid() performance
is terrible. Theses two tests are on the same dom0, with same NetBSD
versions in the domU:

With a single vcpu:
$ time php -r 'for ($i = 0; $i < 1000000; $i++) uniqid();'
    2.94s real     0.77s user     1.71s system

With two vcpu (note this is only 100 iterations):
$ time php -r 'for ($i = 0; $i < 100; $i++) uniqid();'  
   19.10s real     6.13s user     6.39s system

This php function loops around gettimeofday() until the microsecond
changes:
  do {
    (void)gettimeofday((struct timeval *) &tv, (struct timezone *) NULL);
  } while (tv.tv_sec == prev_tv.tv_sec && tv.tv_usec == prev_tv.tv_usec);
   
This does not look wise, but why is it so slow? ktrace/kdump -R
gives a hint: most gettimeofday() calls last less than a microsecond,
but there are exceptions:
 29062  29062 php83    0.000000000 CALL  __gettimeofday50(0x7f7fffc2f420,0)
 29062  29062 php83    4.820000000 RET   __gettimeofday50 0

Or this:
 29062  29062 php83    0.000000000 CALL  __gettimeofday50(0x7f7fffc2f420,0)
 29062  29062 php83    0.000000000 RET   __gettimeofday50 0
 29062  29062 php83    0.360000000 CALL  __gettimeofday50(0x7f7fffc2f420,0)

Or even this, which I do not understand. 
 29062  29062 php83    0.000000000 CALL  __gettimeofday50(0x7f7fffc2f420,0)
 29062  29062 php83    4.240000000 CALL  __gettimeofday50(0x7f7fffc2f420,0)
 29062  29062 php83    0.000000000 RET   __gettimeofday50 0

Any idea what can explains such numbers?

-- 
Emmanuel Dreyfus
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.