Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(ops): support Cow<'_, str> #15664

Conversation

littledivy
Copy link
Member

Inline String and Option<String> args in the #[op] macro. Also implements deserialization of Cow<'_, str> from v8::String - it is backed by a global stack allocated buffer.

5% improvement in op_url_parse by switching href: String to href: Cow<'_, str>

# main

deno run -A --unstable cli/bench/url_parse.js 50 1000000
time 1076 ms rate 929368
time 1057 ms rate 946073
time 1047 ms rate 955109
time 1045 ms rate 956937
time 1043 ms rate 958772
time 1046 ms rate 956022
time 1049 ms rate 953288
# This patch

target/release/deno run -A --unstable cli/bench/url_parse.js 50 1000000
time 1020 ms rate 980392
time 1012 ms rate 988142
time 1004 ms rate 996015
time 1001 ms rate 999000
time 1000 ms rate 1000000
time 1000 ms rate 1000000
time 1000 ms rate 1000000

};
}
// Fast path for `Cow<'_, str>`, optimizes to reuse a stack allocated buffer.
if is_cow_str(&**ty) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is an Option<Cow<'_, str>> possible?

@littledivy littledivy changed the title perf(ops): inline String args, support Cow<'_, str> perf(ops): support Cow<'_, str> Aug 30, 2022
@littledivy littledivy closed this Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants