-
-
Notifications
You must be signed in to change notification settings - Fork 164
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 !!! 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
|
54. BUG:
|
on 52. - builtin localI think it was always like this? But many people have ran into it, so I think we should fix it IIRC my issue was that the word splitting is different when unquoted, e.g. consider
however all shells behave like this IIRC, so it can be OK to do .... not 100% sure this is the issue, but I think we can do something on 53. LHS array parsingYes we are taking a shortcut here -- I think only "word" chars are allowed, like if we can can come up with good algorithm, we could change it Although I think this is the first report I've heard of it on 54. func warningI think this is about the |
Yeah I think It is a bit special, like bash takes |
Re: 52. Regression:
|
I filed #2260 Yes the solution to
( BTW I would like to turn on |
Oh OK I see I'll look into that, I'm not sure if that is new or not |
OK I see that it makes sense when yo'ure doing Maybe we have
|
- For ble.sh compatibility with shopt -u expand_aliases - #1069 - the check worked in shell functions, but was broken in proc/func
BTW I just disabled the check for I will work on |
Thank you. 55. Memory footprint 1.2 GBBy the way, I noticed that the memory footprint becomes extremely large when
(Detailed commands and results)With eval_unsafe_arith $ cat oshrc.source
#!/usr/bin/env osh
HISTFILE=$HOME/.osh_history
shopt -s eval_unsafe_arith
source out/ble.osh --norc
echo "RSS: $(ps -o rss -p $$ | tail -n 1)" >&2
exit
$ ~/.mwg/git/oilshell/oil/bin/osh --rcfile oshrc.source
shopt -s checkwinsize
^~~~~
out/ble.osh:2815: 'shopt' got invalid option 'checkwinsize'
osh warning: The 'RETURN' hook isn't implemented
RSS: 69168
[ble: elapsed 41.452s, CPU 99.8% (self)usr2ms/sys2ms+(child)usr41.109/sys264ms]
$ ~/.mwg/git/oilshell/oil/_bin/cxx-asan/osh --rcfile oshrc.source
shopt -s checkwinsize
^~~~~
out/ble.osh:2815: 'shopt' got invalid option 'checkwinsize'
osh warning: The 'RETURN' hook isn't implemented
RSS: 1207040
[ble: elapsed 6.421s, CPU 99.5% (self)usr1ms/sys3ms+(child)usr5.824/sys570ms] Without eval_unsafe_arith $ cat oshrc.source
#!/usr/bin/env osh
HISTFILE=$HOME/.osh_history
#shopt -s eval_unsafe_arith
source out/ble.osh --norc
echo "RSS: $(ps -o rss -p $$ | tail -n 1)" >&2
exit
$ ~/.mwg/git/oilshell/oil/bin/osh --rcfile oshrc.source
shopt -s checkwinsize
^~~~~
out/ble.osh:2815: 'shopt' got invalid option 'checkwinsize'
osh warning: The 'RETURN' hook isn't implemented
RSS: 69236
[ble: elapsed 41.640s, CPU 99.8% (self)usr3ms/sys1ms+(child)usr41.288/sys273ms]
$ ~/.mwg/git/oilshell/oil/_bin/cxx-asan/osh --rcfile oshrc.source
shopt -s checkwinsize
^~~~~
out/ble.osh:2815: 'shopt' got invalid option 'checkwinsize'
osh warning: The 'RETURN' hook isn't implemented
RSS: 157896
[ble: elapsed 6.364s, CPU 99.6% (self)usr1ms/sys3ms+(child)usr5.845/sys494ms] Bash 5.3-beta $ cat bashrc.source
#!/usr/bin/env bash
HISTFILE=$HOME/.mwg/git/oilshell/oil/tmp/bash_history
source out/ble.sh --norc --bash-debug-version=ignore
echo "RSS: $(ps -o rss -p $$ | tail -n 1)" >&2
exit
$ bash --rcfile bashrc.source
RSS: 14796
[ble: elapsed 178ms, CPU 100.5% (self)usr2ms/sys2ms+(child)usr149ms/sys28ms] The same behavior is observed with Why does this happen? edit: By the way, the C++ version is faster than the Python version, but it is still 36x slower compared to Bash. The memory size is 10x as large as Bash even without |
Oh wow I would have thought the 36x slower is related to the memory usage bug -- i.e. the GC is causing slowness But it seems like it is slower either way? I am also surprised that it is 36x slower. Our microbenchmarks are showing we are close to batch speed, like 0.5x - 2x the speed of bash First thought: I think There was a similar bug I fixed elsewhere recently ... it caused a lot of slowness and memory usage Let me reproduce this a bit later today ... thank you for the report! I suspect this is a bug, not the normal behavior |
It is definitely a bug if the C++ version is using more memory than Python! That is not the case on microbenchmarks https://oils.pub/release/0.27.0/benchmarks.wwz/mycpp-examples/ Although I guess the only benchmark that is really testing memory is "containers" ... but the other ones are testing that there are no leaks I suspect there are GC bugs in both cases ... i.e. if C++ is using more memory than Python, it's because it's not GC'ing as often, in the right places ... |
Oh actually don't test with You should do ASAN adds a lot of memory usage, and it also slows the binary down ! We only use it for testing, to catch memory errors |
There are some very old wiki pages here https://github.com/google/sanitizers/wiki/addresssanitizer https://github.com/google/sanitizers/wiki/AddressSanitizerPerformanceNumbers ASAN definitely uses much more memory, I remember hitting that when testing the GC ... It is not supposed to introduce that much more time overhead, but let's see |
I guess we don't have a clear place to document
|
Ah, yeah. I actually wasn't sure about how I should generate the non-ASAN binary. That's the reason I also tested the behavior with the tarball of 0.27.0 from the release page. As I've already written in #1069 (comment), the same behavior is observed with the release tarball of 0.27.0. It still uses 1.1 GB memory with
Without eval_unsafe_arith $ ~/.mwg/git/oilshell/oil/_bin/cxx-opt/osh --rcfile oshrc.source
shopt -s checkwinsize
^~~~~
out/ble.osh:2815: 'shopt' got invalid option 'checkwinsize'
osh warning: The 'RETURN' hook isn't implemented
[??? no location ???] warning: Invalid start of UTF-8 sequence
[??? no location ???] warning: Invalid start of UTF-8 sequence
RSS: 38244
[ble: elapsed 930ms, CPU 98.9% (self)usr4ms/sys0+(child)usr530ms/sys388ms] With eval_unsafe_arith $ ~/.mwg/git/oilshell/oil/_bin/cxx-opt/osh --rcfile oshrc.source
shopt -s checkwinsize
^~~~~
out/ble.osh:2815: 'shopt' got invalid option 'checkwinsize'
osh warning: The 'RETURN' hook isn't implemented
[??? no location ???] warning: Invalid start of UTF-8 sequence
[??? no location ???] warning: Invalid start of UTF-8 sequence
RSS: 1087120
[ble: elapsed 964ms, CPU 98.9% (self)usr3ms/sys2ms+(child)usr538ms/sys413ms] So, the updated table would be this:
OK, the memory footprint without |
Note: About Bash 5.3-betaTo be precise, for "Bash 5.3-beta" in the previous replies, I use the devel branch of Bash (which is numbered as Bash 5.3-beta yet contains more recent changes compared to the official tarball of Bash 5.3-beta). In addition, memory debugging code is turned on in Bash 5.3-beta, so I turn it off by using the following configure option: $ cd ~/prog/ext/bash-dev
$ ./config.status --config
--with-bash-malloc=no --prefix=/home/murase/.opt/bash/dev 'CFLAGS=-march=native -O3' |
56: BUG:
|
58. BUG:
|
59. Assigning Str to BashArray/BashAssoc removes BashArray/BashAssoc$ bash -c 'ret=(1 2 3); ret=3; declare -p ret'
declare -a ret=([0]="3" [1]="2" [2]="3")
$ osh -c 'ret=(1 2 3); ret=3; declare -p ret'
declare -- ret=3
$ |
Thanks for finding these issues!
|
I will look at Maybe you can add failing cases to And I actually I wonder how many of the above issues are still open. Do we have 50 left or 30 or 20 ?? :-) It would be nice if we can collect the failing test cases (although I know it's sometimes hard to find them all) I also remember |
I keep track of everything needed to run
|
OK thanks for keeping it up to date! Related, this was just reported by a user: On the page, there is a bug for both
I think we should probably do something about this, but I am not sure what exactly yet ... I kinda liked that control flow was static rather than dynamic, i.e. But yeah I guess we probably disagree with every shell there |
I checked the original report of item 22. The command that caused the error was $ osh -c 'builtin declare a=1; declare -p a'
declare -- a=1 On the other hand, as far as I see #1069 (comment), I think what you refer to with " $ bash -c 'x="1 b=2"; builtin declare a=$x; declare -p a b'
declare -- a="1"
declare -- b="2"
$ osh -c 'x="1 b=2"; builtin declare a=$x; declare -p a b'
declare -- a='1 b=2' However, |
I fixed |
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: