{"id":679,"date":"2022-11-02T19:03:49","date_gmt":"2022-11-02T18:03:49","guid":{"rendered":"http:\/\/blog.magnusmanske.de\/?p=679"},"modified":"2022-11-03T13:25:16","modified_gmt":"2022-11-03T12:25:16","slug":"trust-in-rust","status":"publish","type":"post","link":"http:\/\/magnusmanske.de\/wordpress\/archives\/679","title":{"rendered":"Trust in Rust"},"content":{"rendered":"<p>So Toolforge is <a href=\"https:\/\/wikitech.wikimedia.org\/wiki\/Help:Toolforge\/Kubernetes\">switching<\/a> from grid engine to Kubernetes. This also means that tool owners such as myself need to change their tool background jobs to the new system. <a href=\"http:\/\/mix-n-match.toolforge.org\/\">Mix&#8217;n&#8217;match<\/a> was my tool with the most diverse job setup. But resource constraints and the requirement to &#8220;name&#8221; jobs meant that I couldn&#8217;t just port things one-to-one.<\/p>\n<p>Mix&#8217;n&#8217;match has its own system of jobs that run once or on a regular basis, depend on other jobs finishing before them etc. For the grid engine, I could start a &#8220;generic&#8221; job every few minutes, that would pick up the next job and run it, with plenty of RAM assigned. Kubernetes resource restriction make this impossible. So I had to refactor\/rewrite several jobs, and make them usable as PHP classes, rather than individual scripts to run.<\/p>\n<p>Mix&#8217;n&#8217;match <a href=\"https:\/\/bitbucket.org\/magnusmanske\/mixnmatch\/src\/master\/classes\/\">classes<\/a> have become rather significant in code size, with &gt;10K lines of code. Unsurprisingly, despite my best efforts, jobs got &#8220;stuck&#8221; for no apparent reason, bringing the whole system to a halt. This made especially new Mix&#8217;n&#8217;match catalogs rather unusable, with no automated matches etc.<\/p>\n<p>Rather than fiddling with the intricacies of a hard-to-maintain codebase, I decided to replace the failing job types with <a href=\"https:\/\/github.com\/magnusmanske\/mixnmatch_rs\">new Rust code<\/a>. This is already live for several job types, mainly preliminary match and person name\/date match, and I am adding more. Thanks to the easy multi-threading and async\/await capabilities of Rust, many jobs can run in parallel in a single process. One design feature for the new code is batched processing, so memory requirements are low (&lt;200MB) even for multiple parallel jobs. Also, jobs now keep track of their position in the batch, and can resume if the process is stopped (eg to deploy new code).<\/p>\n<p>I strongly doubt I will replace the entire code base, especially since much of the scraping code involve user-supplied PHP code that gets dynamically included. But safe, fast, and reliable Rust code serves its purpose in this complex tool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So Toolforge is switching from grid engine to Kubernetes. This also means that tool owners such as myself need to change their tool background jobs to the new system. Mix&#8217;n&#8217;match was my tool with the most diverse job setup. But resource constraints and the requirement to &#8220;name&#8221; jobs meant that I couldn&#8217;t just port things [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,9],"tags":[],"class_list":["post-679","post","type-post","status-publish","format-standard","hentry","category-rust","category-wikidata"],"_links":{"self":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/comments?post=679"}],"version-history":[{"count":2,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/679\/revisions"}],"predecessor-version":[{"id":681,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/679\/revisions\/681"}],"wp:attachment":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/media?parent=679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/categories?post=679"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/tags?post=679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}