<html><head></head><body>Hi Tobias,<br>Yes, thank you for all this. We certainly could optimize SWMgr c-tor for large repos. My guess is that the creation of every SWModule for large repos is taking the time. Many impls of SWModule check their data files on c-tor. SWMgr also adds all the filters to each SWModule. All of this could be delayed until use. That's my suspicion for the speed difference. I'll keep this in mind for the next release and have a look at your code for a new method to InstallMgr. Thank you!<br><br>Troy<br><br><div class="gmail_quote">On September 30, 2019 5:13:23 AM MST, contact@tklein.info wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Hi,<br><br>in my Sword backend (node-sword-interface) I've now implemented a new  <br>method isModuleAvailableInRepo:<br><br>bool isModuleAvailableInRepo(std::string moduleName, std::string  <br>repoName="all");<br><br>This method avoids the creation of a SWMgr instance (which is slow for  <br>large repos), but just quickly goes through the .conf files of  <br>sword::InstallSource.localShadow. It then extracts the module ids  <br>(from the first line of each .conf file) and checks whether the given  <br>module id is found in the overall list.<br><br>On my Windows tablet this operation completes in 0.5s, whereas  <br>creation of SWMgr + going through the ModMap takes 5.8s.<br>When executed for a bunch of modules at start-up this change  <br>significantly reduces start-up time of Ezra Project (especially on  <br>slower computers).<br><br>The question remains whether a similar function would make sense  <br>directly in the SWORD engine.<br><br>Best regards,<br>Tobias<br><br>Some links for you to see how this was implemented:<br><br>bool isModuleAvailableInRepo(std::string moduleName, std::string  <br>repoName="all");<br><a href="https://github.com/tobias-klein/node-sword-interface/blob/0.68.0/sword_facade.cpp#L483">https://github.com/tobias-klein/node-sword-interface/blob/0.68.0/sword_facade.cpp#L483</a><br><br>std::vector&lt;std::string&gt; getRepoModuleIds(std::string repoName);<br><a href="https://github.com/tobias-klein/node-sword-interface/blob/0.68.0/sword_facade.cpp#L301">https://github.com/tobias-klein/node-sword-interface/blob/0.68.0/sword_facade.cpp#L301</a><br><br>std::string getModuleIdFromFile(std::string moduleFileName);<br><a href="https://github.com/tobias-klein/node-sword-interface/blob/0.68.0/sword_facade.cpp#L276">https://github.com/tobias-klein/node-sword-interface/blob/0.68.0/sword_facade.cpp#L276</a><br><br>Quoting contact@tklein.info:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> To correct what I wrote earlier ...<br> It seems to be the construction of SWMgr that takes some time, in my<br> case InstallSource::getMgr().<br> The actual iteration over the ModMap is fast.<br><br> Best regards,<br> Tobias<br><br> Quoting contact@tklein.info:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> Hi,<br><br> For now I'm thinking to store this information (Repository of a<br> module) in my own application-level persistence layer.<br><br> However, I'm still wondering about the performance of<br> InstallMgr::getModuleStatus.<br> It's not a big issue on current desktop PCs with fast SSDs. On my<br> Windows tablet, though - it takes ~3s to call this function using<br> the "eBible.org" repository. When calling it for all repositories to<br> gather a complete list of modules, it takes ~6s on my Windows tablet.<br><br> I guess the function walks through all the module files and a long<br> list of files just takes its toll ... Is there a possibility for a<br> performance improvement, though?<br><br> Best regards,<br> Tobias<br><br> Quoting contact@tklein.info:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;"> Hi Troy!<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #fcaf3e; padding-left: 1ex;">I guess InstallMgr could add a line into the .conf when<br>installing: InstalledFrom, but that could be a side load, a local<br>repo, another SWORD application install on a local lan, or one of<br>our remote sources which might not still host the module.<br></blockquote><br> That would be helpful!<br><br> I have 2 use cases:<br><br> 1) Show the repository that a module was installed from as part of<br> other module meta information ("Module About Dialog")<br> 2) Check, which repository a certain module is available from in<br> the context of a "sync feature". In Ezra Project, I'm storing a<br> list of installed modules and this list can be synced between<br> different computers. My expectation as a user is that I want to<br> work with the same set of modules whichever of my computers I'm<br> using. The "sync feature" in Ezra Project basically checks the<br> "list of installed modules" (from Ezra Project synced<br> configuration, synced via Dropbox or similar service) and then<br> automatically installs missing modules if there are any modules in<br> the list that have not been installed locally yet. For this to work<br> efficiently it would be good to know the source repository of a<br> module, because otherwise I have to search all repositories for it<br> (That's what I'm currently doing and the performance is the issue).<br><br> Best regards,<br> Tobias<hr> sword-devel mailing list: sword-devel@crosswire.org<br> <a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br> Instructions to unsubscribe/change your settings at above page<br></blockquote><hr> sword-devel mailing list: sword-devel@crosswire.org<br> <a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br> Instructions to unsubscribe/change your settings at above page<br></blockquote><hr> sword-devel mailing list: sword-devel@crosswire.org<br> <a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br> Instructions to unsubscribe/change your settings at above page<br></blockquote><hr>sword-devel mailing list: sword-devel@crosswire.org<br><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>Instructions to unsubscribe/change your settings at above page<br></pre></blockquote></div><br>-- <br>Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>