question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mapping seemingly degrades performance

See original GitHub issue

I have the following definitions using 2.13.0 (somewhat pseudo-notation):

// Custom generators

// Gen<Tree<Box<'a>>>
let genTree () = TreeGenerator.tree Arb.generate<Box<'a>>

type T<'a> = T of Tree<Box<'a>>

// Gen<T<'a>>, so basically a packaged tree
let genWrappedTree () = T <!> genTree ()

// Registrations and tests

type Generators () =
   static member T () = Arb.fromGen ^ genWrappedTree ()
   static member Tree () = Arb.fromGen ^ genTree ()

// Takes 5 minutes to complete with huge input data
let prop1 (tree : T<int>) = predicate tree

// Takes 2 seconds to complete with good looking input data
let prop2 (tree : Tree<Box<int>>) = predicate (T tree)

Generator TreeGenerator.tree recursively generates a rose tree (with elements generated by the given generator) taking current size into account and distributing it among the sub-trees. Box<'a> is a record type. Generators genTree and genWrappedTree differ only in mapping over the box tree generator.

It would seem that mapping in genWrappedTree considerably affects performance: prop1 is wildly slower than prop2, where T is applied inside the test. Besides running times, I made the following observations:

  • Input generated in prop1 is much larger than in prop2. 300000 lines vs 7000 when using the verbose configuration.
  • Not registering genWrappedTree makes prop1 and prop2 comparable, both in terms of running time and generated input.
  • T <!> Gen.resize 1 (genTree ()) helps, but
  • Gen.sized (fun s -> T <!> Gen.resize s (genTree ())) does not.

I am especially puzzled by the second observation. This example is but a simple wrapper which could be applied inside a property, but my real use-case is working with another tree type, which is the result of applying a catamorphism to Tree<Box<..>> instead of T. So I would like to have a genWrappedTree -like generator, but this seems out of reach for the moment.

Am I doing something wrong and is there an explanation for this performance drop and size behavior?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kurtschelfthoutcommented, Jan 11, 2019

Hm, interesting. I will take a look. Thanks for the detailed writeup.

0reactions
kurtschelfthoutcommented, Jan 22, 2019

I cannot reproduce that though. So I still think you may have some issue with registration of the generators or something like that. When I run your experiment 3 in FSI, fast() and slow() take about the same time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Seemingly unique performance degradation
After 7-8 games I'll be dropping to 170ish and fluctuating quite a bit, some maps being much worse than others. My CPU load...
Read more >
Spatial validation reveals poor predictive performance of ...
Mapping aboveground forest biomass is central for assessing the global carbon balance. However, current large-scale maps show strong ...
Read more >
How many primitives can you have before performance ...
How many primitives can you have before performance degrades?
Read more >
Amplifying side channels through performance degradation
In this paper, we demonstrate that software-based performance-degradation attacks can be used to amplify side-channel leaks, enabling the ...
Read more >
How I overcame the vector map learning curve
Here's a breakdown of vector tile mapping from the perspective of a ... the last set of mapping tiles, they start to degrade...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found