## Implementation Summary * Only keys and only values of hash table are contiguous to eliminate structure padding. * Change upper limit of `iv_tbl` size to `UINT16_MAX` (it seems to be acceptable in mruby because the total number of classes/modules immediately after starting Redmine is 20,000 or less). * `iv_tbl*` point hash buckets directly. ## Benchmark Summary Only the results of typical situations on 64-bit Word-boxing are present here. For more detailed information, including consideration, see below report (although most of the body is written in Japanese). * https://shuujii.github.io/mruby-iv-benchmark ### Memory Usage Lower value is better. | iv_tbl Size | Baseline | New | Factor | |------------:|---------------:|---------------:|-----------:| | 4 | 88B | 52B | 0.59091x | | 30 | 536B | 388B | 0.72388x | | 100 | 2072B | 1540B | 0.74324x | | 200 | 4120B | 3076B | 0.74660x | Although not mentioned in the above report, the memory usage of `mrbtest` (full-core gembox) is as follows in the result by Valgrind. * Baseline: 108,086 allocs, 16,313,122 bytes allocated * New: 94,273 allocs, 15,875,214 bytes allocated ### Performance Higher value is better. #### `mrb_obj_iv_set` | iv_tbl Size | Baseline | New | Factor | |------------:|---------------:|---------------:|-----------:| | 4 | 88.63003M i/s | 92.60611M i/s | 1.04486x | | 30 | 32.97066M i/s | 25.25095M i/s | 0.76586x | | 100 | 16.33224M i/s | 22.74998M i/s | 1.39295x | | 200 | 5.64484M i/s | 6.79949M i/s | 1.20455x | #### `mrb_obj_iv_get` | iv_tbl Size | Baseline | New | Factor | |------------:|---------------:|---------------:|-----------:| | 4 | 217.58391M i/s | 237.59912M i/s | 1.09199x | | 30 | 139.56195M i/s | 160.49470M i/s | 1.14999x | | 100 | 143.09716M i/s | 190.95047M i/s | 1.33441x | | 200 | 89.75291M i/s | 134.78717M i/s | 1.50176x | ### Binary Size Lower value is better. | File | Baseline | New | Factor | |:------------|---------------:|---------------:|-----------:| | mruby | 697,520B | 697,520B | 1.00000x | | libmruby.a | 1,046,570B | 1,046,682B | 0.99989x | ## Note The address in `struct RObject::iv` may change after initialization because `iv_tbl*` points directly to hash buckets. Therefore, the address cannot be copied and shared when include/prepend. So, when sharing `iv_tbl`, refer to it via the sharing source class. As a result, the following bug have also been fixed. * [An `iv_tbl` is not shared when a class includes or prepends an empty module](https://gist.github.com/shuujii/0ac23fa24b0c55b2c602b534d81e4a95)
What is mruby
mruby is the lightweight implementation of the Ruby language complying to (part of) the ISO standard. Its syntax is Ruby 2.x compatible.
mruby can be linked and embedded within your application. We provide the interpreter program "mruby" and the interactive mruby shell "mirb" as examples. You can also compile Ruby programs into compiled byte code using the mruby compiler "mrbc". All those tools reside in the "bin" directory. "mrbc" is also able to generate compiled byte code in a C source file, see the "mrbtest" program under the "test" directory for an example.
This achievement was sponsored by the Regional Innovation Creation R&D Programs of the Ministry of Economy, Trade and Industry of Japan.
How to get mruby
The preview version 3.0.0 of mruby can be downloaded via the following URL: https://github.com/mruby/mruby/archive/3.0.0-preview.zip
The stable version 2.1.2 of mruby can be downloaded via the following URL: https://github.com/mruby/mruby/archive/2.1.2.zip
The latest development version of mruby can be downloaded via the following URL: https://github.com/mruby/mruby/zipball/master
The trunk of the mruby source tree can be checked out with the following command:
$ git clone https://github.com/mruby/mruby.git
You can also install and compile mruby using ruby-install, ruby-build or rvm.
mruby home-page
The URL of the mruby home-page is: https://mruby.org.
Mailing list
We don't have a mailing list, but you can use GitHub issues.
How to compile, test, and install (mruby and gems)
See the compile.md file.
Building documentation
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen)
To build both of them, simply go
rake doc
You can also view them in your browser
rake view_api
rake view_capi
How to customize mruby (mrbgems)
mruby contains a package manager called mrbgems. To create extensions in C and/or Ruby you should create a GEM. For a documentation of how to use mrbgems consult the file mrbgems.md. For example code of how to use mrbgems look into the folder examples/mrbgems/.
License
mruby is released under the MIT License.
Note for License
mruby has chosen a MIT License due to its permissive license allowing developers to target various environments such as embedded systems. However, the license requires the display of the copyright notice and license information in manuals for instance. Doing so for big projects can be complicated or troublesome. This is why mruby has decided to display "mruby developers" as the copyright name to make it simple conventionally. In the future, mruby might ask you to distribute your new code (that you will commit,) under the MIT License as a member of "mruby developers" but contributors will keep their copyright. (We did not intend for contributors to transfer or waive their copyrights, Actual copyright holder name (contributors) will be listed in the AUTHORS file.)
Please ask us if you want to distribute your code under another license.
How to Contribute
See the contribution guidelines, and then send a pull request to https://github.com/mruby/mruby. We consider you have granted non-exclusive right to your contributed code under MIT license. If you want to be named as one of mruby developers, please include an update to the AUTHORS file in your pull request.