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

Removed RefCells for dispatcher. #220

Merged

Conversation

orium
Copy link
Member

@orium orium commented Aug 22, 2024

We now explicitly pass that state around. This will reduce the number of Mutexes in a Send version of the rewriter.

Benchmarks show a median speedup of 0.4%... so, no performance difference when all benchmarks are aggregated.

@orium orium force-pushed the html-rewriter-no-refcell-for-dispatcher branch from a90a9e9 to 068d90c Compare August 22, 2024 11:49

fn enter_cdata(&mut self, input: &[u8]);
fn leave_cdata(&mut self, input: &[u8]);
type PassingState;
Copy link
Member Author

Choose a reason for hiding this comment

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

Looking for a better name for this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know it's overused as a term, but Context?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think that's good: it is generic, but the nature of this type is also generic!

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, was about to write that it's better to use ParserContext. Also, drop passing and shared prefixes. Just pass ctx: ParserContext around

Copy link
Contributor

Choose a reason for hiding this comment

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

didn't have a time to do a deep dive in the code, so it's easier to just ask here: why it needs to be a type parameter? is it because the state is generic over S. Can we just make StateMachine trait generic then?

Copy link
Member Author

Choose a reason for hiding this comment

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

why it needs to be a type parameter? is it because the state is generic over S.

It's because we need to reference it in the trait methods. (The ones in directly in the trait and the ones added by macros on the StateMachine "sub"-trait).

Can we just make StateMachine trait generic then?

Not sure if I understand: the traits are generic over the context.

@orium orium force-pushed the html-rewriter-no-refcell-for-dispatcher branch from 068d90c to ee4b343 Compare August 22, 2024 15:26
We now explicitly pass that state around. This will reduce the number of
`Mutex`es in a `Send` version of the rewriter.
@orium orium force-pushed the html-rewriter-no-refcell-for-dispatcher branch from ee4b343 to efd8398 Compare August 22, 2024 15:39
@Noah-Kennedy Noah-Kennedy merged commit fa7a7f7 into cloudflare:master Aug 26, 2024
4 checks passed
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.

4 participants