Skip to content
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

IL: optimize attribute cluster reading #13821

Merged
merged 8 commits into from
Sep 23, 2022
Merged

Conversation

auduchinok
Copy link
Member

  • Removes ImmutableArray builder creation, its array reversion, another array allocation and copying for sorted tables
  • For unsorted tables it prevents the reader from going further through the table after a cluster of matching attributes is found

The second optimization may in theory break things if any compiler produced the attributes out of order, but AFAIK none of the popular compilers do it, and we have been using it for many years without ever seeing an issue. @dsyme @vzarytovskii What do you think about it?

@auduchinok
Copy link
Member Author

This is ready.

@dsyme
Copy link
Contributor

dsyme commented Sep 13, 2022

The second optimization may in theory break things if any compiler produced the attributes out of order, but AFAIK none of the popular compilers do it, and we have been using it for many years without ever seeing an issue. @dsyme @vzarytovskii What do you think about it?

Could you check if F# produces attributes out of order please, if multiple instances of the same attribute are given in source text out of order. Thanks

@auduchinok
Copy link
Member Author

auduchinok commented Sep 13, 2022

@dsyme do you mean checking if there's a case where attributes of one entity are mixed with attributes of another one? I thought the table is populated sequentially for each method, type, etc, i.e. nothing would write other things to it in the middle of generating attributes for a particular attribute owner.

@dsyme
Copy link
Contributor

dsyme commented Sep 13, 2022

@auduchinok Ignore my comment, and I think your code is fine, but to double check could you please clarify what you mean by this:

The second optimization may in theory break things if any compiler produced the attributes out of order

@auduchinok
Copy link
Member Author

auduchinok commented Sep 13, 2022

@dsyme Consider this pseudo table that says which entity does each attribute belong to:

1, Type1
2, Type1
3, Type2
4, Type1

The previous code would find all three attributes for Type1 for unsorted tables and the current one would only find one of the two separated groups. It seems the popular compilers don't produce tables like this, and I've seen this optimization used in other places, so it's probably not too bad?

@dsyme
Copy link
Contributor

dsyme commented Sep 13, 2022

@dsyme Consider this pseudo table that says which entity does each attribute belong to:

Sorry, just to be really clear, can you give headings for those columns? You mean like this?

Index     Parent      Attribute/Type/Constructor
1            Type1       SomeAttribute()
2            Type1       SomeAttribute()
3,           Type2       SomeAttribute()
4            Type1       SomeAttribute()

ECMA-335 says the CustomAttributes table must always be sorted by "Parent" so it's possible that the code not using a binary chop is never used.

@auduchinok
Copy link
Member Author

Sorry, just to be really clear, can you give headings for those columns? You mean like this?

Yes, exactly, thanks.

ECMA-335 says the CustomAttributes table must always be sorted by "Parent" so it's possible that the code not using a binary chop is never used.

Oh, indeed. I guess the original code was meant to be more generic than only getting attributes. Then all is good.

@dsyme
Copy link
Contributor

dsyme commented Sep 13, 2022

Oh, indeed. I guess the original code was meant to be more generic than only getting attributes. Then all is good.

Yup, Or else the binary chop was added later and the old code was left there to test correctness or in case we needed it

