GithubHelp home page GithubHelp logo

Comments (11)

AltSysrq avatar AltSysrq commented on July 30, 2024 1

The various string-generation strategies are now Send + Sync as of 0.3.2.

I also did look into the performance of string generation, and I believe the main bottleneck is actually character generation due to the inefficient way it accomplishes biasing towards particular characters. Changing that will likely require breaking backwards compatibility, so I'll make another pass at that at a later time.

from proptest.

AltSysrq avatar AltSysrq commented on July 30, 2024 1

I've moved the regex performance concerns to a separate issue (#16) since the problem referenced by the title of this one has been fixed.

from proptest.

vitiral avatar vitiral commented on July 30, 2024

also, any advice on speeding up generation of random strings? I'm seeing significant (i.e. 10x) slowdowns compared to quickcheck + regex_generate.

from proptest.

vitiral avatar vitiral commented on July 30, 2024

one thing I did: reduce the number generated for tests that don't need a large number. Very hard to do with quickcheck!

from proptest.

AltSysrq avatar AltSysrq commented on July 30, 2024

Strategies don't implement Sync

I originally wanted to leave the possibility of using interior mutability within a strategy. But as I found out trying to implement prop_recursive with it, you can't usefull track state in a strategy anyway, so I don't think there's any reason not to add Sync at this point.

seeing significant (i.e. 10x) slowdowns compared to quickcheck + regex_generate

That's somewhat expected. Proptest needs to build and retain a more complicated structure for shrinking to work correctly. The generation could also benefit a lot from small string optimisation; currently, each individual element of the regex becomes its own Vec<u8>, so you may be paying for an enormous amount of allocations depending on the regex. I'll look into improving this soon.

from proptest.

vitiral avatar vitiral commented on July 30, 2024

Thanks for the replies. It would be nice to add Sync.

As for the slowdown, I think it's mostly fine -- obviously faster is always better :)

It would probably be worth documenting eventually though, especially if a solution cannot be found.

from proptest.

AltSysrq avatar AltSysrq commented on July 30, 2024

It turns out that adding Strategy: Send + Sync would actually be pretty painful as combinators like prop_map would need to require the closures to be Send + Sync. Instead, I'm just fixing the immediate problem which was specific to the regex strategy, which used Box<Strategy> under the hood and so erased the OIBITS. I'm also adding a conventional way to make a Box<Strategy + Send + Sync> so external users can get the same benefit.

The only other remaining internal use of BoxedStrategy is in prop_recursive(), but I'm not sure what could be done there since switching to the Send + Sync version would restrict how people could use that combinator.

from proptest.

AltSysrq avatar AltSysrq commented on July 30, 2024

@vitiral Would you be able to provide the regex in question? I started looking into optimising the string generation, but the regex I tried ([0-9]{4}-[0-9]{2}-[0-9]{2} .*) ended up being faster than I anticipated (~9μs per iteration), so it would help to have a slow-but-realistic test case.

from proptest.

vitiral avatar vitiral commented on July 30, 2024

Here is the regex I am using:

const GEN_NAME_RE: &str = r#"(?ix)
(REQ|SPC|TST)-              # the type followed by `-`
([a-z0-9_]{1,20}-){0,8}     # an optional number of `elem-` elements
[a-z0-9_]{1,20}             # required final element
"#;

from proptest.

vitiral avatar vitiral commented on July 30, 2024

originally I was using * instead of the ranges {1,20} or {0,8}. That was slow, so I adjusted the ranges to (I think) up to 50 and then down to 20/8.

Hope that helps!

from proptest.

vitiral avatar vitiral commented on July 30, 2024

Thanks! Wow, you are really responsive on these issues. Hope they were helpful for you as a lib designer!

from proptest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.