-
Notifications
You must be signed in to change notification settings - Fork 790
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
Fix failing tests (including changes codegen for failing IL generation tests for generic comparison) #944
Conversation
df0f269
to
769aecd
Compare
Hmmm... This spans both the philosophical and practical. I'll lay out the thought processes, and maybe this can lead us to the "best" solution. Why remove tail?
Why insert tail?
What about the real world?
My thoughts from typing this? Argh, don't ask me for my opinion! OK, well if I have to. Given that making values types useful (i.e. performance improvement) requires lots of bending over backwards currently anyway, I think that removing tail from the standard equality operations is probably more risky that it's worth, even though I think it unlikely that any "real" type would require tails functionality. This does perpetuate the bad name that values types have though, condemning them basically to always remain a second class citizen. (i.e. you should never basically use them in standard contexts) (A possibly way out of this malaise might be a parallel interfaces along the lines of:
which could be created at some stage would would bypass the problem by only passing reference cells which would be "tail" safe, as well as fast. (Purely theoretical, I haven't persued this line in reality; probably would have to be an alternative operator, as existing operators will all act on the actual type...)) |
@manofstick My concern is that we just keep things exactly as they were before (no regressions) for the cases we care about. First, was the removal of tailcall deliberate here, or just an outcome of the changes in FSharp.Core? Thx These are mostly about generic hash, compare and equality on structures such as
and similar recursive types. As you mention these tailcall via direct jumps within the critical routine, hence coping with very long lists. Please check there are no changes in tailcalling here - I don't think there are. The problem with removing
The type When I say "indirect through a type variable" I man like this:
So, could you poke around with testing and determine if there has been actual behaviour change here in cases like the above then I'd be grateful. thanks |
...this message is just part of some notes as I explore the space, [1 of n]... Functionality in code below is unchanged from current release to master. Note is: If you don't "tail" tuples on recursive union types then you will blow up with stack overflow. Side note: possibly worth of a warning (to blow up code below
Side, side note: When not blowing the stack, this is another good example of performance improvement of #513 ! :-) |
It is more an outcome of changes of FSharp.Core. That was deliberate, because testing with > 64 bit value types had proven a performance bottleneck that I was trying to eradicate. But I didn't think though the ramifications that all generated equality/comparison operators through all bits of code would then be affected. |
BADNESS! ...modifying the example in note 1 with the Pair structure causes StackOverflow... I think I need to remove those eliminate_tail_calls....
|
Actually there is current release badness too! If I change those equals to getting the hash, then current release blows up as well! (simplified)
(Although on contemplation for structures so large one is unlikely to actually want to calculate the hash by a complete descent...) |
Very bad badness... I removed all my eliminate tail call calls and was still getting stack overflow errors. I've had a small investigation into what is the cause of the problem and it appears that in my building block types the compiler isn't adding tail. Now I'm currently at my daughter's swimming lessons and not sure if I'll get another chance to get to code today, but I hope that my initial investigation is wrong or it's a compiler bug, as opposed to some fundamental reason. I.e. being able to tail call on a constrained type call. Otherwise I might be in trouble here... |
Here is a version of the issue (not a particularly great example of programming; but should recurse until it gets a null reference exception; but doesn't. Gets a stack overflow)
So the problem is that
This is a REALLY BIG PROBLEM. Hmmm... I'm thinking I might have backout #513 if can't mix constrained with tail... |
@manofstick I'm closing this in favour of #941. We will likely commit the updates to the tests, and then open a separate issue about whether the tailcall issue means we need to backout #513 for now |
These are the changes needed to fix the last failing tests mentioned here: #915
@manofstick The changes are the removal of tailcalls in some generated IL code due to the recent changes in IL comparison in FSharp.Core.
I've looked at these cases carefully and they all look OK to me: tailcalls are not taken further down the chain in any case, or the structures involved are not recursive. The tailcalls are not an essential part off the specification of the generated code in these particular cases.