Skip to content

Commit fb82937

Browse files
authored
Merge pull request #3 from artichoke/readme-updates
Update README
2 parents f079a4d + 73e484b commit fb82937

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

.github/labels.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@
1515
"description": "Area: Compile-time features or attributes."
1616
},
1717
{
18-
"name": "A-hash-table",
18+
"name": "A-data-structure",
1919
"color": "f7e101",
20-
"description": "Area: st_table."
20+
"description": "Area: StHashMap and StHashSet."
2121
},
2222
{
2323
"name": "A-deps",
2424
"color": "f7e101",
2525
"description": "Area: Source and library dependencies."
2626
},
27+
{
28+
"name": "A-hash-table",
29+
"color": "f7e101",
30+
"description": "Area: st_table."
31+
},
2732
{
2833
"name": "A-performance",
2934
"color": "f7e101",
@@ -39,6 +44,11 @@
3944
"color": "f7e101",
4045
"description": "Area: crates.io releases and version bumps."
4146
},
47+
{
48+
"name": "A-Rust-API",
49+
"color": "f7e101",
50+
"description": "Area: Rust API wrapper around core data structure."
51+
},
4252
{
4353
"name": "A-security",
4454
"color": "f7e101",

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010

1111
Insertion-ordered hash table suitable for embedding via FFI.
1212

13-
Drop-in replacement for `st_hash` originally written by Peter Moore @ UCB and
14-
used in [Ruby]'s [implementation][st.c] of the [`Hash`][hash] core class.
13+
Status: Work in progress.
14+
15+
Strudel was conceived as a drop-in replacement for `st_hash`, a hash map
16+
implemented in C originally written by Peter Moore @ UCB and used in [Ruby]'s
17+
[implementation][st.c] of the [`Hash`][hash] core class.
18+
19+
This crate is an exercise in implementing an insertion-ordered hash map in Rust
20+
that cannot use the built-in `Hasher` infrastructure. The implementation uses
21+
[Ruby's `Hash` backend][sthash-notes] and [Python's dict][pydict-notes] as prior
22+
art.
1523

1624
`StHashMap` is designed to implement the `st_hash` C API and be FFI-friendly.
1725

@@ -47,6 +55,32 @@ All features are enabled by default.
4755
- **capi-specialized-init** - Enables additional `st_init_table` C APIs with
4856
known `st_hash_type`s for tables with numeric and string keys.
4957

58+
## Building Ruby with Strudel
59+
60+
Strudel exports most of the symbols implemented by `st.c` in MRI 2.6.3. The
61+
[included patch](strudelify-mri.patch) and some
62+
[`configure` arguments](build.sh) can build the bootstrapping phase of MRI 2.6.3
63+
with Strudel as the hash backend.
64+
65+
To build `miniruby` with Strudel, run:
66+
67+
```sh
68+
./build.sh
69+
```
70+
71+
The resulting Ruby is in `./build/ruby-strudel-build-root/miniruby`. `miniruby`
72+
can run simple scripts involving `Hash`, for example:
73+
74+
```console
75+
$ ./build/ruby-strudel-build-root/miniruby -e 'h = {}' -e '1000.times { |i| h[i] = i }' -e 'puts h.length'
76+
1000
77+
```
78+
79+
`miniruby` successfully executes the benchmarks in [`benches`](benches).
80+
81+
NOTE: Strudel cannot build a full Ruby due to bugs in the implementation of the
82+
`st_hash` API.
83+
5084
## License
5185

5286
`strudel` is licensed under the [MIT License](LICENSE) (c) Ryan Lopopolo.
@@ -67,6 +101,9 @@ The `st_hash` implementation in Ruby includes the following notice:
67101
[ruby]: https://github.com/ruby/ruby
68102
[st.c]: https://github.com/ruby/ruby/blob/v2_6_3/st.c
69103
[hash]: https://ruby-doc.org/core-2.6.3/Hash.html
104+
[sthash-notes]: https://github.com/ruby/ruby/blob/v2_6_3/st.c#L1-L101
105+
[pydict-notes]:
106+
https://github.com/python/cpython/blob/v3.8.4/Objects/dictobject.c#L1-L110
70107
[`hashmap`]: https://doc.rust-lang.org/std/collections/struct.HashMap.html
71108
[`vec`]: https://doc.rust-lang.org/std/vec/struct.Vec.html
72109
[`libc`]: https://crates.io/crates/libc

0 commit comments

Comments
 (0)