Support for method cache in ExtensionClass

Reported by Yoshinori K. Okuji on 2009-11-21
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope 2
Undecided
Hanno Schlichting

Bug Description

Python 2.6 has method cache optimization:

  http://bugs.python.org/issue1700288

but it is not enabled automatically in extensions:

  http://bugs.python.org/issue1878

So I attach a patch for the support in ExtensionClass. The patch is made against the trunk (r105930). All the unit tests run successfully both before and after my modification.

Yoshinori K. Okuji (okuji) wrote :
Andreas Jung (ajung) wrote :

Applying the patch would require dropping the inofficial Python 2.5 support for Zope 2.12...I think we should not do that right now (perhaps except for the Zope trunk).

Yoshinori K. Okuji (okuji) wrote :

I added (ugly) cpp conditionals (like #ifdef Py_TPFLAGS_HAVE_VERSION_TAG), so it should still work with Python 2.5.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yoshinori K. Okuji wrote:
> I added (ugly) cpp conditionals (like #ifdef
> Py_TPFLAGS_HAVE_VERSION_TAG), so it should still work with Python 2.5.

I am generally +1 on these three patches. Do you have any benchmarks of
speedups on a typical site?

Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 <email address hidden>
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAksH7LwACgkQ+gerLs4ltQ5cpwCfe8bXdkwraNiA/fc7NhHwvin4
4FsAn2CMy4wqeLqfonei0YDSPv5Uzbcg
=sKm6
-----END PGP SIGNATURE-----

Yoshinori K. Okuji (okuji) wrote :
Download full text (6.2 KiB)

I don't know what a typical site is, as every application on top of Zope2 is heavily customized. For now, Zope 2.12 is too new to test complex projects, such as Plone and ERP5, so I made a simple test against the default installation of ZWiki 2:

(original)
$ ab -n 500 http://localhost:8080/zwiki/FrontPage
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests

Server Software: Zope/(2.12.2-dev,
Server Hostname: localhost
Server Port: 8080

Document Path: /zwiki/FrontPage
Document Length: 7679 bytes

Concurrency Level: 1
Time taken for tests: 54.929 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 3983000 bytes
HTML transferred: 3839500 bytes
Requests per second: 9.10 [#/sec] (mean)
Time per request: 109.857 [ms] (mean)
Time per request: 109.857 [ms] (mean, across all concurrent requests)
Transfer rate: 70.81 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 106 110 3.9 109 149
Waiting: 95 109 3.9 108 148
Total: 107 110 3.9 109 149

Percentage of the requests served within a certain time (ms)
  50% 109
  66% 109
  75% 109
  80% 110
  90% 116
  95% 119
  98% 121
  99% 122
 100% 149 (longest request)
$ ab -n 500 'http://localhost:8080/zwiki/FrontPage/searchwiki?expr=this'
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests

Server Software: Zope/(2.12.2-dev,
Server Hostname: localhost
Server Port: 8080

Document Path: /zwiki/FrontPage/searchwiki?expr=this
Document Length: 5642 bytes

Concurrency Level: 1
Time taken for tests: 39.018 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 2920000 bytes
HTML transferred: 2821000 bytes
Requests per second: 12.81 [#/sec] (mean)
Time per request: 78.035 [ms] (mean)
Time per request: 78.035 [ms] (mean, across all concurrent requests)
Transfer rate: 73.08 [Kbytes/sec] received

Connection Times (ms)
              min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 75 78 3.1 77 110
Waiting: 67 77 3.0 76 108
Total: 75 78 3.1 77 110

Percentage of the requests served within a certain time (ms)
  50% 77
  66% 78
  75% 78
  80% 78
  90% 79
  95% ...

Read more...

Changed in zope2:
assignee: nobody → Hanno Schlichting (hannosch)
status: New → Fix Released
Hanno Schlichting (hannosch) wrote :

Just to be complete: I did some more performance tests with this against Plone 4.0a5 with all of Acquisition, ExtensionClass and Persistence patched to support the method cache.

The result is basically the same as noted in one of the comments. There's no actual measurable difference in performance. The claims from the original ticket in the Python tracker promised 5% - 20% speed ups, which don't seem to translate to any real world application code.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers