3 ms·
> Deterministic evaluation. If you execute the same code twice, you will get the same results. In Python, the code won’t be deterministic if it relies on the ou
by djoldman 2y ago
> Deterministic evaluation. If you execute the same code twice, you will get the same results. In Python, the code won’t be deterministic if it relies on the output of functions like “id”, “hash”, if it iterates over a hashtable, if it has race conditions, or if it measures the execution time.
> if it has race conditions
Does this mean starlark cannot generate a race condition? If so, how does threading work?
- laurentlb 2y agoYes. See my other comment - https://news.ycombinator.com/item?id=40595125 https://news.ycombinator.com/item?id=40595125 In short: Evaluating a file has no visible side-effect. The evaluation returns a set of frozen values. These values that can accessed by other threads become immutable.
- vitiral 2y ago> how does threading work? Basic answer: there is no threading, at least not for the user. The build system runs a thread per BUILD file (in bazel). Since the BUILD files are written in starlark and starlark has no threads -- there is no problem.
- laurentlb 2y agoYou can define a value (let's say a dictionary) in a .bzl file and load it from multiple BUILD files. This is safe only because the dictionary becomes immutable before it is shared. Bazel is massively parallel. It has to evaluate a potentially large number of BUILD files; each file can have multiple load statements. You end up with a graph of dependencies and Bazel will evaluate as many files as possible in parallel.