Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimizes implicit assembly loading. Helps to reduce amount of faulted LoadAssembly calls.#528

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

dmitriyse
Copy link
Contributor

What does this implement/fix? Explain your changes.

  1. Assembly.GetTypes replaced to Assembly.GetExportedTypes. So we are really skipping non-public types now.
  2. Type.IsNested types are excluded from the names collection that is used for implicit assembly loading.

Does this close any currently open issues?

no
...

Any other comments?

VS 2017 + Docker is insensitive to DebuggerNonUserCode, and LoadAssembly exceptions produces long trash in the debug log.

  • This fix speedups unit tests (up to 3x). And probably speedups initialization of production projects.
    ...

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself toAUTHORS
  • Updated theCHANGELOG

@mention-bot
Copy link

@dmitriyse, thanks!@vmuriart,@tonyroberts,@cgohlke,@tiran and@BartonCline, please review this.

@codecov
Copy link

codecovbot commentedAug 23, 2017
edited
Loading

Codecov Report

Merging#528 intomaster willdecrease coverage by0.63%.
The diff coverage is61.9%.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #528      +/-   ##==========================================- Coverage    77.4%   76.76%   -0.64%==========================================  Files          63       64       +1       Lines        5589     5630      +41       Branches      892      894       +2     ==========================================- Hits         4326     4322       -4- Misses        970     1013      +43- Partials      293      295       +2
FlagCoverage Δ
#setup_linux69.42% <ø> (ø)⬆️
#setup_windows75.95% <61.9%> (-0.63%)⬇️
Impacted FilesCoverage Δ
src/runtime/pythonengine.cs77.68% <57.14%> (-0.64%)⬇️
src/runtime/assemblymanager.cs87.3% <64.28%> (-1.8%)⬇️
src/runtime/constructorbinding.cs9.85% <0%> (-29.58%)⬇️
src/runtime/overload.cs58.33% <0%> (-15.58%)⬇️
src/runtime/pyiter.cs63.63% <0%> (-13.64%)⬇️
src/runtime/iterator.cs81.81% <0%> (-7.08%)⬇️
src/runtime/genericutil.cs82.81% <0%> (-3.13%)⬇️
src/runtime/moduleobject.cs81.6% <0%> (-1.54%)⬇️
src/runtime/pyobject.cs38.85% <0%> (-0.92%)⬇️
src/runtime/runtime.cs90.98% <0%> (-0.4%)⬇️
... and5 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatefb84cd2...f016059. Read thecomment docs.

@dmitriysedmitriyseforce-pushed theimplicit_assembly_load_opt branch froma13e4f6 toe2efddaCompareAugust 28, 2017 13:14
@dmitriysedmitriyseforce-pushed theimplicit_assembly_load_opt branch frome2efdda to9304d72CompareSeptember 4, 2017 15:23
@dmitriysedmitriyseforce-pushed theimplicit_assembly_load_opt branch 2 times, most recently from09acf53 toe7edeabCompareSeptember 7, 2017 15:51
@dmitriysedmitriyseforce-pushed theimplicit_assembly_load_opt branch frome7edeab to1fd5998CompareSeptember 22, 2017 01:30
@dmitriysedmitriyse mentioned this pull requestNov 2, 2017
@dmitriysedmitriyseforce-pushed theimplicit_assembly_load_opt branch from1fd5998 toe4764f2CompareNovember 16, 2017 22:12
@dmitriysedmitriyseforce-pushed theimplicit_assembly_load_opt branch frome4764f2 tod09fc92CompareJanuary 12, 2018 18:41
Type[] types = new Type[0];
try
{
types = assembly.IsDynamic ? assembly.GetTypes():assembly.GetExportedTypes();
Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitriyse can you please add explanation for why you added check forisDynamic?

Copy link
Contributor

Choose a reason for hiding this comment

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

should there be a test for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

According to thedocumentation, GetExportedTypes() is not supported on dynamic types and will throwNotSupportedException

Copy link
Contributor

Choose a reason for hiding this comment

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

@Cronan good explanation! still maybe worth adding a comment about this. especially explaining the switch from GetTypes to GetExportedTypes for normal types.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitriyse@Cronan ok, I see this comment in the header of the PR:

Assembly.GetTypes replaced to Assembly.GetExportedTypes. So we are really skipping non-public types now.
Type.IsNested types are excluded from the names collection that is used for implicit assembly loading.

foreach (Type t in types)
{
if ((t.Namespace ?? "") == nsname)
{
names.Add(t.Name);
if (!t.IsNested)
Copy link
Contributor

Choose a reason for hiding this comment

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

@why is this nested check needed? should there be a test for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitriyse ok, I see this comment in the header of the PR:

Type.IsNested types are excluded from the names collection that is used for implicit assembly loading.

catch(TypeLoadException)
{
// Do nothing.
// This problem usually occurs when transitive dependencies have references to older packages than main application.
Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitriyse what do you mean by transitive dependencies?

Copy link
Contributor

@CronanCronanFeb 8, 2018
edited
Loading

Choose a reason for hiding this comment

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

I may be wrong, butReflectionTypeLoadException is thrown by GetTypes() if any of the dependent assemblies can't be loaded (with a list of the loaded types), but GetExportedTypes() throwsFileNotFoundException with no information. I'm not sure if TypeLoadException is thrown here.

den-run-ai reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

@Cronan i think you are right about TypeLoadException -> ReflectionTypeLoadException, these are 2 different exceptions and I believe this was a typo from@dmitriyse:

https://msdn.microsoft.com/en-us/library/system.typeloadexception(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.reflection.reflectiontypeloadexception(v=vs.110).aspx

@@ -8,6 +8,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
## [unreleased][]

### Added
- Optimized implicit assembly loading on module import, PythonEngine.ImplicitAssemblyLoading event added.
Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitriyse please add reference to this pull request and issues from which you referred to this pull request.

@@ -196,7 +196,17 @@ public static Assembly LoadAssembly(string name)
Assembly assembly = null;
try
{
assembly = Assembly.Load(name);
var importEvent = new ImplicitAssemblyLoadingEventArgs(name);
Copy link
Contributor

Choose a reason for hiding this comment

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

@dmitriyse why did you augment assembly loading with this event, I cannot see the purpose of this.

@den-run-ai
Copy link
Contributor

@dmitriyse I left some comments in this pull request. Once you explain the intent of this code, feel free to merge this one with all CI's passing tests. And please address@Cronan concern with likely incorrect exception names.

@den-run-ai
Copy link
Contributor

@Cronan thanks for reviewing this!

@dmitriyse if you can come up with a test for nested types, that would be great.

@filmor
Copy link
Member

To be honest, I don't see the point of the whole event/event-args part of this pull request.SkipAssemblyLoad is never set explicitly, so I fail to see where we actually skip anything. I'll prepare a PR that only includes theIsNested check andGetExportedTypes, that should do the trick.

@filmor
Copy link
Member

Superceded by#723.

@filmorfilmor closed thisOct 29, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@CronanCronanCronan left review comments

@den-run-aiden-run-aiden-run-ai left review comments

@tonyrobertstonyrobertsAwaiting requested review from tonyroberts

@filmorfilmorAwaiting requested review from filmor

@vmuriartvmuriartAwaiting requested review from vmuriart

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@dmitriyse@mention-bot@den-run-ai@filmor@Cronan

[8]ページ先頭

©2009-2025 Movatter.jp