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

src,lib: remove the cost of encoding parameter serialization #56047

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Nov 28, 2024

Work in progress. If anybody wants to take over this work and complete it, please comment on this pull-request and proceed without depending on a response. Happy holidays everyone!

The goal is to remove the ability to send string encoding values (such as "utf8", "latin1" etc.) to C++. Result of this work will enable adding more V8 fast APIs and improve the performance of all functions (small or big it doesn't matter) that use encoding as a parameter.

PS: I did a similar work on Cloudflare workers: cloudflare/workerd#2478

cc @nodejs/performance @lemire @jasnell @mcollina @ronag

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Nov 28, 2024
@anonrig anonrig requested review from ronag and RafaelGSS November 28, 2024 01:11
@anonrig anonrig force-pushed the yagiz/remove-cost-of-encoding branch from b01ae01 to db3069b Compare November 28, 2024 01:12
buffer.csv Outdated Show resolved Hide resolved
@anonrig anonrig force-pushed the yagiz/remove-cost-of-encoding branch from db3069b to 32ce431 Compare November 28, 2024 01:17
Copy link

@dogia dogia left a comment

Choose a reason for hiding this comment

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

LG

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@ronag
Copy link
Member

ronag commented Nov 28, 2024

Is this unfinished or not? It's not draft but on slack you wrote it's not finished?

@targos
Copy link
Member

targos commented Nov 28, 2024

CI fails everywhere. It fails to build.

if (args.Length() >= 1) {
encoding = ParseEncoding(env->isolate(), args[0], BUFFER);
static_cast<ENCODING>(args[0].As<v8::Uint32>()->Value());
Copy link

Choose a reason for hiding this comment

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

Seems this line is not doing anything?

Suggested change
static_cast<ENCODING>(args[0].As<v8::Uint32>()->Value());
encoding = static_cast<ENCODING>(args[0].As<v8::Uint32>()->Value());

I guess you wanted it to be like this ^ ?

@@ -1385,7 +1385,7 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
THROW_IF_INSUFFICIENT_PERMISSIONS(
env, permission::PermissionScope::kFileSystemRead, path.ToStringView());

const enum encoding encoding = ParseEncoding(isolate, args[1], UTF8);
auto encoding = static_cast<ENCODING>(args[1].As<v8::Uint32>()->Value());
Copy link

Choose a reason for hiding this comment

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

IMHO, it's good to let this (and others in this file) remain const

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants