<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>A new request with request id 18719 has been created by koha-devel-request@lists.koha-community.org. Short info on the request is : <br><br>Title : Koha-devel Digest, Vol 185, Issue 20<br>Category : <br>Description : <div>Send Koha-devel mailing list submissions to<br>    koha-devel@lists.koha-community.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>    https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>or, via email, send a message with subject or body 'help' to<br>    koha-devel-request@lists.koha-community.org<br><br>You can reach the person managing the list at<br>    koha-devel-owner@lists.koha-community.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Koha-devel digest..."<br><br><br>Today's Topics:<br><br>   1. Re: Optimizing Starman startup (Ere Maijala)<br>   2. Re: Optimizing Starman startup (Julian Maurice)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Wed, 21 Apr 2021 11:31:47 +0300<br>From: Ere Maijala <ere.maijala@helsinki.fi><br>To: dcook@prosentient.com.au, koha-devel@lists.koha-community.org<br>Subject: Re: [Koha-devel] Optimizing Starman startup<br>Message-ID: <dfcc6f89-b121-6dee-58c2-6edf5f4354a9@helsinki.fi><br>Content-Type: text/plain; charset=utf-8; format=flowed<br><br>Awesome, good to hear it's been useful. :) Even better if you can <br>improve it further.<br><br>--Ere<br><br>dcook@prosentient.com.au kirjoitti 21.4.2021 klo 3.46:<br>> Thanks for that optimization. My restart time has gone from 2 minutes 45 seconds to 1 minute 30 seconds. Much better.<br>> <br>> Now I'm going to try the preload and see if I can get it down to 45 seconds or better...<br>> <br>> David Cook<br>> Software Engineer<br>> Prosentient Systems<br>> Suite 7.03<br>> 6a Glen St<br>> Milsons Point NSW 2061<br>> Australia<br>> <br>> Office: 02 9212 0899<br>> Online: 02 8005 0595<br>> <br>> -----Original Message-----<br>> From: Koha-devel <koha-devel-bounces@lists.koha-community.org> On Behalf Of dcook@prosentient.com.au<br>> Sent: Wednesday, 21 April 2021 10:28 AM<br>> To: 'Ere Maijala' <ere.maijala@helsinki.fi>; koha-devel@lists.koha-community.org<br>> Subject: Re: [Koha-devel] Optimizing Starman startup<br>> <br>> Hi Ere,<br>> <br>> Thanks for your reply. 24700 looks much better. I'll look at backporting it locally.<br>> <br>> Although I'm looking at JSON::Validator::OpenAPI::Mojolicious at https://metacpan.org/pod/release/JHTHORSEN/Mojolicious-Plugin-OpenAPI-2.19/lib/JSON/Validator/OpenAPI/Mojolicious.pm and it says "Do not use this module directly. Use Mojolicious::Plugin::OpenAPI instead." I notice that you're using the "bundle" method. Do we really need that there? Why don't we just load the JSON using the JSON module, merge with the plugin spec files, and then pass it to the OpenAPI plugin? Shouldn't the plugin take care of the $ref replacement?<br>> <br>> Hmm... I didn't realize until now that the OpenAPI plugin was doing a validate behind the scenes. That's tricky.<br>> <br>> At a glance, we might be able to pre-load the app into the Starman master process pre-fork. There are warnings about doing that with open database connections, so we'd need to review plack.psgi, but a quick glance suggests it might be OK. (Alternatively, I have wondered about running the REST API as a separate process apart from Starman using hypnotoad. According to https://docs.mojolicious.org/Mojolicious/Guides/Cookbook, Mojo::Server::Prefork preloads the application in the manager/master process, and Hypnotoad is based off that, so that would help.)<br>> <br>> It does seem like changes to the OpenAPI plugin would be needed for caching.<br>> <br>> I'm going to try backporting your change and try pre-loading and see how far that gets me.<br>> <br>> David Cook<br>> Software Engineer<br>> Prosentient Systems<br>> Suite 7.03<br>> 6a Glen St<br>> Milsons Point NSW 2061<br>> Australia<br>> <br>> Office: 02 9212 0899<br>> Online: 02 8005 0595<br>> <br>> -----Original Message-----<br>> From: Koha-devel <koha-devel-bounces@lists.koha-community.org> On Behalf Of Ere Maijala<br>> Sent: Tuesday, 20 April 2021 4:48 PM<br>> To: koha-devel@lists.koha-community.org<br>> Subject: Re: [Koha-devel] Optimizing Starman startup<br>> <br>> Hi,<br>> <br>> I did some work on improving it here:<br>> <br>> https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24700<br>> <br>> That shaved a good bit of time from it, but it's still a heavy operation, and it would make sense to<br>> <br>> 1.) avoid doing it too often<br>> <br>> 2.) cache the results and avoid doing it if results are cached<br>> <br>> If you could address the first one, that'd go a long way. I'm afraid the second one would require changes to the OpenAPI plugin to support caching.<br>> <br>> --Ere<br>> <br>> dcook@prosentient.com.au kirjoitti 20.4.2021 klo 6.15:<br>>> Hi all,<br>>><br>>> Do you despair when you see the following periodically in “top” when a<br>>> starman worker is recreated ?<br>>><br>>>     PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+<br>>> COMMAND<br>>><br>>> 9529 my-koha  20   0  460108 197212  17172 R 100.0  0.4   0:03.41<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> Or the following in top when you install koha-common package or<br>>> restart the koha-common service?<br>>><br>>> 11101 1-koha  20   0  447232 193320  16076 R   10.6  0.4   0:09.09<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> 11168 1-koha  20   0  447240 193264  16056 R   10.6  0.4   0:08.72<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> 11306 2-koha  20   0  447220 193148  16000 R   10.6  0.4   0:08.07<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> 11543 2-koha  20   0  447232 193036  15828 R   10.6  0.4   0:07.07<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> 11784 3-koha  20   0  441536 189664  16172 R   10.6  0.4   0:06.04<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> 11830 3-koha  20   0  439548 187212  15748 R   10.6  0.4   0:05.82<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> 11831 4-koha  20   0  438620 186344  15748 R   10.6  0.4   0:05.81<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> 11853 4-koha  20   0  437680 185672  16000 R   10.6  0.4   0:05.79<br>>> /usr/share/koha/api/v1/app.pl<br>>><br>>> Well, I still have a lot of investigation left to do, but I notice 1<br>>> place that a lot of time taken is here (per worker):<br>>><br>>>       my $validator = JSON::Validator::OpenAPI::Mojolicious->new;<br>>><br>>>       $validator->load_and_validate_schema(<br>>><br>>>           $self->home->rel_file("api/v1/swagger/swagger.json"),<br>>><br>>>           {<br>>><br>>>             allow_invalid_ref  => 1,<br>>><br>>>           }<br>>><br>>>         );<br>>><br>>>       push @{$self->routes->namespaces}, 'Koha::Plugin';<br>>><br>>>       my $spec = $validator->schema->data;<br>>><br>>>       $self->plugin(<br>>><br>>>           'Koha::REST::Plugin::PluginRoutes' => {<br>>><br>>>               spec      => $spec,<br>>><br>>>               validator => $validator<br>>><br>>>           }<br>>><br>>>       );<br>>><br>>>       $self->plugin(<br>>><br>>>           OpenAPI => {<br>>><br>>>               spec  => $spec,<br>>><br>>>               route =><br>>> $self->routes->under('/api/v1')->to('Auth#under'),<br>>><br>>>               allow_invalid_ref =><br>>><br>>>                 1,    # required by our spec because $ref directly<br>>> under<br>>><br>>>                       # Paths-, Parameters-, Definitions- & Info-object<br>>><br>>>                       # is not allowed by the OpenAPI specification.<br>>><br>>>           }<br>>><br>>> );<br>>><br>>> Anyone have ideas for improving this? Do we have to validate the<br>>> schema every time? Can we move the schema validation into a different<br>>> module and preload it into Starman using the -M flag so that it’s done<br>>> 1 time per Starman master instance rather than 1 time per Starman worker instance?<br>>><br>>> I find “/usr/share/koha/api/v1/app.pl” to be the bane of deployments,<br>>> as it puts a massive load on a server, when you have multiple Koha<br>>> instances on the server.<br>>><br>>> David Cook<br>>><br>>> Software Engineer<br>>><br>>> Prosentient Systems<br>>><br>>> Suite 7.03<br>>><br>>> 6a Glen St<br>>><br>>> Milsons Point NSW 2061<br>>><br>>> Australia<br>>><br>>> Office: 02 9212 0899<br>>><br>>> Online: 02 8005 0595<br>>><br>>><br>>> _______________________________________________<br>>> Koha-devel mailing list<br>>> Koha-devel@lists.koha-community.org<br>>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>>> website : https://www.koha-community.org/ git :<br>>> https://git.koha-community.org/ bugs :<br>>> https://bugs.koha-community.org/<br>>><br>> <br>> --<br>> Ere Maijala<br>> Kansalliskirjasto / The National Library of Finland _______________________________________________<br>> Koha-devel mailing list<br>> Koha-devel@lists.koha-community.org<br>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>> website : https://www.koha-community.org/ git : https://git.koha-community.org/ bugs : https://bugs.koha-community.org/<br>> <br>> <br>> _______________________________________________<br>> Koha-devel mailing list<br>> Koha-devel@lists.koha-community.org<br>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>> website : https://www.koha-community.org/ git : https://git.koha-community.org/ bugs : https://bugs.koha-community.org/<br>> <br>> <br><br>-- <br>Ere Maijala<br>Kansalliskirjasto / The National Library of Finland<br><br><br>------------------------------<br><br>Message: 2<br>Date: Wed, 21 Apr 2021 11:00:15 +0200<br>From: Julian Maurice <julian.maurice@biblibre.com><br>To: koha-devel@lists.koha-community.org<br>Subject: Re: [Koha-devel] Optimizing Starman startup<br>Message-ID: <75a89c2a-c7fc-a694-c791-71eb6260d93c@biblibre.com><br>Content-Type: text/plain; charset=utf-8; format=flowed<br><br>Le 21/04/2021 à 09:26, dcook@prosentient.com.au a écrit :<br>> I recall someone (Julian or Kyle?) did some work to make Koha into a <br>> Mojolicious application<br><br>Yes, since 20.11 Koha can be started as a Mojolicious application.<br><br>`hypnotoad bin/intranet`<br><br>But you'll probably need <br>https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26625 in order <br>to configure the listen port/address.<br><br>-- <br>Julian Maurice<br>BibLibre<br><br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>Koha-devel mailing list<br>Koha-devel@lists.koha-community.org<br>https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>website : https://www.koha-community.org/<br>git : https://git.koha-community.org/<br>bugs : https://bugs.koha-community.org/<br><br><br>------------------------------<br><br>End of Koha-devel Digest, Vol 185, Issue 20<br>*******************************************<br></div><br><br>NOTE: You are receiving this mail because, the Requester/Technician wanted you to get notified on this request creation.<br></body></html>