IRC logs for #buildstream for Tuesday, 2020-06-30

*** tristan has quit IRC05:06
*** tristan has joined #buildstream06:13
*** ChanServ sets mode: +o tristan06:13
*** benschubert has joined #buildstream07:21
benschuberttristan, juergbi : seems like threading is not yet that fast. Initial benchmarks are twice slower on the debian project.07:22
benschubertThis brings me to a question: How/when would we be happy moving on with the threaded implementation? Should we do like for the yaml refactor, a long lived branch that gradually shapes and improve the code until we are happy?07:22
*** tomaz has joined #buildstream07:28
tristanbenschubert, What are the prospects and hotspots here ? plugins walking dependency trees and such ?07:48
benschuberttristan:07:50
benschubert- the event loop polling too much?? (85s (half of the time)07:50
benschubert- The child-parent split in Job that's wreaking havoc for nothing07:50
benschubertAre the two biggest hotspots I can see07:50
tristanMaybe we need to go the pickle route (also eliminating the `multiprocessing` module but replacing with subprocesses) after all ? what is more promising ?07:50
benschubertI'll be removing the second as soon as all the tests pass and I have a clean commit07:50
benschubertI think the threading route might give us nicer code and handling07:50
tristanHow is parent/child in Job "for nothing" ?07:50
benschubertso I think it's worth continuing for a while (at least until "clean"implementation + a few optis)07:50
tristanAh I guess it would go away with threading ?07:51
benschubertyep exactly07:51
benschubertwith threading it needs to go away (all the communication got hrough a pipe, which is not needed and puts burden on the epoll())07:51
tristanRight, and with subprocessing and pickling of the minimal amount of state, we don't have the issue of worrying about the GIL at all07:52
benschubertso: I think it can be done and we can have as good perf as with multiprocess. However, I think we would need a big MR to have it nice and avoid mistakes :)07:52
benschuberttristan: that's also true07:52
tristanI mean, threading approach assumes there is no justification of in-process python computation07:53
tristanAnd I don't know if I can believe that07:53
tristanIn the long term, it may add unnecessary onus on optimizing the python codepaths07:53
benschubertwe have the computing of cache keys and whether things are cached that takes time07:54
tristanAnd walking the dependency tree07:54
tristanFor implementing stage_artifact() and stage_dependency_artifacts()07:54
tristanAnd for implementing Element.search(), for whatever reason an Element might use that for07:54
benschubertstage_Artifact is mostly buildbox-casd no?07:55
benschubertthrough grpc07:55
tristanRegardless of how fast we can get staging to happen in the casd, the python side needs to be allowed to select which elements get staged where07:55
tristanThat implies a plugin/buildstream side walk anyway07:55
benschuberttrue07:56
tristanThat's an important feature (I should be able to say, I want the 'foo' domain of dependency 'bar.bst', without it's deps, in directory '/baz')07:56
tristanMaybe there will be more I dont know07:56
benschubertthat's not that big computationally though right?07:56
tristanOf course, in C we would be able to construct this lock free, as most of the data model is immutable once processing starts07:57
tristanbut I'm not sure we can in python07:57
tristanI don't know07:57
tristanbenschubert, it could be slow with very wide dependency graphs and lots of workers in RE07:57
benschubertI mean we have two things:07:57
benschubert- creating a subprocess is not free, and with pickling it will take some noticeable time07:57
benschubert- compute-intensive stuff in python07:57
benschubertAnd we need to bet on one ? :)07:57
tristanthe bottleneck would become BuildStream python07:57
WSalmon+11111 <tristan> That's an important feature (I should be able to say, I want the 'foo' domain of dependency 'bar.bst', without it's deps, in directory '/baz')07:57
tristanbenschubert, exactly07:58
WSalmonor everything but the licence domain then have all the licence domains somewere else07:58
tristanbenschubert, that is a hard problem, then again with subprocesses, process launch overhead could be constant with some reuse of pids07:58
benschuberttristan: you mean a jobserver? :) Yeah that would be not too bad either07:59
tristanbenschubert, pickling is problematic, ideally we don't *really* have to pickle, and can use only custom Queues and proper internal IPC apis07:59
tristansimple objects07:59
tristanChild processes can instantiate plugins on demand just to execute tasks, etc07:59
tristanbut that's a lot of internal API craftmanship07:59
benschuberttristan: and if you have a plugin that needs it's whole dep tree? What now?07:59
benschubertthat's a lot of data across08:00
tristanAh right, good point08:00
benschubertSo yeah, I don't think there is a right solution there08:00
tristanWell08:00
tristanI mean08:00
benschubert(Actually, all plugins will want their dep tree, just to be able to stage)08:00
tristanLemme think, we had a concept at some point that there would be an ArtifactElement, e.g. an Element instantiated form an artifact08:01
tristanWhen processing an Element, we should not need the real plugin type instantiated for dependencies should we ? Maybe we do I'm not 100% certain08:01
benschubertWe might? Bazel element? ;)08:01
tristanBut ensuring that a plugin only ever has a minimal Element implementation for it's dependencies when processing, would eliminate any abuses such as issue #3 of bst-plugins-external08:02
tristanWhy would we require an instantiated BazelElement as a dependency ?08:02
tristanWe only need it's output to be staged, the ability to stage it's output08:02
tristanand if the current element is a BazelElement, it should have the capabilities it needs08:03
juergbiit might be interesting to benchmark a more realistic project08:03
benschuberttristan: bazel element might want to look at the sources potentially, but yeah08:04
benschubertjuergbi: agreed08:04
juergbiI'm definitely still leaning towards the threaded approach08:04
tristanbenschubert, right, and that is the kind of abuse in bst-plugins-external we would eliminate08:04
tristanbenschubert, the model would force BazelElement to not cheat, and implement things in core properly instead :D08:04
juergbishould overall be simpler than pickling, imo08:04
benschuberttristan: Not speaking about bst-plugins-external there, but rather the idea of a nice transparent bazel plugin :)08:04
juergbiand I expect that we can get it perform reasonably well08:04
tristanOf course, you need real instantiation of your own sources in order to stage them08:05
benschubertjuergbi: I too lean towards threading, it is not necessarily simpler though, we had assumptions about what would change where, and many break now08:05
tristanAnd any context you get from Source API (directly of via dependencies), needs to be transported via BuildStream core API in some way anyway08:05
tristanBut anyway, this is far down the rabbit hole for a theory :)08:05
juergbiI'll have to look at the changes to get a better idea08:07
benschubertYep. I'll make a "minimal" POC PR as soon as I get all tests pass reliably08:07
juergbithanks08:07
juergbibenschubert: regarding potential merge, the branch completely replaces the subprocess model, right? or could it be feasible/sensible to support both at once in a single branch?08:08
benschubertI don't think supporting both is feasible in an acceptable way08:08
juergbiok08:09
benschubertjuergbi: if you are interested current set of changes is https://gitlab.com/BuildStream/buildstream/-/compare/master...bschubert%2Fno-multiprocessing08:09
benschubertbut there are things that I'll have to remove because they are actually needed08:10
juergbita08:12
*** phildawson has joined #buildstream08:20
*** santi has joined #buildstream08:27
tristanbenschubert, want to try the new tristan/partial-variables ?08:48
tristanIt should be faster now08:48
tristanmaybe not quite there yet08:48
tristanbut faster, would be interested to see your bench08:48
tomazit's possible to use buildstream as build tool, like `kdesrc-build`? (downloads / build / install software locally, using local libraries if they are installed?)08:50
tomazif this works I'll try to use buildstream to replace kdesrc-build besides the flatpak and snap generation.08:50
tristantomaz, no08:56
tomazdang.08:57
tristantomaz, rather the whole point is to be completely isolated from your host system (so developers working on system 'foo' are using exactly the same dependencies and produce exactly the same results, regardless of their host)08:57
tristanin a FOSDEM talk a few years ago, I did do a demonstration of staging debian base system as a dependency in BuildStream, to build a debian package targetting that debian system, and then check it out locally and install it on my host08:59
tristanbecause my host happened to be the same debian version08:59
tristanbut I should be able to build for any debian version on my fedora or any host08:59
tomazyeah,  I just tought it could be  a good way to replace gnome-builder or kdesrc-build if it could target the same system. (for instance, I don't want to rebuild qt when I'm building KDE software that I use locally to test)09:00
tomazmaybe for the distant future. :)09:00
coldtomit may be possible to do local dev by leveraging workspaces and bst shell, but i've never tried it in anger09:03
tristanIt's made for that, but requires that your project.conf declares some shell hints09:05
tristantomaz, https://docs.buildstream.build/master/format_project.html#customizing-the-shell09:08
tristantomaz, https://gitlab.gnome.org/GNOME/gnome-build-meta/-/blob/master/project.conf#L15709:09
tristanFor some reason, freedesktop-sdk still didnt pick up on customizing the shell09:09
tristantomaz, that should work for your basic linux applications which need pulseaudio and graphics acceleration09:10
tristantomaz, Of course, this is supposed to be *better* than developping on your host09:10
tristantomaz, because you can for example, make a build of firefox, and then open a workspace on glibc, and use `bst build --no-strict`09:10
tristanSo you should be able to make minor tweaks to lower level dependency libraries and see how that impacts a higher level graphics application09:11
tomaztristan: aha.09:11
benschuberttristan: let me try :)09:31
tristanbenschubert, iterating over lists, and runtime checks on strings, appear to be a big overhead here; creating C arrays of C strings might be an option, but would probably mean "".join(list) in C and a final call to PyUnicode_DecodeUTF8()09:43
benschuberttristan: cython can convert a c string to python automatically if you return it09:43
tristanAnd ideally it would mean using C strings as dictionary keys09:43
benschubertso not even need to do this :)09:43
tristanOh ?09:43
benschubertyep!09:43
tristanInteresting09:43
tristanI wasn't sure if I was going to take it that far, but could be a good idea09:44
tristanthink I can just use a C string as a dictionary key ? Maybe cast it as <void *> ?09:44
tristanThe strings are interned anyway and the memory they point to is still referenced by the original string objects09:45
benschubertyeah I'm not sure we'd win a lot there09:46
benschubertwonder if we could do this instead:09:46
benschubert```09:46
benschubertcdef object string_temp09:46
benschubertcdef str string09:46
benschubertfor string_temp in my_list:09:46
benschubert    string = <str> string_temp09:46
benschubert```09:46
benschubertlike trick cython to generate code without the checks?09:47
tristanI don't get it09:47
tristanOh09:47
tristanReally ?09:47
tristanWell09:48
benschubertworth a try to see what cython generates?09:48
tristanbenschubert, there are two parts to this, one of them is having to have a list at all09:48
benschubertand that would probably then be optimized by the ocmpiler09:48
tristancdef char **strings = malloc(sizeof(void *) * len(string_list))09:49
tristanand then while loops with indexes into the string array09:49
tristanI think is much faster09:49
benschubertworth a try :)09:50
tristanThere are some parts where sets are useful though, e.g. in the cyclic dependency check queue, we do set_object.update(dependencies)09:51
tristantradeoffs09:51
tristanbenschubert, nice trick09:54
benschubertthe double def? :)09:54
benschubertthis is something that's nowhere in optimizations trick with cython09:58
benschubert/me should start a blog around optimizing python tricks09:58
tristanyeah09:58
tristandouble def works09:59
tristanhelps at least09:59
benschubert:D let me know when you have a branch I should re-benchmark. the previous one is running currently09:59
tristanSo is it that the <typecast> syntax does not incur a runtime typecheck ?09:59
benschubertand if you want to see per-commit you made since master I can also provide09:59
benschubertcorrect09:59
benschubertit's like a c cast09:59
tristanOk, I wouldn't have guessed10:00
benschubertso you tell cyhton, I know what this is, trust me and segfault10:00
benschubertminus the segfault if you are actually right :)10:00
tristanHmmm, method calls are given tuples10:10
tristanat least constructors10:11
tristanI'd have expected function specific structs10:11
Frazerhi, are we still using the old Mailing List to discuss implementing new features, or should we move over to the new one now?10:15
tristanJust move to the new one10:15
tristanFrazer, ^^10:15
Frazerthanks, just to confirm is it this one in the irc topic? https://lists.apache.org/list.html?dev@buildstream.apache.org10:16
tristanYes.10:16
Frazerthanks10:16
tristanbenschubert, do you know if it is worth that same trick on Cython objects you declare ? I guess so ?10:18
tristanfor value_part_object in self._value_parts:10:18
benschubertprobably yes :)10:18
tristan  value_part = <ValuePart> value_part_object10:18
benschubertwe can probably do this and benchmark10:19
tristanI think that I'm at the limit without getting into real arrays10:19
tristanexcept for one thing10:19
tristanhttps://gitlab.com/BuildStream/buildstream/-/blob/tristan/partial-variables/src/buildstream/_variables.pyx#L247 and https://gitlab.com/BuildStream/buildstream/-/blob/tristan/partial-variables/src/buildstream/_variables.pyx#L35110:20
tristanbenschubert, looking at those two `try` lines10:21
tristanbenschubert, I think it's possible to remove one dictionary lookup by making the second try loop responsible for raising UNDEFINED_VARIABLE error10:21
tristanmaybe change _check_circular_references() for something like self._validate(), and have it return a Value10:22
tristanI think if I can do that, I'll be at a point where the cython is as good as it gets, I can save that branch as a reference point, and then do a C string/array exercise after10:23
benschubertthat seems great10:24
benschubertif you separate commits nicely I cna also give you the numbers per commit10:24
benschubertif we want veri fine-grained knowledge10:24
tristanHmmm, maybe I'll start with those two steps10:24
tristanSeparate commit for stringification10:24
tristanDid the ongoing benchmark complete ?10:24
benschubertnot yet10:25
tristanOk I think I'll get some food and come back.10:25
benschubertok!10:25
tristanThe full stack circular reference error provenance thing will be very nice and easy to do, but I'm leaving that pleasure for the end10:26
*** tristan has quit IRC10:29
benschuberttristan: https://gitlab.com/snippets/1991367 current state11:01
*** tristan has joined #buildstream11:10
*** ChanServ sets mode: +o tristan11:10
tristanback... benschubert any half decent news ?11:13
benschuberttristan: https://gitlab.com/snippets/1991367 current state11:13
benschubertso based on the `show` it seemsslightly better11:14
tristangrumble11:16
benschubertmmh interesting, we have roughly 3000 DeprecationWarnings that appeared after running the code under the new scheduler, turns out we have code that raised warning but never caught since running only in the sub processes :/11:39
tristancrap12:41
tristanEvery once and a while, you paint yourself into a corner where cython screws up12:41
tristanLike AttributeError: 'buildstream._variables.Value' object has no attribute 'provenance'12:41
tristanOr you name a list with the same name as something else, and the code generator bails out with an internal stack trace not telling you what really happened12:43
tristanand then you have to go add sys.stderr.write() statements in .tox/.../CythonCodeGeneratorStuff/...12:43
benschubert:/12:52
benschubertthat's one reason why I think we need not to add too much of it, only where it brings a lot :)12:52
tristan:-/12:54
* tristan rewinds and makes tiny incrememtal changes with his patch12:55
tristanAnother, perhaps saner plan, is to create C modules and only bind to them in python12:55
tristanThat way you could perhaps use normal tooling to debug C problems12:55
tristanI guess that would have to start with a faster, C implementation of ruamel.yaml12:56
benschubertruamel.yaml.clib is in cython12:59
benschubertI wanted to have them export their symbols12:59
benschubertbut the project is in an aweful limbo right now12:59
benschubertthe alternative would be to use libyaml directly12:59
benschubertbut then, it might throw off contributions and make buildstream harder to install13:00
tristanis libyaml roundtripping ?13:13
benschubertoh I don't think so13:14
benschubertit's true, we need roundtrip -_-'13:14
tristanI think I've got something closer... need to polish up something commit worthy13:16
tristanOh damn no, that wont work :'(13:19
* tristan knows that he is missing something simple13:29
tristanThe nature of the loop iterating over dependencies should allow for a more rudimentary cyclic dependency, which can be followed by the more loopy reporting code13:30
tristanI need a counter !13:30
tristanWhere does it go13:31
tristanSo basically, I have a set of already traversed variables which are "safe so far", and if they ever intersect with the next level of indirection (variables they refer to), then there is a circular dependency13:32
tristanBut given that you can have "%{foo} and %{foo}", you need to iterate twice on that level before checking for circular refs13:32
tristanor rather you can have %{foo} and %{bar} both use %{baz}, but you will process %{foo} -> %{baz} before encountering %{bar}, without a counter, you don't know that %{bar} doesnt constitute a circular ref13:33
tristanHmmmm13:33
* tristan thinks a walk and a breather will fix it13:34
WSalmonso it turns out that changing the format-version in project.conf of bst-1.4 changes the cache keys of some of the elements in a junction but not all of them!13:49
tristanThat is a bug if it happens13:51
tristanI seem to recall some people had some hare brained ideas, thinking that code should change behavior depending on format-version13:52
tristanit's possible that some madness slipped in while I was away ?13:52
WSalmontristan, should be pretty eash to reproduce, just toggle the version and run show https://gitlab.com/willsalmon/busybox-system/-/commit/cf139114c2c44762d5bfa45de0eb026942a9e4c5#bb485c194054386656d16ab113f2b2fe87c99e3e_6_513:54
WSalmonwaiting 396f85cb20c1f24706a7c9fa2df6ca15ac9320ba404ab465e5d0f112c1c0242a freedesktop-sdk.bst:bootstrap-import.bst vs waiting f253e43b797028413c2cb9ffa82f3573923ae13fc4654db18c47a2a7efc0abe9 freedesktop-sdk.bst:bootstrap-import.bst13:56
WSalmonfetch needed 12c68a5c5a294f373474813406545d25085c16870a4e402d289a1b83b8123a8b freedesktop-sdk.bst:bootstrap/build/base-sdk/image-x86_64.bst vs fetch needed 12c68a5c5a294f373474813406545d25085c16870a4e402d289a1b83b8123a8b freedesktop-sdk.bst:bootstrap/build/base-sdk/image-x86_64.bst13:57
tristanDoesnt appear possible13:58
tristan_project.py on 1.4 branch parses format-version and discards it immediately after performing a check13:58
tristanWSalmon, of course the commit you are referring to also changes a commit sha, which would *definitely* affect cache key13:59
WSalmonyep but i just commited everything needed to fix the cache keys not matching13:59
WSalmoni needed both changes14:00
tristanYeah, but I don't see how format-version can possibly affect cache key in 1.4, it's not stored in context anywhere14:00
tristancode cannot be conditional on it, because it's not there14:00
tristanIf you can provide an isolated test case that proves it, that would be helpful in an issue report14:00
WSalmonummm, i have just toggled them and it dose look like its not the issue, but im really confused as when i updated the junction it didnt seem to change it.. im really confused14:02
*** tristan has quit IRC14:04
*** tomaz has quit IRC17:41
*** santi has quit IRC17:47
*** tristan has joined #buildstream18:04
*** ChanServ sets mode: +o tristan18:04
*** benschubert has quit IRC22:20

Generated by irclog2html.py 2.15.3 by Marius Gedminas - find it at mg.pov.lt!