Vrtgs / thirtyfour

Selenium WebDriver client for Rust, for automated testing of websites
Other
1.06k stars 78 forks source link

Much more efficient memory usage and smarter dynamic dispatch usage,... #210

Closed Vrtgs closed 7 months ago

Vrtgs commented 7 months ago

…and a bunch of kinda nit-picky changes to docs (including typo fixes)

I ran the tests this time, I learned, but this time I only ran chrome, because I just could not get the gekodriver to work properly

Vrtgs commented 7 months ago

oh yeah msvc is probably 1.75 if that matters too much I'm gonna have to fix that

stevepryde commented 7 months ago

oh yeah msvc is probably 1.75 if that matters too much I'm gonna have to fix that

Personally I don't mind, but some users might not like it. How much work it is to support versions back 12 months or something like that? Somewhere around 1.69 or 1.70. That's still arbitrary but might be nicer for some users if they're stuck on an older version for whatever reason.

stevepryde commented 7 months ago

…and a bunch of kinda nit-picky changes to docs (including typo fixes)

I ran the tests this time, I learned, but this time I only ran chrome, because I just could not get the gekodriver to work properly

What OS? Wondering if there's any documentation updates we can add to fix this. https://stevepryde.github.io/thirtyfour/contributing/testing.html

I am on Windows WSL but I've tried it on Linux previously. On Ubuntu you can just install the firefox snap and then run geckodriver from a terminal. Then in another terminal/tab you can run the tests using THIRTYFOUR_BROWSER=firefox cargo test.

Vrtgs commented 7 months ago

oh yeah msvc is probably 1.75 if that matters too much I'm gonna have to fix that

Personally I don't mind, but some users might not like it. How much work it is to support versions back 12 months or something like that? Somewhere around 1.69 or 1.70. That's still arbitrary but might be nicer for some users if they're stuck on an older version for whatever reason.

I think we can do that by just adding #[async_trait] to thirtyfour::components::wrapper::resolver::sealed::Resolve

Vrtgs commented 7 months ago

…and a bunch of kinda nit-picky changes to docs (including typo fixes) I ran the tests this time, I learned, but this time I only ran chrome, because I just could not get the gekodriver to work properly

What OS? Wondering if there's any documentation updates we can add to fix this. stevepryde.github.io/thirtyfour/contributing/testing.html

I am on Windows WSL but I've tried it on Linux previously. On Ubuntu you can just install the firefox snap and then run geckodriver from a terminal. Then in another terminal/tab you can run the tests using THIRTYFOUR_BROWSER=firefox cargo test.

running geckodriver on the terminal displays a "Machine type Mismatch"

codecov-commenter commented 7 months ago

Codecov Report

Attention: Patch coverage is 37.22826% with 231 lines in your changes are missing coverage. Please review.

Project coverage is 41.31%. Comparing base (f2b9a13) to head (47a11ef).

