Merge lp:~jameinel/u1db/faster-shutdown into lp:u1db
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | John A Meinel | ||||
Proposed branch: | lp:~jameinel/u1db/faster-shutdown | ||||
Merge into: | lp:u1db | ||||
Diff against target: |
109 lines (+45/-6) 2 files modified
u1db/remote/sync_server.py (+24/-0) u1db/tests/test_remote_sync_server.py (+21/-6) |
||||
To merge this branch: | bzr merge lp:~jameinel/u1db/faster-shutdown | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu One hackers | Pending | ||
Review via email: mp+81281@code.launchpad.net |
Description of the change
The test suite has started slowing down a bit. We're now over 2s on my machine (2.3s for my last test).
I did some profiling, and a fair amount of time was spent waiting for the socket server to shut down. This adds a few changes, some of which are a bit ugly.
0) This changes 'make check' to finish in 1.4s down from 2.3s. That's about 40% of the total runtime just cut out.
1) Fix bug #884427, suppress EBADF when the server gets it, rather than printing to stderr/stdout.
2) When we get a shutdown request, do a simple connect and close to the server. The default serve_forever loop does have a customizable timeout, but it is set to 10ms, which seems to add up quite a bit with lots of tests. (currently we have 500 tests, which could be 5s total time.)
The connect-and-close can let us make that faster without turning the server into a busy-wait loop.
It does cause bug #884427 to trigger all the time, though, because now the server code tries to read on a socket that is closed. (sometimes that causes recv() to return the empty string, sometimes it raises EBADF)
3) Hack shutdown() to do this. You have to request the server start shutting down before you do the connection, unfortunately BaseServer uses a private variable, so we have to poke to get access to it.
Its either that or re-implement all the stuff that BaseServer implements to avoid a private attribute.
Unmerged revisions
- 106. By John A Meinel
-
Get faster test shutdown by doing a fake connect.
This requires fixing bug #884427, otherwise we get too much stipple in tests.
Otherwise the SocketServer defaults to the 0.01s timeout time, which adds up when
you have lots of tests.Overall, this patch changes 'make check' from 2.172s down to 1.423s.
On my notebook (i7, intel ssd) this takes it from ~2.8s to ~2.5s.