Re: WSGI: creating a new tracker instance for each request?

Thomas Arendsen Hein <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
* Christof Meerwald <[email protected]> [20200205 22:00]:
> 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.

It is significant, but you should really consider serving static
files directly from a generic web server.

I have something like this in the apache config for every tracker:

  Alias /test/@@file/ /srv/roundup/test/html/

> 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?

Yes, it is. I thought that you wanted to use a single/global tracker
instance, not a pool of tracker instances that are reused after a
request has finished.

With a pool everything should be fine.

Regards,

Thomas

-- 
Thomas Arendsen Hein <[email protected]>
OpenPGP key: https://intevation.de/~thomas/thomas_pgp.asc (0xD45DE28FF3A2250C)
Intevation GmbH, Neuer Graben 17, 49074 Osnabrueck - AG Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
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.