Re: WSGI: creating a new tracker instance for each request?
Christof Meerwald <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 5 Feb 2020 12:28:32 +0100, Thomas Arendsen Hein wrote: > * Christof Meerwald <[email protected]> [20200205 00:08]: >> just noticed that in wsgi_handler.py we create a new tracker instance >> for each request: >> >> tracker = roundup.instance.open(self.home, not self.debug) >> >> is that really intentional/needed? It seems like a significant >> performance issue to me. > It cost a bit of performance. > > Some quick measurements: > echo -e 'help'|roundup-admin -i . -> 0.280s > echo -e 'display user1'|roundup-admin -i . -> 0.502s > echo -e 'display user1\ndisplay user2'|roundup-admin -i . -> 0.505s > > So I'd say about 0.2 seconds on our roundup server, which is a VM on > a slightly old hardware. Yes, 0.2 seconds for each request (even if it's just a static .css file), seems significant to me. Anyway, I think at the moment I would only allow easier customization, something like https://bitbucket.org/cmeerw/roundup/commits/4f6d7744edd03c4abbcc7b8e890761a1fd25b4d8 so the behaviour can easily be overridden, probably with something like this to reuse tracker instances: @contextmanager def get_tracker(self): try: tracker = self._pool.pop() except IndexError: tracker = roundup.instance.open(self.home, not self.debug) yield tracker self._pool.append(tracker) > The only problem that I see is that with database backends that > allow concurrent access without a global lock, commits of a tracker > state may happen too early. I am confused - is that related to the above? Christof -- http://cmeerw.org sip:cmeerw at cmeerw.org mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org