Skip to content

Make html and escape modules optional#519

Merged
Martin1887 merged 2 commits intopulldown-cmark:masterfrom
jfrimmel:master
May 18, 2023
Merged

Make html and escape modules optional#519
Martin1887 merged 2 commits intopulldown-cmark:masterfrom
jfrimmel:master

Conversation

@jfrimmel
Copy link
Contributor

This PR introduces a new enabled-by-default-feature html. If this feature is enabled, there are no functional differences. If it is disabled, the html and escape modules are not compiled. This is helpful, if a dependent crate does not require any HTML rendering.

Note, that this will break user crates, that use --no-default-features and also use one of the two modules in question. Therefore I understand, if this PR cannot be merged.

Note, that some tests and examples need new annotations, as they require the html module.

@marcusklaas
Copy link
Collaborator

marcusklaas commented Feb 24, 2021

Thank you for your thoughtful PR. I am sympathetic to this change, but would like one more pair of eyes on this before I merge.

@raphlinus: does this look like a good idea to you as well?

@raphlinus
Copy link
Collaborator

Hmm, I have mixed feelings about it. I certainly understand the desire to keep compile times down and avoid bloat, but these modules don't strike me as especially heavy. The experience with default features is that they're almost always left on, and are somewhat inconvenient to control.

Do we have any kind of quantitative measurement about how much compile time is saved here?

@jfrimmel
Copy link
Contributor Author

I understand the mixed feelings 😉

I've run some measurements with hyperfine on my laptop (crates were all downloaded):
image

@raphlinus
Copy link
Collaborator

That's a nontrivial improvement. I'm ok with this change. If the time delta had been much smaller I would have said it's not worth it. Thanks for the PR and measurements :)

@jfrimmel
Copy link
Contributor Author

Oh, I've noticed something:
I think the previous comparison was not 100% fair, as there is another additional crate built (getopts) when default features are active.

Here is a better benchmark, which shows the real difference:
image

@ehuss
Copy link
Contributor

ehuss commented Feb 24, 2021

I would caution against making a breaking change like this. There are a number of projects that use default-features=false (like rustdoc, clippy, etc.).

Also, to me, 0.7 seconds does not seem worth a change.

@jfrimmel
Copy link
Contributor Author

jfrimmel commented May 31, 2021

Is there anything to do here? Should this PR be closed or left open until a decision is reached?

Does anyone know how much the breakage would be?

@Martin1887
Copy link
Collaborator

This makes a lot of sense to me, and having an HTML renderer in a parser crate was a bit shocking the first time I checked the project. I think that both features should be in different crates, but keeping the current minimal functionality as optional features can make sense for tests.

All implications must be carefully reviewed though, so I will be back on this relatively soon.

Related to #526.

@Martin1887 Martin1887 merged commit f324932 into pulldown-cmark:master May 18, 2023
@Martin1887
Copy link
Collaborator

Martin1887 commented May 18, 2023

This pull request is interesting for the 0.10 release, merged.

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.

5 participants