:exclamation: Current head 47a11ef differs from pull request most recent head 45cbafc. Consider uploading reports for the commit 45cbafc to get more accurate results

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files | [Files](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde) | Coverage Δ | | |---|---|---| | [thirtyfour/src/action\_chain.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Faction_chain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvYWN0aW9uX2NoYWluLnJz) | `61.25% <ø> (ø)` | | | [thirtyfour/src/alert.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Falert.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvYWxlcnQucnM=) | `73.33% <ø> (ø)` | | | [thirtyfour/src/common/capabilities/firefox.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Fcommon%2Fcapabilities%2Ffirefox.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvY29tbW9uL2NhcGFiaWxpdGllcy9maXJlZm94LnJz) | `0.00% <ø> (ø)` | | | [thirtyfour/src/common/command.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Fcommon%2Fcommand.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvY29tbW9uL2NvbW1hbmQucnM=) | `78.21% <100.00%> (ø)` | | | [thirtyfour/src/common/requestdata.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Fcommon%2Frequestdata.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvY29tbW9uL3JlcXVlc3RkYXRhLnJz) | `47.61% <100.00%> (ø)` | | | [thirtyfour/src/extensions/query/poller.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Fextensions%2Fquery%2Fpoller.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvZXh0ZW5zaW9ucy9xdWVyeS9wb2xsZXIucnM=) | `100.00% <ø> (ø)` | | | [thirtyfour/src/web\_element.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Fweb_element.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvd2ViX2VsZW1lbnQucnM=) | `87.50% <100.00%> (ø)` | | | [thirtyfour/tests/components.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Ftests%2Fcomponents.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci90ZXN0cy9jb21wb25lbnRzLnJz) | `100.00% <ø> (ø)` | | | [thirtyfour-macros/src/lib.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour-macros%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci1tYWNyb3Mvc3JjL2xpYi5ycw==) | `0.00% <0.00%> (ø)` | | | [thirtyfour/src/common/capabilities/chromium.rs](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree&filepath=thirtyfour%2Fsrc%2Fcommon%2Fcapabilities%2Fchromium.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde#diff-dGhpcnR5Zm91ci9zcmMvY29tbW9uL2NhcGFiaWxpdGllcy9jaHJvbWl1bS5ycw==) | `10.12% <0.00%> (-1.37%)` | :arrow_down: | | ... and [16 more](https://app.codecov.io/gh/stevepryde/thirtyfour/pull/210?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Steve+Pryde) | |
Vrtgs commented 7 months ago

I'm curious to know why you felt memory usage was an issue, especially for a web browser automation crate. What is your use-case? Neither performance nor memory usage are usually critical for this kind of software

a bit of a dumb reason honestly what sparked my initial snooping in the code was I got mad that I had to wrap everything in Box::new and Box::pin for the resolver, and looked at the code

and honestly the thing that ticked me off the most to go read the entire codebase and do these changes was because I saw you storing Arc<ElementQueryFn> but ElementQueryFn was Box<dyn ...>, yes again I realize its a bit of a waste to care too much, I ended up taking it as a challenge for the most part, not that it was that bad for performance

stevepryde commented 7 months ago

I'm curious to know why you felt memory usage was an issue, especially for a web browser automation crate. What is your use-case? Neither performance nor memory usage are usually critical for this kind of software

a bit of a dumb reason honestly what sparked my initial snooping in the code was I got mad that I had to wrap everything in Box::new and Box::pin for the resolver, and looked at the code

and honestly the thing that ticked me off the most to go read the entire codebase and do these changes was because I saw you storing Arc but ElementQueryFn was Box<dyn ...>, yes again I realize its a bit of a waste to care too much, I ended up taking it as a challenge for the most part, not that it was that bad for performance

Yep I like the changes you made in that area. The predicate code feels a bit nicer now.

stevepryde commented 7 months ago

…and a bunch of kinda nit-picky changes to docs (including typo fixes) I ran the tests this time, I learned, but this time I only ran chrome, because I just could not get the gekodriver to work properly

What OS? Wondering if there's any documentation updates we can add to fix this. stevepryde.github.io/thirtyfour/contributing/testing.html I am on Windows WSL but I've tried it on Linux previously. On Ubuntu you can just install the firefox snap and then run geckodriver from a terminal. Then in another terminal/tab you can run the tests using THIRTYFOUR_BROWSER=firefox cargo test.

running geckodriver on the terminal displays a "Machine type Mismatch"

That's odd. What OS? What arch? Are you downloading the correct version of geckodriver?

stevepryde commented 7 months ago

oh yeah msvc is probably 1.75 if that matters too much I'm gonna have to fix that

Personally I don't mind, but some users might not like it. How much work it is to support versions back 12 months or something like that? Somewhere around 1.69 or 1.70. That's still arbitrary but might be nicer for some users if they're stuck on an older version for whatever reason.

I think we can do that by just adding #[async_trait] to thirtyfour::components::wrapper::resolver::sealed::Resolve

I think this is worth doing

stevepryde commented 7 months ago

Once you're done making changes, please provide a summary of the changes and the reasons for them. I feel that these later changes probably should have been a separate PR. Let's not try to change the entire codebase in one commit 😅

Vrtgs commented 7 months ago

Once you're done making changes, please provide a summary of the changes and the reasons for them. I feel that these later changes probably should have been a separate PR. Let's not try to change the entire codebase in one commit 😅

hmm yeah, I should

Vrtgs commented 7 months ago

…and a bunch of kinda nit-picky changes to docs (including typo fixes) I ran the tests this time, I learned, but this time I only ran chrome, because I just could not get the gekodriver to work properly

What OS? Wondering if there's any documentation updates we can add to fix this. stevepryde.github.io/thirtyfour/contributing/testing.html I am on Windows WSL but I've tried it on Linux previously. On Ubuntu you can just install the firefox snap and then run geckodriver from a terminal. Then in another terminal/tab you can run the tests using THIRTYFOUR_BROWSER=firefox cargo test.

running geckodriver on the terminal displays a "Machine type Mismatch"

That's odd. What OS? What arch? Are you downloading the correct version of geckodriver?

windows x86_64, I downloaded geckodriver-v0.33.0-win64.zip

stevepryde commented 7 months ago

I appreciate the effort you've put in, but dumping a huge code change like this as a PR makes it really difficult to sift through and understand the intent and the implications.

I like the improvements to the predicate functions but a lot of other changes seem to increase the complexity of the codebase without offering a tangible real-world benefit either to the developer or to the runtime outcome. I'd even suggest there's a fair chunk that largely comes down to personal preference. This is the first I've seen anyone recommend Arc<str> instead of String, for example. I can see why you'd care about this for a performance critical application, but this isn't that. Instead many users of the library will probably find it confusing.

I think there's an argument for keeping things familiar and not increasing the complexity unnecessarily.

Vrtgs commented 7 months ago

I appreciate the effort you've put in, but dumping a huge code change like this as a PR makes it really difficult to sift through and understand the intent and the implications.

I like the improvements to the predicate functions but a lot of other changes seem to increase the complexity of the codebase without offering a tangible real-world benefit either to the developer or to the runtime outcome. I'd even suggest there's a fair chunk that largely comes down to personal preference. This is the first I've seen anyone recommend Arc<str> instead of String, for example. I can see why you'd care about this for a performance critical application, but this isn't that. Instead many users of the library will probably find it confusing.

I think there's an argument for keeping things familiar and not increasing the complexity unnecessarily.

hmm yea I see your point, and I think I really should make a list of all the changes and detail what how and why I did them

as for Arc<str> I think should be used here because we just want an immutable view to a string slice, and as can be see from the code since we clone the string slice a lot I think it would be useful to use an Arc<str> instead of a String, and I mean most of the changes that came with that were not at the site where the string was used, just where it was created and given a type

stevepryde commented 7 months ago

I appreciate the effort you've put in, but dumping a huge code change like this as a PR makes it really difficult to sift through and understand the intent and the implications. I like the improvements to the predicate functions but a lot of other changes seem to increase the complexity of the codebase without offering a tangible real-world benefit either to the developer or to the runtime outcome. I'd even suggest there's a fair chunk that largely comes down to personal preference. This is the first I've seen anyone recommend Arc<str> instead of String, for example. I can see why you'd care about this for a performance critical application, but this isn't that. Instead many users of the library will probably find it confusing. I think there's an argument for keeping things familiar and not increasing the complexity unnecessarily.

hmm yea I see your point, and I think I really should make a list of all the changes and detail what how and why I did them

as for Arc<str> I think should be used here because we just want an immutable view to a string slice, and as can be see from the code since we clone the string slice a lot I think it would be useful to use an Arc<str> instead of a String, and I mean most of the changes that came with that were not at the site where the string was used, just where it was created and given a type

I understand the reason for the Arc<str>. It's not a bad change. There is some benefit like you said. And I think you did it in a way that doesn't affect how the library is used. It seems to be an internal change only for the most part. So that's fine.

Don't worry about splitting it or anything. Let's just put a freeze on the feature changes and I'll have another look through the code and we can go from there.

If you can summarise the changes with a bullet point each that would be helpful too.

Vrtgs commented 7 months ago

I appreciate the effort you've put in, but dumping a huge code change like this as a PR makes it really difficult to sift through and understand the intent and the implications. I like the improvements to the predicate functions but a lot of other changes seem to increase the complexity of the codebase without offering a tangible real-world benefit either to the developer or to the runtime outcome. I'd even suggest there's a fair chunk that largely comes down to personal preference. This is the first I've seen anyone recommend Arc<str> instead of String, for example. I can see why you'd care about this for a performance critical application, but this isn't that. Instead many users of the library will probably find it confusing. I think there's an argument for keeping things familiar and not increasing the complexity unnecessarily.

hmm yea I see your point, and I think I really should make a list of all the changes and detail what how and why I did them as for Arc<str> I think should be used here because we just want an immutable view to a string slice, and as can be see from the code since we clone the string slice a lot I think it would be useful to use an Arc<str> instead of a String, and I mean most of the changes that came with that were not at the site where the string was used, just where it was created and given a type

I understand the reason for the Arc<str>. It's not a bad change. There is some benefit like you said. And I think you did it in a way that doesn't affect how the library is used. It seems to be an internal change only for the most part. So that's fine.

Don't worry about splitting it or anything. Let's just put a freeze on the feature changes and I'll have another look through the code and we can go from there.

If you can summarise the changes with a bullet point each that would be helpful too.

here since I'm done with the first part for the first list of major changes you can read through while I write part 2

List of changes:

lets start with thirtyfour-macros, the changes I made were:

as for thirtyfour it self:

other changes have either been discussed or are very minor