-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run ble.sh (2022) #1069
Comments
Just ran it again: http://travis-ci.oilshell.org/github-jobs/2022-01-07__05-34-01.wwz/_tmp/soil/logs/ble-test.txt
|
Hm from #762 we were at
Hm maybe we're on the wrong branch? I think there is a branch that is maybe not maintained But still there is a regression @akinomyoga Can you tell me if this https://github.com/oilshell/oil/blob/master/test/ble.sh#L18 I revived this build we did in 2020! I haven't touched it since then but it still kinda works. Just curious if there have been any changes |
Also continuing the thread from #257 , here is a page I drafted about help I would like to raise money to pay for https://github.com/oilshell/oil/wiki/Compiler-Engineer-Job Although now that I read it over it looks too detailed. The short summary is: Write a 10K line Python compiler in Python, and 10K line C++ runtime, and get a free shell :-) (and get paid, although I'm still working on raising the funds) I think this is a very fun project for the right person. It's fun but I think will take full time effort. (And remember it is over half done, but the code is messy because of the way we used MyPy, and probably needs a rewrite) I made this web page with line counts, although for some reason it makes things look bigger than they are ... it is a small amount of code, at least compared with GNU bash itself: https://www.oilshell.org/release/0.9.6/pub/metrics.wwz/line-counts/for-translation.html |
I don't remember the details after two years, but basically
I think there can be several approaches to 1 and 2:
Hmm, OK. If we use ble.sh with the Python osh/oil, it might be a good demonstration of osh/oil, but I have to say that the response is too slow to be used as a line editor of daily use. Also, in my vague memory, the footprint of osh with ble.sh was of the order of a few or several hundred megabytes (but it might be different). |
Not maintained, meaning that it doesn't track the changes in the latest master. I think the |
Ah OK thanks for the info. Off the top of my head I think we have I don't think
There is a rough idea of memory usage here: https://www.oilshell.org/release/0.9.6/benchmarks.wwz/mycpp-examples/ e.g. on small examples the Python version uses 7.3 MB while the C++ version uses 3.4 MB. That seems like it's going in the right direction but probably not good enough. (hence why I am looking for help!) How much memory does ble.sh use when run under bash? I agree |
Hm actually now I realize a good memory benchmark would be I suspect it will be a lot higher because Oil has a very detailed representation of the code, and it does eager parsing inside |
Oh, OK, I have now confirmed that. I think I need to update the wiki page Running ble.sh With Oil · oilshell/oil Wiki.
That's nice to hear.
Yeah, that is also one option. I remember that the source of the functions in JavaScript which is obtained by
Actually, it depends on the Bash version. The memory use of ble.sh is larger for recent Bash. For example, the latest ble.sh uses about 50 MB in the latest Bash. Actually, this is one of the recent problems of ble.sh.
I have tried it.
In the previous reply, I wrote a few hundred megabytes used by osh in my memory, but that was wrong. (Actually, I have slightly modified |
Great, thank you for trying it! This is very helpful. I filed #1070 to automate this -- it will help with the C++ translation, which is the focus of the upcoming year. Actually it's better than I thought -- Python objects are very large:
So the translation to C++ should reduce that by a lot -- a pointer will be 8 bytes, an integer will be 4 bytes, etc. It's statically laid out rather than dynamic with a I think we can get within 2x of bash on the first try, and then optimize it with enough effort. |
Also Oil has something like the JavaScript feature you're talking about. It uses http://www.oilshell.org/blog/2021/09/multiline.html#reminder-doc-comments-with This works with traditional shell functions as well as Oil
You could use these in ble.sh right now because the syntax is compatible with bash. That is, you can use Oil as a documentation extractor if that proves useful. Although now I see you use a https://github.com/akinomyoga/ble.sh/blob/master/lib/core-complete.sh What kind of metadata would you want to put in there? Anyway, I welcome more feedback on Oil. I hope it will converge with ble.sh at some point, and we both agree C++ translation is important. Also, I realized that This is #967 Also I remember you know quite a bit about C++ too, and I think the translation task could be pretty fun in that respect. Here is a listing of the generated code: https://www.oilshell.org/release/0.9.6/pub/metrics.wwz/line-counts/oil-cpp.txt
And this already passes 1131 out of 1900 spec tests! It can run those fibonacci and bubble_sort examples, etc. I think it should be able to Actually what is the reason for the (I didn't look at why the unit test numbers went down, but I was a little surprised by that, since I don't know of any OSH regressions. It is very highly tested. I may dig into it more) |
Thinking about the doc comments a little more, I think it wouldn't be that hard to support
The strings are encoded in QSN format, so this can be parsed and used by a doc generator. I'm not sure if this is important for ble.sh, but just mentioning it in case. I guess it is probably not that hard to make a custom parser but I think it is nice if the language can do it for you. |
Oh,
I usually put 1) what arguments the shell function accepts, 2) what variable the shell function accesses through the dynamic scoping, and 3) the description of exit status, along with the details of each data format, etc. I actually don't think the short description of the function is so important because I feel that that information should be usually represented by the function name,
"n/a" for +module+activate: Yes, there are still some syntaxes that OSH fails to parse in modules. It's not a regression because I was actually aware back then. These were related to or relying on the module for the syntax analysis that is designed for Bash syntax but not for Osh syntax, so I didn't make much effort to find out the causes and to report it here at that time. "n/a" for ble.sh (2022-01): Just because I haven't tried it yet. First of all, ble.sh cannot be loaded in osh without modifications and there were already many modifications to the
I'm not sure what you mean by regression, but any behavioral changes could affect the results. It's not surprising to me that the changes to osh behavior affect the result of tests.
I actually don't use the document comments from inside the script. Maybe I do some static analysis in the future, but I don't think I will do it by the script but would rather write a program in C++ or other languages. |
ble.sh (2022-01) for oshI have finished the rebasing of the branch
Test resultsTest summary in osh-0.9.6. The full log is here: blesh-test.txt [ Note: this text file contains escape sequences for color codes, so I recommend opening it with
For comparison, this is the expected result generated by Bash:
|
Great thank you for testing it! It's good to see some progress with 985/1193 vs. 895/1011. I'm not sure what happened with 90 MB doesn't seem too bad considering how large the Python objects are. I'm looking forward to testing out Although I also wonder what method you use to get 3.8 MB "plain" for bash 4.3 ? I'm trying to compare plain bash vs. OSH here too. The way I do it is https://github.com/oilshell/oil/blob/master/benchmarks/vm-baseline.sh#L39 Actually bash's peak seems to be higher than OSH which seems wrong because of the Python issue, but I can't see any bug in the benchmark. (This chart doesn't include https://www.oilshell.org/release/0.9.0/benchmarks.wwz/vm-baseline/ This seems reasonable but maybe there is a better way, and a way to make our measurements more consistent. |
Wow, I found the bug in the benchmark !!! https://github.com/oilshell/benchmark-data/tree/master/vm-baseline/spring.2021-12-29__22-16-29 Notice that the process name is actually (Shells do this to varying degrees; I noticed yash is very optimal in this regard) If I run this, it shows that bash creates 3 different processes for that command.
But I you run that with OK I will fix this ... |
Yup in this old release before OSH was optimized, you can see the memory is correctly measured ... (but zsh is still incorrectly measured, since it is optimized) https://www.oilshell.org/release/0.7.0/benchmarks.wwz/vm-baseline/ Compared to the latest one: https://www.oilshell.org/release/0.9.6/benchmarks.wwz/vm-baseline/ |
38. Regression
|
Fixes issue tickled by ble.sh, mentioned in #1069.
Ah thank you, I just fixed that bug! It was introduced during a refactoring. Thanks for your help -- I think having the ble.sh tests run will be useful, and the memory benchmark as mentioned. I'm working on publicizing this "compiler engineer" position to accelerate the project: https://github.com/oilshell/oil/wiki/Compiler-Engineer-Job I spent a lot of time debugging the C++ runtime, and it's about half done, but needs more hands on it ! |
Just making a note about running ble tests in our CI:
It seems like there is a problem with our container; it doesn't like accessing
On my host machine, it's not in the
|
ble/function#suppress-stderr:ble/util/is-stdin-ready
^~~~~~~~~~~~
[ eval word at line 4022 of 'out/ble.osh' ]:1: 'ble/function#suppress-stderr:ble/util/is-stdin-ready' not found This error is caused by exec 30>&- 30< /dev/tty
^~~
[ eval word at line 4403 of 'out/ble.osh' ]:1: Can't open '/dev/tty': No such device or address
Error closing descriptor 30: Bad file descriptor
osh I/O error: Bad file descriptor
I don't think the permission of
|
Now the tests run to completion. [section] ble/main: 16/19 (3 fail, 0 crash, 0 skip) [section] ble/util: 999/1193 (194 fail, 0 crash, 0 skip) [section] ble/canvas/trace (relative:confine:measure-bbox): 0/5 (5 fail, 0 crash, 12 skip) [section] ble/canvas/trace (cfuncs): 0/0 (0 fail, 0 crash, 18 skip) [section] ble/decode: 33/33 (0 fail, 0 crash, -1 skip) Part of #1069.
Oh great point, thank you! I am just starting to use Docker/podman. With the
|
I decided to assign a sequential number continuing from #653 (I renumbered the above regression for 39. NYI:
|
40. BUG:
|
41. BUG: [[ -c /dev/null ]] fails in C++ versionAs I have already written in the Zulip conversation at the following link, it fails with an assertion error. $ osh -c '[[ -c /dev/zero ]]'
osh: cpp/osh.cc:129: bool bool_stat::DoUnaryOp(id_kind_asdl::Id_t, Str*): Assertion `false' failed. With some workarounds, I could run the tests. I attach the full log: test-util.txt. The test summary reads
The expected results with Bash are as follows. Some of the tests for
|
42. BUG:
|
OK wow, this is very useful, thanks for all the testing! I will file separate bugs for many of these and post updates here On performance, it doesn't match what we're seeing, but I guess it might not be surprising if ble.sh hits some pathological case in OSH One issue is that we don't have real dict lookups yet -- dictionaries do linear searches. These are dictionaries at the OSH INTERPRETER level, not just bash assoc arrays It seems like we should be able to handle the equivalent of a 21 MB heap in bash with our GC, so something is wrong Here are some benchmarks: On I/O bound workloads like https://www.oilshell.org/release/0.15.0/benchmarks.wwz/osh-runtime/ On CPU bound workloads we're seeing 2-3x slower, e.g. Fibonacci runs in 109ms with bash, and 234 ms with OSH https://www.oilshell.org/release/0.15.0/benchmarks.wwz/compute/ So I don't know why there is a big discrepancy, but we have many tools for profiling, so we can certainly figure it out I'll follow up on each of these issues, any help is appreciated :) Again this is very useful, thank you! |
FYI I ran ble.sh with OSH at head, with some optimizations I mentioned, following the instructions on the wiki https://github.com/oilshell/oil/wiki/Running-ble.sh-With-Oil#try-read--e-by-blesh And I get the 33/33 decode successes, although many other failures. Let me try with the other commands you posted
|
Actually I ran this same command
in 36 seconds? This is with HEAD, where I did optimize something. but I highly doubt that Oils 0.15.0 was that much slower? Let me try it and see One suspicion I had was that the tests were sometimes running the Python version of OSH? Sometimes if you
|
Ah, this could be the reason. If I correctly understand the above, are they the dictionaries for the variable namespace and the function namespace? Then, ble.sh defines about 5000 global variables and 3000 functions. If the name lookup for the variables and functions are performed by the linear search, it would extremely slow down the execution. For the footprint, I initially thought about the memory use of the runtime objects, but another possibility is the size of the program on the memory. I think you were talking about something called lossless syntax tree. If that retains the full information about the original source code, it might also require a larger footprint.
Ah, sorry, I haven't yet pushed the patched version. I'll push it. |
Oh yes I forgot that we can't run the tests with 0.15.0
In any case I hope you can get all the runs in ~36 seconds or so now, regardless of what happened in the past :) I am not sure what happened
I mentioned on Zulip how to get a tarball from every commit This is a good one: http://travis-ci.oilshell.org/github-jobs/4014/ http://travis-ci.oilshell.org/github-jobs/4014/cpp-small.wwz/_release/oils-for-unix.tar |
I have now force-pushed the patched version of ble.sh ( |
OK I ran that one in 1 minute and 3 seconds ? Maybe we can use Zulip only, because I don't want to "drown out" all the great issues you posted above https://oilshell.zulipchat.com/#narrow/stream/121539-oil-dev/topic/ble.2Esh.20Performance So we can use this thread for bugs, and then use Zulip for figuring out why we are getting a performance difference I couldn't get the same command to run with bash, it will be helpful if I can run the |
Continuation of #653
At the very least we should see if we can reproduce the results of running ble.sh unit tests in #762 on our new container-based continuous build
I'm also curious what functionality is missing
The text was updated successfully, but these errors were encountered: