Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.

Fixes to re-enable Pipeline tests that were skipped. #1432

Merged
merged 6 commits into from
Apr 6, 2017
Merged

Fixes to re-enable Pipeline tests that were skipped. #1432

merged 6 commits into from
Apr 6, 2017

Conversation

shiftylogic
Copy link
Contributor

@shiftylogic shiftylogic commented Apr 5, 2017

Fixes #1404

@shiftylogic
Copy link
Contributor Author

@davidfowl @pakrym @ahsonkhan

{
try
{
var tuple = await PingClient(connection, SendCount);
var tuple = PingClient(connection, SendCount).GetResultSync();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing these changes, does it make sense to just change PingClient and keep the test as async Task?
https://github.com/ahsonkhan/corefxlab/blob/FixingTests/tests/System.IO.Pipelines.Tests/SocketsFacts.cs#L185

Copy link
Contributor

Choose a reason for hiding this comment

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

What is using span in this test?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing. Your change here fixed the issue: #1421

[Fact(Skip = "System.TypeLoadException : A value type containing a by-ref instance field, such as Span<T>, cannot be used as the type for a class instance field.")]
public async Task ReadTWorksAgainstSimpleBuffers()
[Fact]
public void ReadTWorksAgainstSimpleBuffers()
Copy link
Contributor

Choose a reason for hiding this comment

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

  [Fact]
        public void ReadTWorksAgainstSimpleBuffers()
        {
            var readable = BufferUtilities.CreateBuffer(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 });
            var span = readable.ToSpan();
            Assert.True(readable.IsSingleSpan);
            Assert.Equal(span.Read<byte>(), readable.ReadLittleEndian<byte>());
            Assert.Equal(span.Read<sbyte>(), readable.ReadLittleEndian<sbyte>());
            Assert.Equal(span.Read<short>(), readable.ReadLittleEndian<short>());
            Assert.Equal(span.Read<ushort>(), readable.ReadLittleEndian<ushort>());
            Assert.Equal(span.Read<int>(), readable.ReadLittleEndian<int>());
            Assert.Equal(span.Read<uint>(), readable.ReadLittleEndian<uint>());
            Assert.Equal(span.Read<long>(), readable.ReadLittleEndian<long>());
            Assert.Equal(span.Read<ulong>(), readable.ReadLittleEndian<ulong>());
            Assert.Equal(span.Read<float>(), readable.ReadLittleEndian<float>());
            Assert.Equal(span.Read<double>(), readable.ReadLittleEndian<double>());
        }

        [Fact]
        public void ReadTWorksAgainstMultipleBuffers()
        {
            var readable = BufferUtilities.CreateBuffer(new byte[] { 0, 1, 2 }, new byte[] { 3, 4, 5 }, new byte[] { 6, 7, 9 });
            Assert.Equal(9, readable.Length);

            int spanCount = 0;
            foreach (var _ in readable)
            {
                spanCount++;
            }
            Assert.Equal(3, spanCount);

            var span = readable.ToSpan();

            Assert.Equal(span.Read<byte>(), readable.ReadLittleEndian<byte>());
            Assert.Equal(span.Read<sbyte>(), readable.ReadLittleEndian<sbyte>());
            Assert.Equal(span.Read<short>(), readable.ReadLittleEndian<short>());
            Assert.Equal(span.Read<ushort>(), readable.ReadLittleEndian<ushort>());
            Assert.Equal(span.Read<int>(), readable.ReadLittleEndian<int>());
            Assert.Equal(span.Read<uint>(), readable.ReadLittleEndian<uint>());
            Assert.Equal(span.Read<long>(), readable.ReadLittleEndian<long>());
            Assert.Equal(span.Read<ulong>(), readable.ReadLittleEndian<ulong>());
            Assert.Equal(span.Read<float>(), readable.ReadLittleEndian<float>());
            Assert.Equal(span.Read<double>(), readable.ReadLittleEndian<double>());
        }

EnsureSpanDisposed(preserved.Buffer.First);
}

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these attributes necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was ensuring these weren't optimized away since nothing in that code is ever used.

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't understand why it is necessary.
If the method call can get optimized out, won't this get optimized too:
https://github.com/dotnet/corefxlab/pull/1432/files#diff-920b95938a7bd6c56992737a476f216eL326

// Make sure we can acccess the span
 var span = buffer.First.Span;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could in release builds, if the compiler can determine that accessing First and Span are side-effect free.

@pakrym
Copy link
Contributor

pakrym commented Apr 5, 2017

LGTM

@ahsonkhan
Copy link
Contributor

@shiftylogic, is something broken?

It seems like the tests never end:
15:37:37 Starting test execution, please wait...
15:37:38 [xUnit.net 00:00:00.5424943] Discovering: System.IO.Pipelines.Tests
15:37:38 [xUnit.net 00:00:01.1666408] Discovered: System.IO.Pipelines.Tests
15:37:39 [xUnit.net 00:00:01.3608667] Starting: System.IO.Pipelines.Tests
15:37:40 Ping: 500; Pong: 500; Time: 48ms
15:37:40 Ping: 500; Pong: 500; Time: 29ms
15:37:40 Ping: 500; Pong: 500; Time: 20ms
15:37:40 Ping: 500; Pong: 500; Time: 21ms
15:37:40 Ping: 500; Pong: 500; Time: 21ms
15:37:40 Ping: 500; Pong: 500; Time: 14ms
15:37:40 Ping: 500; Pong: 500; Time: 14ms
15:37:40 Ping: 500; Pong: 500; Time: 14ms
15:37:40 Ping: 500; Pong: 500; Time: 14ms
15:37:40 Ping: 500; Pong: 500; Time: 16ms
...

@ahsonkhan
Copy link
Contributor

@dotnet-bot test this please

@ahsonkhan
Copy link
Contributor

Build timed out (after 120 minutes). Marking the build as aborted.
17:30:11
Build was aborted

Copy link
Contributor

@ahsonkhan ahsonkhan left a comment

Choose a reason for hiding this comment

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

Revert last commit or resolve timeout issue

@KodrAus
Copy link
Contributor

KodrAus commented Apr 6, 2017

@ahsonkhan Hmm interesting. I made a similar change in another PR and the build timed out in debug.

@ahsonkhan
Copy link
Contributor

@KodrAus, I see. It seems like there is an issue with the CI then.

@KodrAus
Copy link
Contributor

KodrAus commented Apr 6, 2017

Or an issue surfaced by CI I suppose.

@ahsonkhan
Copy link
Contributor

@dotnet-bot test this please

@ahsonkhan
Copy link
Contributor

@dotnet-bot test this please

@KodrAus KodrAus mentioned this pull request Apr 6, 2017
@shiftylogic
Copy link
Contributor Author

Turns out that ToSpan in the context of these tests is picking up an experimental version from S.B.Experimental that was implemented to be used with ReadOnlyBuffer. That version, used in this context, results in an infinite loop.

Given what we are testing here, I don't really need to call ToSpan.

@pakrym
Copy link
Contributor

pakrym commented Apr 6, 2017

@shiftylogic can we also fix that ToSpan version, people are hitting it in signalr team and random hand is hard to diagnose.

@shiftylogic
Copy link
Contributor Author

That ToSpan is working correctly for what it is supposed to be, which is specifically for ReadOnlyBuffer. I'm more interested in trying to figure out how any call to ReadableBuffer.ToSpan would ever resolve to using that extension method. There must be some implicit conversion happening.

@shiftylogic
Copy link
Contributor Author

Oh, I didn't realize that ReadableBuffer actually implemented ISequence<ReadOnlyBuffer>.

I'll take a look and see why the method ends up in an infinite loop.

FYI, the correct solution might be to expose a ToSpan extension publicly that works specifically for ReadableBuffer, since there is a faster method than exists for the generic one.

@shiftylogic
Copy link
Contributor Author

Created an issue for ToSpan (#1436). It doesn't block this merge since we aren't using it anymore.

@shiftylogic shiftylogic merged commit 5016fe6 into dotnet:master Apr 6, 2017
Drawaes pushed a commit to Drawaes/corefxlab that referenced this pull request Apr 6, 2017
* Fixes to re-enable Pipeline tests that were skipped.

* Simplify changes to pipeline tests.

* PR Changes

* Undoing previous change.

* Changes from Pavel

* ToSpan extension in this context is available. Picking up a bad one.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants