I'm writing code for compiler for yet another programming language. The code can be read at my GitHub repo. I'm working (in PR) to optimize around char sequence operation. The cargo-flamegraph
indicated that there are some serious bottleneck. The following figure is its output (with RUST_LOG="warn" CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -p origlang-cli -F 10000 -- execute --input-file ./compile/positive/perf/very_long_string_literals_printout.origlang >/dev/null
in repo root):
I'd like to ask help about optimizing "char boundary cache", speficially:
- Should I avoid use of
Vec<char>
for both memory efficiency and cpu efficiency? - Should I cache their boundary if there are a lot of call to
str.chars().nth(_)
to avoid overhead ofcore::str::validation::next_code_point
? - How can I optimize
origlang_compiler::chars::boundary::MultiByteBoundaryAwareString
(and its constructor)? - Can I avoid those page-faults (the perf was taken on Linux machine)? If so, how can I?
Thank you