-
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
String map performance improvement #9470
Conversation
I guess String.Create api is not available? |
@Rodrigo-Andrade Indeed, see the link, I investigated that, and showed timings (which are better), though I knew it cannot be used because it creates a dependency for framework projects. Though this is still a reasonable improvement, I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff
It seems, that the changeset in this PR is identical to #9469. |
@abelbraaksma, It was used in a bunch of places in the BCL to reduce the creation of string builders for small strings. It is used extensively in BCL .ToString() implementations funnily enough. I have often wondered whether it would be of benefit in FSharp.Core. Here is an example of it in use: https://github.com/dotnet/runtime/blob/8f8cfd446db5227d2685b7c0fe63084c776019ff/src/libraries/System.Net.Http/src/System/Net/Http/Headers/TransferCodingHeaderValue.cs#L123 Do you think it would be worthwhile trying it out, to see if it is beneficial, because we could probably use it to improve allocations of most stringbuilders in FSharp.Core. Effectively for small strings the StringBuilder cache would eliminate keep reallocating a string builder. At the cost of 1 string builder per thread. |
@KevinRansom, several methods that were used originally, like I noticed with many timings, when the expected size is known beforehand, it is just much, much faster in almost all cases to not use either the This is in part because the constructor of In my own code I usually choose
I've been thinking about that a bit. But the same rules in general apply: the cached builder is already used in many cases through other BCL methods and it still adds a lot of overhead, esp for small concats, compared to either For uses in FCS that are string-intensive, we might get a lot of benefit by using |
Sourcelink errors, not sure what causes this: https://github.com/dotnet/fsharp/pull/9470/checks?check_run_id=780410684 |
@vzarytovskii, my apologies. This is meanwhile fixed. I accidentally cross-merged between branches. |
@abelbraaksma , yes when the size is known ahead of time a single allocation is waaaay better than stringbuilder. However, if the cached sb is already bigger than the string to be built then there should be no allocation at all.
This surprises me, because the benefit of the cache was supposed to be for small stringbuilds. If the required string is bigger than the cache limit then a new sb is used, if the sb grows above the limit a new sb is used. |
@KevinRansom That was my take as well, and I turned out to be wrong. There's always the allocation of the final string, which copies the relevant buffer to the immutable string. Real advancement can only be made if we skip the extra copy step (fixed, span, or use In some cases the buffering is the fastest method, sometimes it isn't. The overhead of the buffering never wins from There's certainly no "one size fits all", and after learning a lot about SB, I'm still surprised it's often so much slower. My take is that it has to do with the method call overhead, as it's called for each 16 bit char. The differences are much less (but still present) with Perhaps we should continue this in the main issue? As it applies to almost all functions. #9390. |
@abelbraaksma the returned string allocation, is a constant requirement. However, the sb cache should only require that one allocation for strings under 360 chars. Whereas this PR, (and it's definitely a big improvement over the existing version, requires 2 allocations), the initial buffer on line 27 and the returned string. I would really like to understand whether there is any benefit to the SB cache, because we could probably use that same technique where-ever we use an SB in fsharp.core. |
I thought the same, but the bug mystery is, it requires 3. This followed from BDN analysis and was constant: with the initial string, it required 4x the mem size of the string. Same is true for SB, but maybe I missed something. I discussed this in Slack with @baronfel, but we couldn't explain the extra allocation. With
@KevinRansom, I linked an example in the main issue, the benefit shows there clearly when used with enumerables. |
I will take a look, there could be a bug in SB I suppose, or even the cache. These mysteries are what make our job fun and miserable at the same time. I have your code in the copy buffer, as soon as I finish the email I'm on, I'm gonna look. BTW @cartermp is a l33t nerdsniper but it seems as if you are approaching his nerd-snipping skillz. :-) |
@abelbraaksma do you have the bdn benchmark somewhere? |
@KevinRansom, I'm also on Slack, if you prefer an in depth discussion of findings and possibilities, I've investigated a lot in string optimizations in my own parser/compiler, we can always set up a brainstorm session or call :) |
@NinoFloris, did you check the linked issue? All relevant timings are there. |
That would be good, however, I am at home, with two noisy kids running about. So I expect to be a bit distracted for a while. |
I was mostly interested in
Not sure which of the functions shows that phenomenon |
@NinoFloris, it's this function (it applies to more functions there, but this was the main focus): let fasterMap mapper str =
if String.IsNullOrEmpty str then String.Empty
else
let result = str.ToCharArray()
let mutable i = 0
for c in result do
result.[i] <- mapper c
i <- i + 1
String result To compare, the following gives 2x input size as mem use, as opposed 4x input size for the above function and the let fixedStrCopySrcIdx2 (mapper: char -> char) (str: string) =
let len = String.length str
let result = String.Copy str
use shadow = fixed result
let mutable i = 0
while i < len - len % 2 do
NativePtr.set shadow i (mapper str.[i])
NativePtr.set shadow (i + 1) (mapper str.[i + 1])
i <- i + 2
while i < len do
NativePtr.set shadow i (mapper str.[i])
i <- i + 1
result The timings of this function can be found in the tables of this comment: #9390 (comment). The BDN benchmark function looks like this, where
The module module Data =
let get value =
match value with
| 0 -> String.Empty
| 1 -> "A"
| 2 -> "Ab"
// etc
| 1024 -> large1024 // `global let bindings so they're loaded only once during cctor |
@abelbraaksma well you totally nerd-sniped me. I reimplemented StringBuilderCache and reworked the func to use it and I get these results, and they are mixed. The string being mapped is 30 characters : ''''C:\kevinransom\interactive\src''''
It should be noted that perf in this PR is unbeatable, which was to be expected. The character copying is just array element to array element ... that's really ... really nice. The allocations however using the cached String Builder are slightly more than twice the improvements in this PR. We could combine this PR along with a CharBuffer class to get the memory improvements and the great perf. If we were to go with that approach, we could use it all over the bcl when doing this kind of char copying code. What do you think?
|
How would we write the string copy to be faster? |
One other thing, we have tried to minimize the dependency that FSharp.Core takes so taking a dependency on System.Buffer is probably not something we will do. It is in netstandard2.1 and would require us to stop targeting desktop for FSharp.Core apps. However, the code for the cache isn't a lot of code and the grabbed memory is small. The benefit accrues to smaller strings, but there are many more of those than stonking great large strings. If I can speed up the iteration I think I would prefer to take the cached version, because lowering allocations is pretty helpful |
@KevinRansom the version of System.Buffers I see on Nuget says it supports net45 and net461, surely that qualifies? https://www.nuget.org/packages/System.Buffers/ |
@baronfel , in an ideal world you would be correct, however, everyone that ships an App dependent on FSharp.Core which is almost everybody who builds a desktop app using the fsharp compiler would also have to ship System.Buffers.dll. I'm absolutely certain that loads of people would get that wrong. We messed up when took a dependency on it in VS. Today FSharp.Core only has a dependency on things that can be retrieved from the desktop framework, with the exception of ValueTuple, which it needs for reflection helpers. And even then everything else works if ValueTuple is not found. Kevin |
@KevinRansom, there's a discussion about I've created a discussion topic here: #9501, as we have veered quite far from just this PR ;). |
@abelbraaksma , @cartermp says you have an implemention using fixed, can we take a look at that again. That seems like the lowest friction, and likely best performing approach to take. |
@KevinRansom, in the light of this issue? Or as a more general approach, because I'd like to move that to #9501 (I'll update there with some answers to your questions). Indeed, I did make it for The timings are published here: #9470 (comment). If you check, for instance, the The The simplest version, without unrolling, looks as follows (the unrolled version is in the comment above): let mapWithFixed(mapper: char -> char) (str: string) =
let len = String.length str
let result = String.Copy str
use shadow = fixed result
let mutable i = 0
while i < len do
NativePtr.set shadow i (mapper str.[i])
i <- i + 1
result Note that at the bottom of that comment all versions I tried, including the ones using |
You’ve nerd snipped both me and Will now. We are having such a lot of fun in the convo will be fine.
|
I really have to put that up on my chimney (if I still had one), you're honestly the first ever who I've seen using the phrase "nerd snipped", but it certainly makes me smile :). Btw, who's Will? Smith? |
@abelbraaksma can you ping me using my work email address pls. |
Okay I logged into fsharp.org general as codecutter. |
Will is indeed Mr Smith. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does a good job on reducing allocations, and is faster too.
edit, I've moved my comment here: #9501 (comment) |
Last change 83ac13d is only in tests, following up on a comment from @KevinRansom to get rid of "foo" in tests, just kind find the original comment. Anyway, nothing functionally changed, all's still green. |
* Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves #9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl>
* Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves #9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl>
* Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet/fsharp#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl>
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves #9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (#9516) (#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) (#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) (#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (#9644) (#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (#9657) (#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (#9657) (#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) (#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix #9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f396177996a7d63e1ce650423993f07facd8239. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet/fsharp#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (#9516) (#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) (#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) (#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (#9644) (#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (#9657) (#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (#9657) (#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) (#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet/fsharp#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
* Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl>
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
* string interploation implementation * string interploation tests * escape {{ }}, test verbatim and triple quote, implement .NET specifiers * fix tests * string interpolation tests: internal representation corner cases * string-interp tests should have --langversion:preview * string interop tests: sprintf * string interp tests: format specifier negative cases * string interp tests: format specifier negative cases, .NET-style padding * fix nested interp strings * style cleanup * lex: unify string interp stack and counter * string-interp: add test cases * fix mixed quote nested string interpolation * string-interp: add test case for multiple interpolation points with different indentation * lexfilter: push new CtxtParen at endPos for INTERP_STRING_PART and INTERP_STRING_BEGIN_PART * lexfilter: do not check undentation limit for string interpolation tokens. * FormattableString prototype * add FormattableString support * negative error checking * remove diagnostics * simpler FormattableString implementation * fix test * add testing for nested * add IFormattable support * tweak error message * tests: StringInterpolation: fix case errors * fix error message * check number of values matches * allow use of format strings with printf and friends * update baselines * fix baselines * add Experimental attributes * update string interp negative tests * stringinterp test: add PrintFormat tests * printf: fix empty interpolation string evaluates to null in printf env * enable test corectly * Revert "printf: fix empty interpolation string evaluates to null in printf env" This reverts commit 7f39617. * simplify codegen for interpolated strings * fix build * fix build * Merge master to feature/string-interp (dotnet#9580) * Update dependencies from https://github.com/dotnet/arcade build 20200626.2 (dotnet#9577) Microsoft.DotNet.Arcade.Sdk From Version 1.0.0-beta.20302.3 -> To Version 1.0.0-beta.20326.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Improve perf for String.filter up to 3x (dotnet#9509) * Improve perf for String.filter 2-2.5x * Cleanup: remove "foo" etc in tests * Add tests for new execution path for LOH in String.filter * Change test string * String map performance improvement (dotnet#9470) * Simplify and improve perf of String.length * Improve performance of String.map * Revert "Simplify and improve perf of String.length" * Resolves dotnet#9470 (comment) * Lingering space * Change `String` to use `new` to clarify use of ctor * Add some better tests for String.map, add side-effect test * Add tests to ensure the mapping function is called a deterministically amount of times * Fix typo * Remove "foo" from String.map tests * Perf: String.replicate from O(n) to O(log(n)), up to 12x speed improvement (dotnet#9512) * Turn String.replicate from O(n) into O(log(n)) * Cleanup String.replicate tests by removing usages of "foo" * String.replicate: add tests for missing cases, and for the new O(log(n)) cut-off points * Improve String.replicate algorithm further * Add tests for String.replicate covering all lines/branches of algo * Fix accidental comment Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Re enable tests for operators: OperatorsModule1.fs and OperatorsModule2.fs (dotnet#9516) (dotnet#9589) * Re-enabling tests from OperatorsModule1/2.fs (compile errors) * Fix compile errors in OperatorsModule1/2.fs, fix tests. Note tanh test comment. * Fix `tanh` test, ensure stable result on x86 vs x64 runtimes * Stop using exception AssertionException, so that test window shows useful info * Whitespace cleanup and redundant code removal * Cleanup spelling etc * Re-enabling int, int16, int32, int64, nativeint, incr, nullArg etc tests * Special-case floating-point assertion messages for higher precision output * Fix/update/add tests (some still failing) * Separate Checked tests, add & fix others, differentiate framework/bitness for some tests * Add branch for .NET Native (ignore cos test) * Resorting to comparing floats with a delta using Assert.AreNearEqual * Add some more tests Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9599) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) (dotnet#9604) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> * Merge master to feature/string-interp (dotnet#9615) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> * Merge master to feature/string-interp (dotnet#9619) * Moved fsharpqa/Libraries/Core/Unchecked test cases to NUnit (dotnet#9576) * Moved fsharpqa/Libraries/Core/Reflectiontest cases to NUnit (dotnet#9611) * Migrated PreComputedTupleConstructor01.fs test case * Migrated PreComputedTupleConstructor02.fs test case * Migrated DU.fs and Record.fs test cases * Allow notebook to discover location of shared framework (dotnet#9596) Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> * Text tweeks * don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644) (dotnet#9648) Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> * yeet (dotnet#9657) (dotnet#9661) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * yeet (dotnet#9657) (dotnet#9670) yeet Co-authored-by: Phillip Carter <pcarter@fastmail.com> * fix up tokenizer tests * fix code review things * fix code review things * fix code review things * fix code review things * add various testing * correct continuations for interpolated strings * fix lexer continuations and colorization for multi-line interpolated strings * revert xlf changes * fix assert * completion and brace matching (not all tests passing yet) * Fix rebuild * fix various niggles and get tests working * fix printf when '%a' in final position * fix test case * interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix triple quote interpolated string specifer highlighting * fix build * fix missing error message * fix % specifiers for interpolated strings * fix % specifiers for interpolated strings * fix FCS tests * minor nits from code review * code review feedback and use struct tuples in more places * revert struct tuples * use struct tuples where possible, byrefs for index * fix byref for index * fix ksprintf block size * make recent cache entry more explicit (cleanup) * improve performance * remove unused code * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) (dotnet#9848) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Move existing Compiler.ComponentTests to a new Compiler.fs framework (dotnet#9839) * Move existing Compiler.ComponentTests to a new Compiler.fs framework; Add 'parse' function * Changed some wording in error messages * fix dotnet#9893 * fix unmantched right brace in interp string Co-authored-by: Yatao Li <yatli@microsoft.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com> Co-authored-by: dotnet bot <dotnet-bot@dotnetfoundation.org> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Abel Braaksma <abel.online@xs4all.nl> Co-authored-by: Thorsten Reichert <ThorstenReichert@users.noreply.github.com> Co-authored-by: Phillip Carter <pcarter@fastmail.com> Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
As in the title: Improve performance of String.map by 2 - 2.5x and reduce mem and GC pressure by 10%. For details of measurements, see #9390 (comment)
I decided not to go for special-casing small values or loop-unrolling as for this specific case, the benefits don't outweigh the costs of the added complexity.
The chosen approach is the array-based approach.