fitzgen / inlinable_string

An owned, grow-able UTF-8 string that stores small strings inline and avoids heap-allocation.
http://fitzgen.github.io/inlinable_string/inlinable_string/index.html
Other
69 stars 11 forks source link

A quick no_std patch #31

Closed ArtemGr closed 3 years ago

ArtemGr commented 3 years ago

Works in the Linux kernel:

image

To give it a go, use

inlinable_string = {git = "https://github.com/ArtemGr/inlinable_string", branch = "no_std", features = ["no_std"]}
ArtemGr commented 3 years ago

Did some benchmarks, https://gitlab.com/artemciy/lin-socks/-/blob/95d2bb96/bench/stack-string.rs

old i7
write_string            time:   [142.63 ns 143.45 ns 144.32 ns]
write_cursor            time:   [41.238 ns 41.339 ns 41.456 ns]
write_cursor_uninit     time:   [37.525 ns 37.588 ns 37.661 ns]
write_smallvec          time:   [62.710 ns 62.767 ns 62.843 ns]
write_inlinable_string  time:   [54.599 ns 54.631 ns 54.668 ns]

VPS, QEMU Virtual CPU version 2.5+
write_string            time:   [108.38 ns 109.77 ns 111.61 ns]
write_cursor            time:   [47.222 ns 47.999 ns 48.945 ns]
write_cursor_uninit     time:   [44.930 ns 45.296 ns 45.691 ns]
write_smallvec          time:   [56.464 ns 56.991 ns 57.739 ns]
write_inlinable_string  time:   [68.181 ns 68.313 ns 68.510 ns]
ArtemGr commented 3 years ago

Published, https://crates.io/crates/inlinable_string/0.1.13