Oil 0.8.pre6 - Pure Bash and C++

栏目: IT技术 · 发布时间: 6年前

内容简介:This is the latest version of Oil, a Unix shell that's our upgrade path frombash:Oil version 0.8.pre6 - Source tarballs and documentation.To build and run it, follow the instructions inINSTALL.txt. The wiki has tips on

This is the latest version of Oil, a Unix shell that's our upgrade path frombash:

Oil version 0.8.pre6 - Source tarballs and documentation.

To build and run it, follow the instructions inINSTALL.txt. The wiki has tips on How To Test OSH .

Table of Contents

Patch to run the mal Lisp

Appendix: Selected Metrics

Highlights

(1) Fixes soOSH can run two interpreters written in bash :

  • The kanaka/mal Lisp. I implemented negative slice indices for strings like ${s : -5 : -2} , and submitted a patch upstream. The next section explains the patch.
  • Crestwave's Brainfuck . I fixed a corner case with literal hyphens in globs like ${x//['+-']} , and fixed the semantics of unset a[-1] .

These are pure programs in the sense that they do little I/O. For example, they don't start external processes like common shell scripts. Pure programs are useful to test the speed of the OSH interpreter itself, and because translating I/O to C++ is separate work.

(2) Fixes to run the ShellSpec test framework. For example, shopt -u verbose_errexit makes OSH silent on errexit , like other shells. Feedback on the shell's verbosity is still welcome.

Keep the bug reports coming! The fixes were minor, which is evidence that OSH is maturing.

(3) More progress translating Oil to C++, i.e.oil-native. The last release announcement described this work.

  • The main bundle osh_eval.cc now has ~24K lines of code, up from ~21K .
  • The native interpreter passes 633 spec tests, up from 420 . More details below.

Note that these two strands of work have yet to converge. That is, the Python version of OSH can run Lisp, Brainfuck, and a JSON parser, butoil-native can't yet.

Achieving that may be a good milestone for version 0.8.0 !

Patch to run the mal Lisp

Pull Request 518 on kanaka/mal was merged a couple days ago, and it shows the changes necessary to run mal under OSH. To justify the changes, I linked to sections in the Known Differences doc :

  • Arrays and strings are distinct in OSH, but not in bash.
  • Associative array keys must be quoted, because Parsing Bash is Undecidable . That is, OSH avoids dynamic parsing based on the runtime type of the variable.
  • I extracted a constant regex, as suggested by the bash manual. OSH doesn't have a special lexing mode for the pattern in [[ x =~ $pat ]] .

In my mind, each of these changes improved the program . So this is evidence that OSH is delivering on its claims to be a stricter, saner language, while still running real bash programs .

Related: Oil 0.8.pre4 - The Biggest Shell Programs in the World

Closed Issues

You can also view thefull git log.

#774 eval 'break' doesn't break, 'source return.sh' doesn't return, etc.
#772 Support negative indices in string slices
#769 read -n1 </dev/null succeeds
#768 Unsetting the last element of an array and appending an element behaves differently than bash
#765 Incorrect handling of literal hyphen in patsub
#763 Suppress some errexit messages

What's Next?

I'm very focused on translation to C++. Running these pure bash programs under theoil-native will be a great milestone, and it opens up the possibility of using existing benchmarks in the kanaka/mal repository. How fast does a Lisp run under OSH?

Such benchmarks aren't representative of all shell programs, but they are representative of programs that do a lot of string processing, like autocompletion plugins .

I'd still like more help with testing , bug fixes, and evaluating theOil language. As I mentioned in the last post, Oil is looking more like a language/library for building shells than a shell itself.

If you want it to be more than that, please get involved! Send us a message on Github or Zulip .

Appendix: Selected Metrics

Let's compare this release with last month's0.8.pre5 release.

Lines of Native Code

Most commits in this release were related to C++ translation. Here's evidence of that:

Binary Size

I still have to figure out why the size of osh_eval.opt.stripped differs so much between GCC and Clang.

I also think that the binary is too big, considering the source code size. For example,bash has over 140K lines of code, and it's also about 1 MB in size.

I spent some time withbloaty and it looks like some of the problems are:

  • Exception tables. Oil uses exceptions but bash doesn't.
  • Extra pretty-printing methods generated byASDL. These can be removed with some effort.
  • Global strings that are dynamically allocated. This is a result of the roughmycpp translation, which still needs improvement in many areas.
  • mycpp compiles every Python % format string into a C++ function, which increases the code size. I think Rust programs often notice an analogous issue.
  • Constant data. Oil has about twice as much as bash, maybe due to more detailed error messages.

However, to keep this in context, common shells in Rust or Go are often 10x bigger than Oil and bash. They're more like 10 MB than 1 MB.

But my goal is to sneak theOil language in "for free", so to speak. Making the binary smaller is future work .

Build Speed

For osh_eval.opt.stripped :

  • 0.8.pre5 : 58.2 / 18.2 seconds under GCC. 44.3 / 14.3 seconds under Clang.
  • 0.8.pre6 : 57.5 / 21.2 seconds under GCC. 51.6 / 16.9 seconds under Clang.

Compared to oil.ovm :

  • 0.8.pre5: 50.2 / 18.9 seconds under GCC, 50.9 / 14.6 under Clang
  • 0.8.pre6: 53.0 / 19.6 seconds under GCC, 51.9 / 15.1 under Clang (redundant)

Compared to bash make :

  • 0.8.pre5: 69.1 / 25.5 seconds under GCC
  • 0.8.pre6: 69.4 / 25.7 seconds under GCC (redundant)

Sooil-native compiles about as fast as our slice of CPython, and compiles a bit faster than bash.

Although again, it has fewer lines of code than bash, so I think it should be even faster. I think that getting rid of small translation units ( .cc files) may improve build times. This is also future work .

Test Results

More builtins run in C++, leading to over 200 new tests passing:

(Minor harness bugs: I fixed the inconsistency between 1539 and 1560 that showed up last time, but there's still an inconsistency between 1589, and 1587 below.)

OSH spec tests:

Oil spec tests:

Significant lines of code:

Physical lines:

Benchmarks

These benchmarks are still noisy, but roughly unchanged. The parser benchmark measures C++ code:

The runtime benchmark measures Python code for now:


以上所述就是小编给大家介绍的《Oil 0.8.pre6 - Pure Bash and C++》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

能量分析攻击

能量分析攻击

Stefan Mangard、Elisabeth Oswald、Thomas Popp / 科学出版社 / 2010-8 / 58.00元

《能量分析攻击》可以作为密码学、电子工程、信息安全等专业的教材,也可以供相关专业人员参考。能量分析攻击旨在通过分析密码设备的能量消耗这一物理特性来恢复设备内部的秘密信息,这种基于实现特性的密码分析对广泛应用的各类密码模块的实际安全性造成了严重威胁,《能量分析攻击》是关于能量分析攻击的综合性专著,系统阐述了能量分析攻击的基本原理、技术方法以及防御对策的设计与分析。一起来看看 《能量分析攻击》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器