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

Improve performance of unwrapping .NET objects passed from Python#930

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

Merged
filmor merged 13 commits intopythonnet:masterfromfilmor:losttech-perf-interop
May 16, 2020

Conversation

filmor
Copy link
Member

UpstreamsQuantConnect#31 by@lostmsu.

Comment by the author:

This addresses the following scenario:

  1. A C# objecta is created and filled with some data.
  2. a is passed via Python.NET to Python. To do that Python.NET creates a wrapper objectw, and stores reference toa in one of its fields.
  3. Python code later passesw back to C#, e.g. callsSomeCSharpMethod(w).
  4. Python.NET has to unwrapw, so it reads the reference toa from it.

Prior to this change in 4. Python.NET had to determine what kind of an objecta is. If it is an exception, a different offset needed to be used. That check was very expensive (up to 4 calls into Python interpreter).

This change replaces that check with computing offset unconditionally by subtracting a constant from the object size (which is read from the wrapper), thus avoiding calls to Python interpreter.

@filmorfilmor requested a review fromlostmsuAugust 2, 2019 10:46
This addresses the following scenario:1. A C# object `a` is created and filled with some data.2. `a` is passed via Python.NET to Python. To do that Python.NET   creates a wrapper object `w`, and stores reference to `a` in one of   its fields.3. Python code later passes `w` back to C#, e.g. calls `SomeCSharpMethod(w)`.4. Python.NET has to unwrap `w`, so it reads the reference to `a` from it.Prior to this change in 4. Python.NET had to determine what kind of anobject `a` is. If it is an exception, a different offset needed to beused. That check was very expensive (up to 4 calls into Pythoninterpreter).This change replaces that check with computing offset unconditionallyby subtracting a constant from the object size (which is read from the wrapper),thus avoiding calls to Python interpreter.
@filmorfilmorforce-pushed thelosttech-perf-interop branch from2dea84a to39add65CompareAugust 2, 2019 10:46
@codecov-io
Copy link

codecov-io commentedNov 21, 2019
edited
Loading

Codecov Report

Merging#930 intomaster willdecrease coverage by0.33%.
The diff coverage isn/a.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #930      +/-   ##==========================================- Coverage   86.66%   86.33%   -0.34%==========================================  Files           1        1                Lines         300      300              ==========================================- Hits          260      259       -1- Misses         40       41       +1
FlagCoverage Δ
#setup_linux64.66% <ø> (-0.67%)⬇️
#setup_windows72.00% <ø> (ø)
Impacted FilesCoverage Δ
setup.py86.33% <0.00%> (-0.34%)⬇️

Continue to review full report at Codecov.

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

@lostmsulostmsu self-assigned thisFeb 21, 2020
@lostmsu
Copy link
Member

lostmsu commentedFeb 21, 2020
edited
Loading

Now we need to update the perf goal accordingly.@filmor, can cherry-pickc2ddaa0 into this branch?

Tried to do it myself, but got

! [remote rejected] filmor/losttech-perf-interop -> filmor/losttech-perf-interop (permission denied)

Copy link
Member

@lostmsulostmsu left a comment

Choose a reason for hiding this comment

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

Needsc2ddaa0 to be cherry-picked into this branch.

@filmor
Copy link
MemberAuthor

Sorry for the delay, cherry-picking didn't work (I assume the given commit is not in any of the branches on the main fork).

@lostmsu
Copy link
Member

Hm, it shows in this fork. This is a very small change though, you can copy it manually.

@filmor
Copy link
MemberAuthor

I did (just before commenting ;)).

@filmorfilmor merged commit4a92d80 intopythonnet:masterMay 16, 2020
@filmorfilmor deleted the losttech-perf-interop branchMay 16, 2020 20:34
lostmsu added a commit to losttech/pythonnet that referenced this pull requestJun 15, 2020
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this pull requestJun 29, 2020
…thonnet#930)This addresses the following scenario:1. A C# object `a` is created and filled with some data.2. `a` is passed via Python.NET to Python. To do that Python.NET   creates a wrapper object `w`, and stores reference to `a` in one of   its fields.3. Python code later passes `w` back to C#, e.g. calls `SomeCSharpMethod(w)`.4. Python.NET has to unwrap `w`, so it reads the reference to `a` from it.Prior to this change in 4. Python.NET had to determine what kind of anobject `a` is. If it is an exception, a different offset needed to beused. That check was very expensive (up to 4 calls into Pythoninterpreter).This change replaces that check with computing offset unconditionallyby subtracting a constant from the object size (which is read from the wrapper),thus avoiding calls to Python interpreter.Co-authored-by: Victor Milovanov <lost@losttech.software>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lostmsulostmsulostmsu approved these changes

Assignees

@lostmsulostmsu

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@filmor@codecov-io@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp