Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Nov 2015 09:01:57 +0100
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        Kubilay Kocak <koobs@FreeBSD.org>
Cc:        Vladimir Bogrecov <bogrecov@gmail.com>, python@freebsd.org, freebsd-virtualization@freebsd.org
Subject:   Re: Python on FreeBSD is slower than on Linux
Message-ID:  <20151113080157.GA93991@ivaldir.etoilebsd.net>
In-Reply-To: <56453E9D.3040809@FreeBSD.org>
References:  <CANx%2B6QKT00ZC4Gh3UHp7qW6mtKJHLn_NkMD1gegTYgiu=gByXg@mail.gmail.com> <56453E9D.3040809@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Nov 13, 2015 at 12:36:29PM +1100, Kubilay Kocak wrote:
> On 13/11/2015 6:26 AM, Vladimir Bogrecov wrote:
> > Hello,
> >=20
> > I'm developing a little project on Python 3.5. The server's operating
> > system is FreeBSD 10.2. Today I decided to do a little test "just for f=
un"
> > and the result has confused me. I ran the following code
> >=20
> > import random
> > import time
> >=20
> >=20
> > def test_sort(size):
> >     sequence =3D [i for i in range(0, size)]
> >     random.shuffle(sequence)
> >     start =3D time.time()
> >     ordered_sequence =3D sorted(sequence)
> >     print(time.time() - start)
> >=20
> >=20
> > if __name__ =3D=3D '__main__':
> >     test_sort(1000000)
> >=20
> > on FreeBSD 10.2 x64 and on Debian 8 x64. Both computers was the smallest
> > (5$ per month) virtual machines on the Digital Ocean (
> > https://www.digitalocean.com). The average result on the FreeBSD was 1.5
> > sec, on the Debian 1.0 sec. Both machines was created specially for test
> > and had not any customization. Could you help me to understand why pyth=
on
> > is so slower on FreeBSD and may be there are some steps I can perform to
> > speed up the python to work not slower than on Debian.
> >=20
> > I have found in Google the similar question:
> > https://lists.freebsd.org/pipermail/freebsd-python/2012-June/004306.htm=
l so
> > it has an interest not only for me.
> >=20
> > P.S. I really like FreeBSD and I would be happy to solve this issue. If=
 you
> > will have an interest to this issue I can provide SSH access for both
> > machines :)
> >=20
> > Thank You!
>=20
> From FreeBSD Python's (team) point of view, I can't think of anything
> obvious off the top of my head that might cause a ~30% performance issue
> for that workload.
>=20
> Let's get a trace (truss, strace, dtrace) of what's going during the run
> so we can figure out exactly what's happening and in what context.
>=20
> With respect to the testing environment, certain VPS providers throttle
> bursts of CPU pretty heavily, so you'll want to account for/isolate that
> as a potential contributor. Yes both OS's are being run on the same
> provider, but as Alfred said, one OS may be mitigating/working around
> certain virtualisation 'issues'.
>=20
> A full trace of what the test case is doing is definitely the next best
> step I can think of, even before profiling in python, which is probably
> going to provide insight as well.
>=20
> Personally, I'd love to hear about anything that might result in FreeBSD
> always topping the charts for Python performance.
>=20
Well the python devs are aware by themselves of potential performances issu=
es on
FreeBSD (and non linux in general) for example subprocess will try to close=
 fds,
on linux by getting the list of fd from /proc/fd and only close the one the=
y do
not want among the existing ones. on freebsd they do the same if /dev/fd is
mounted meaning without /dev/fd, perfs will suck. They do not use closefrom=
(2)
here because on linux it is not async-signal-safe. one could make them use
closefrom(2) on non linux for example or even more efficiently but freebsd =
only
modify the code to use kinfo_getfile(3).

https://bugs.python.org/issue11284

Another area is the AIO iirc (needs to be double checked) the python uses l=
inux
only things for aio which makes this way slower on FreeBSD.

I'm kind of surprised given the number of pythonic people we have that no o=
ne
has had a look at how python perform on FreeBSD and how things are implemen=
ted
in the python VM to help them.

Bapt

--yrj/dFKFPuw6o+aM
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlZFmPUACgkQ8kTtMUmk6EzWBQCfZhE1Y9Dk68y2EZgyXViTe+ac
cp8An3S8uaHRkqOfP5cCVK5TuYcD1Zug
=66lI
-----END PGP SIGNATURE-----

--yrj/dFKFPuw6o+aM--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20151113080157.GA93991>