Tuesday, 2020-10-13

dmsimardsvg: I'm EST, let's chat sometime tomorrow :)00:16
*** etienne has quit IRC03:10
*** dbpiv has joined #ara03:47
*** evrardjp has quit IRC04:33
*** evrardjp has joined #ara04:33
*** TKersten has joined #ara05:40
svgOK, that makes a 6h difference. Your morning is my afternoon.08:34
*** gvincent has quit IRC08:38
*** gvincent has joined #ara08:39
*** etienne has joined #ara13:28
*** TKersten has left #ara14:18
dmsimardsvg: o/ wanna chat ?14:48
svgdmsimard, good timing, yes14:49
dmsimardso just to set the table from a workflow perspective14:51
dmsimardtl;dr of object relationships: https://ara.readthedocs.io/en/latest/api-documentation.html#relationship-between-objects14:51
dmsimardso, for example, creating a play assumes that a playbook has been created and we have the playbook ID because a play is a "child" of a playbook14:52
svgyes, saw that happening in the code14:53
dmsimardsimilarly for tasks (requires playbook id and play id) and results (requires playbook id, play id, task id and host id)14:53
dmsimardI think there are improvement opportunities with the current callback without necessarily doing a full-on "fork"14:54
svgwhat's the difference between playbook-file and task-file?14:54
dmsimardthere's a file for the playbook (say, playbook.yml) and for tasks (say, roles/foo/tasks/main.yml)14:55
svgok, so I wrongly assumed those were all uploaded the same14:56
svgthe starting part where it uploads all the yaml files, is also quite time-consuming.14:56
dmsimardimprovement opportunities I see at a high level: 1) file creation can be threaded/async, by this point the callback has already created the playbook and we don't /need/ to do one file at a time 2) host stats update at the end (v2_playbook_on_stats) can be made threaded/async as well 3) _load_result (14:57
dmsimardhttps://github.com/ansible-community/ara/blob/master/ara/plugins/callback/ara_default.py#L431 ) can probably be made threaded/async as well14:57
dmsimardI have a very naive and largely untested WIP patch implementing threading for _load_result here https://review.opendev.org/#/c/749378/1/ara/plugins/callback/ara_default.py15:02
dmsimardI'm not personally very experienced with threads and async things so very much open to feedback :D15:03
dmsimardcould try adding the file creation in there and see what happens15:03
svgMy Python's a bit rusty, and never worked on doing threaded/async stuff. You have any specifics on how to implement that? (just thinking out load:) IIRC, there's an async version of requests; or would it be an option to implement that directly in ara.client?15:04
svgis that patch available on github? I could test it.15:06
*** openstackgerrit has joined #ara15:11
openstackgerritDavid Moreau Simard proposed recordsansible/ara master: Testing: callback threading  https://review.opendev.org/74937815:11
dmsimardit's not on github but you can check out the patch ^ from the git repository by running: git fetch https://review.opendev.org/recordsansible/ara refs/changes/78/749378/2 && git checkout FETCH_HEAD    (it's at the top right in gerrit under "download")15:12
svggot it15:18
openstackgerritDavid Moreau Simard proposed recordsansible/ara master: Testing: callback threading  https://review.opendev.org/74937815:20
dmsimard^ added host facts to threading cause they can be async too15:20
dmsimardgoing to try with/without the patch with --check on my production and see what it looks like15:23
dmsimardjust from tailing nginx logs, it does feel more async-y15:27
svgfirst comparison (with version 2 of your patch) - 119s wheras before that patch IO got ~156s15:29
svgthose 119s compare with a test I did on a remote vm, which was local to the deployed nodes15:29
dmsimarddid you pull in the host facts patchset too ? -- git fetch https://review.opendev.org/recordsansible/ara refs/changes/78/749378/3 && git checkout FETCH_HEAD15:30
dmsimards/did you/can you/15:31
dmsimardbut hey, shaving ~40s with a relatively simple patch ain't terrible15:31
dmsimarddoing a bit of a larger-scale test here, will report back when I have data15:32
svgI did now, and with patch 3 I get now 123s - basically no difference (but facts are cached in this setup, so I suppose it's normal since the setup module would not run again here)15:32
svgyes, that is definitely a good start15:32
svgbtw, just to be sure, in the virtualenv where I run ansible, I update ara with a simple15:36
svgpip install /home/serge/src/ansible-community/ara15:36
dmsimardyup15:36
svgnormally, instructions say to install ara[server] iirc - I'm not sure what that does differently? the [server] part that is15:36
dmsimard"pip install ara" installs only the Ansible plugins (like the callback) as well as the API clients -- ara[server] does that and also pulls in the API server dependencies15:37
dmsimardthe API server dependencies aren't required if you're not using the offline API client or if you don't plan on running the API server15:38
dmsimardso the base package is very small, actually15:38
svgok15:40
svgshouldn't the self.log.debug statement show with ANSIBLE_DEBUG=1?15:43
svgor they don't show up because it's async in another thread?15:44
svgwhen running my firsdt play, there's around 20 seconds of logging nothing (and IIRC that's where it uploads yaml?)15:45
dmsimardtry with ARA_DEBUG=true and ARA_LOG_LEVEL=DEBUG -- but it might require server dependencies to be installed because of https://github.com/ansible-community/ara/issues/11215:45
dmsimardyeah that's probably the part where the files are uploaded15:45
dmsimardthere's a tradeoff for file uploads -- files are stored uniquely in the database (checksum'd a bit like git) but the callback doesn't know if the file has already been uploaded before uploading it.. the callback /could/ do an API call first to check if the checksum already exists but then it's a second API call to upload the file if it hasn't been15:47
dmsimardcreated yet15:47
svgcan both happen in a separate thread?15:48
dmsimardbut then again, we still need to create a file object so it's part of the playbook -- though the *content* of the file can reference something that already exists15:48
svgyeah, can't seem to make it log, even when installing [server]15:49
dmsimardshould work, looks like this: http://paste.openstack.org/show/798998/15:52
dmsimardgot data with threads, testing without threads now15:56
svgafk for coffee update, brb15:56
dmsimardI got largely the same performance (literally a second of difference) with and without threads :/16:10
svglocal client or http?16:11
dmsimard22 hosts, 74 plays, 2754 results, 398 files in 14m51s16:11
dmsimardhttp to a server between 10 and 20ms away, backed by mysql16:11
dmsimardthere's probably a margin of error (sample count being 1 with and 1 without) but it didn't seem like it made a huge difference -- going to try recording locally with and without and see what happens16:12
svgof course, threading & python might not be the best option here16:13
dmsimarddon't really have a choice for python, it's the interface provided by ansible :p16:15
dmsimardthe rationale for threading is to avoid ansible getting blocked on things that should be non-blocking16:15
dmsimardotherwise ansible waits until the callback hook completes to continue16:15
dmsimardlike, the callback should return asap so ansible can continue and then post whatever it needs to post in the background16:16
dmsimardbtw what version of python and ansible are you testing with ? the runs I did were with ansible 2.7 and python 3.7.916:17
dmsimardI'll try with 2.9 and python 3.8 out of curiosity after I'm done with this current roud16:17
svg3.8.616:21
dmsimardsvg: and what version of Ansible ?16:25
svg2.9.1216:27
dmsimardso I tested against a local API server with the http client and it brought down the duration from 14m51s to 8m30s but there is still no meaningful difference between with or without threads... trying newer version of ansible and python now16:46
svgI'm off for the day. Be sure to let me know if I should test anything. Thank you for looking into this.17:05
dmsimardsure, I'll finish gathering data and put it up in the issue: https://github.com/ansible-community/ara/issues/17117:08
dmsimardI think it'd be worth having a synthetic benchmark playbook so we can easily test different versions of ansible/python -- don't have that kind of flexibility in production (unfortunately)17:10
dmsimardno meaningful difference with 2.9.12 and 3.8.9 either :/17:33
dmsimard2.9.14*17:33
*** sshnaidm is now known as sshnaidm|afk18:24
*** mgariepy has quit IRC23:24
*** mgariepy has joined #ara23:34

Generated by irclog2html.py 2.17.2 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!