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

Htmlunit tuning #715

Merged
merged 19 commits into from
Jan 28, 2024
Merged

Conversation

rschwietzke
Copy link
Contributor

HtmlUnit tuning regarding speed and memory. Current success, more on the memory side.
Please run the full test program, there might be something hidden. The small one looked ok.

E-commerce retailer website

NEW (JDK 17)

Benchmark                                    Mode  Cnt        Score   Error   Units
HtmlUnitBenchmark.simple                     avgt    2  9639101.018           ns/op
HtmlUnitBenchmark.simple:gc.alloc.rate.norm  avgt    2  7612275.912            B/op

OLD (JDK 17)

Benchmark                                    Mode  Cnt         Score   Error   Units
HtmlUnitBenchmark.simple                     avgt    2  10527569.765           ns/op
HtmlUnitBenchmark.simple:gc.alloc.rate.norm  avgt    2   9213538.844            B/op

XC Homepage

NEW (JDK 17)

Benchmark                                    Mode  Cnt       Score   Error   Units
HtmlUnitBenchmark.simple                     avgt    2  397427.602           ns/op
HtmlUnitBenchmark.simple:gc.alloc.rate.norm  avgt    2  383380.466            B/op

OLD (JDK 17)

Benchmark                                    Mode  Cnt       Score   Error   Units
HtmlUnitBenchmark.simple                     avgt    2  411880.438           ns/op
HtmlUnitBenchmark.simple:gc.alloc.rate.norm  avgt    2  454900.410            B/op

rschwietzke and others added 19 commits January 27, 2024 22:42
…nized, but churns too much memory when we need a fail-safe iterator
…d sychronized, but churns too much memory when we need a fail-safe iterator"

This reverts commit fb8355b1c0b32a43b12b425f492f20898e8b4b1f.
…r lists should not be insanely large and hence we can remove by iterating
… index based structure later, less memory when in use, based on FashHashMap with futher footprint reduction
…by default, only in case we don't find anything, we go the lowercasing and comparision route
…cially when also shared, is more expensive than a potential lower casing operation which in most case might not be needed at all.
…hen asking contains or get due to the more likely cache misses when jumping into an array of hashes
private static final Map<String, String> CamelizeCache_ = new HashMap<>();
private static final Map<String, String> RootLowercaseCache_ = new HashMap<>();
private static final Map<String, String> CamelizeCache_ = new ConcurrentHashMap<>();
private static final Map<String, String> RootLowercaseCache_ = new ConcurrentHashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

RootLowercaseCache_ seems to be no longer used - does having this case makes no sense?

Copy link
Member

Choose a reason for hiding this comment

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

found the answer in the commit comment


import java.util.Random;

public final class RandomUtils {
Copy link
Member

Choose a reason for hiding this comment

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

please add author

@rbri
Copy link
Member

rbri commented Jan 28, 2024

https://jenkins.wetator.org/job/htmlunit/view/change-requests/job/PR-715/

the failing tests are my ones - i'm still in the middle of a huge refactoring

@rbri
Copy link
Member

rbri commented Jan 28, 2024

@rbri
Copy link
Member

rbri commented Jan 28, 2024

@shapiroronny is this something you are also interested in? Will be great to see if all the hard work from @rschwietzke has some impact for your use case

@rbri
Copy link
Member

rbri commented Jan 28, 2024

@shapiroronny
Copy link
Contributor

@shapiroronny is this something you are also interested in? Will be great to see if all the hard work from @rschwietzke has some impact for your use case

Hopefully yes. We're disabling javascript for our case and don't do any navigations and very little DOM mutation so not sure which flows are optimized. If initial parsing is faster, that's huge for us.

In any case, we haven't bumped in a while so we're happy upgrading in steps in case this was planned to go in the next major version with Computed Css fixes.

@rbri
Copy link
Member

rbri commented Jan 28, 2024

Hopefully yes. We're disabling javascript for our case and don't do any navigations and very little DOM mutation so not sure which flows are optimized. If initial parsing is faster, that's huge for us.

Great; that was my understanding of your use case and of @rschwietzke 's goal.
Will merge that soon and we will see....

@rbri rbri merged commit 9db455d into HtmlUnit:master Jan 28, 2024
2 of 3 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.

3 participants