@dsyme dsyme merged commit 179db4e into dotnet:main Sep 23, 2022
vzarytovskii added a commit to vzarytovskii/fsharp that referenced this pull request Dec 20, 2022
vzarytovskii added a commit that referenced this pull request Dec 20, 2022
vzarytovskii added a commit that referenced this pull request Jan 9, 2023
vzarytovskii added a commit that referenced this pull request Jan 11, 2023
* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 1997730 (#13925) (#14041)

Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>

* Merge main to release/dev17.5 (#14043)

Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Co-authored-by: Edgar Gonzalez <edgar.gonzalez@fundourselves.com>
Co-authored-by: Eugene Auduchinok <eugene.auduchinok@jetbrains.com>
Co-authored-by: Chet Husk <baronfel@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Florian Verdonck <florian.verdonck@outlook.com>
Co-authored-by: Petr <psfinaki@users.noreply.github.com>
Co-authored-by: Petr Pokorny <petrpokorny@microsoft.com>
Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>

* Update FSharp.Editor.fsproj

I believe a bad merge happened, this line is not in main.  And the file does not exist in either branch.

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2014480 (#14049)

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2016907

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2016985

* XLF

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2017073

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2017391

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2017391

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2018131 (#14089)

* Bugfix: Ref assemblies contained .property definitions at the wrong type in generated IL (#14093)

* Bugfix: Ref assemblies contained property definitions at the wrong type

* Better comment

* Update versions for dev17.4 (#14102)

* Update versions for dev17.5 (#14100)

* Merge main to release/dev17.5 (#14098)

* Add SynType.Or. (#14058)

* Add SynType.Or for generic constrains in the form (^A or ^B):...

* Change ty1.Equals(ty2) to call static op_Equality (#13028)

Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: Don Syme <dsyme@users.noreply.github.com>

Co-authored-by: Florian Verdonck <florian.verdonck@outlook.com>
Co-authored-by: Rustam <rstm.sf@gmail.com>
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: Don Syme <dsyme@users.noreply.github.com>

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2023680 (#14133)

* Disable ref assemblies in e2e tests (#14135)

Disable reference assemblies for e2e test of type providers

Co-authored-by: Adam Boniecki <adboniec@microsoft.com>
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2024009 (#14139)

* Downgrade SDK, rc2 is failing signing (#14146)

* Generate SBOM for Fsharp (#14029) (#14169)

* Generate Sbom

* pass ci flag

* update

* Sbom generation

* Fix for trimming tests: Added nuget.org source + explicit source mapping for FSharp.Core

* Update Build.ps1

Tweaks to handle useGlobalNugetCache

Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: Kevin Ransom (msft) <codecutter.fsharp@hotmail.com>

Co-authored-by: Epsitha Ananth <47157394+epananth@users.noreply.github.com>
Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: Kevin Ransom (msft) <codecutter.fsharp@hotmail.com>

* Update Arcade & Put automated pool provider usage functionality into Dev17.4 branch (similar to PR in main now but will not be backported here) (#14177)

* [release/dev17.4] fix metadata failure due to double integration of signature (#14190)

* fix metadata failure due to double duplication

* fix metadata failure due to double duplication

Co-authored-by: Don Syme <dsyme@users.noreply.github.com>

* Global.json

* [release/dev17.4] Don't emit IsReadOnlyAttribute if not available. (#14281)

Co-authored-by: nojaf <florian.verdonck@outlook.com>

* Fixed package versions to publicly available (#14291)

* Fixed package versions to publicly available

* Update Versions.props

Microsoft.Build.* to 17.4.0

Co-authored-by: Kevin Ransom (msft) <codecutter.fsharp@hotmail.com>

* Update Versions.props

* Prefer nullable over other conversions, fixes #14302

* Replace ROSpan for DateTimeOffset as op_Implicit target, ROSpan is not defined on all test TFMs

* [release/dev17.4] F# 7 fixes (#14322)

* WIP: Fix for calling init-only setter via srtp call + allow calling special-named functions via srtp
* Fix 14097

Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Co-authored-by: Don Syme <dsyme@users.noreply.github.com>

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2051937 (#14381)

* Deploy System.Diagnostics.DiagnosticSource to Tools folder (#14417)

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2059214 (#14427)

* Revert "IL: optimize attribute cluster reading (#13821)"

This reverts commit 179db4e.

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2067933 (#14472)

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2067933

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2067933

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2068561 (#14474)

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2068115

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2068115

Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>

* Localized file check-in by OneLocBuild Task: Build definition ID 499: Build ID 2077478 (#14533)

* Revert "Merge branch 'release/dev17.5' of https://github.com/dotnet/fsharp into release/dev17.5"

This reverts commit 4d222de, reversing
changes made to 2e92791.

* Update azure-pipelines.yml

* Merge main to release/dev17.5 (#14562)

Co-authored-by: Petr <psfinaki@users.noreply.github.com>
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>

Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Co-authored-by: Edgar Gonzalez <edgar.gonzalez@fundourselves.com>
Co-authored-by: Eugene Auduchinok <eugene.auduchinok@jetbrains.com>
Co-authored-by: Chet Husk <baronfel@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Florian Verdonck <florian.verdonck@outlook.com>
Co-authored-by: Petr <psfinaki@users.noreply.github.com>
Co-authored-by: Petr Pokorny <petrpokorny@microsoft.com>
Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
Co-authored-by: Rustam <rstm.sf@gmail.com>
Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com>
Co-authored-by: Adam Boniecki <adboniec@microsoft.com>
Co-authored-by: Epsitha Ananth <47157394+epananth@users.noreply.github.com>
Co-authored-by: Kevin Ransom (msft) <codecutter.fsharp@hotmail.com>
Co-authored-by: Matt Galbraith <MattGal@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nino Floris <mail@ninofloris.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants