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

Python to CLR string marshaling LRU cache.#538

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

Closed

Conversation

dmitriyse
Copy link
Contributor

What does this implement/fix? Explain your changes.

Adds string marshaling LRU cache (10k entries per marshaling type).
This greatly speedups mixed clr/py code. + Saves big amount of memory on large structures translation.

Does this close any currently open issues?

...

Any other comments?

This code is well tested in the high-load project. Memory usage was dramatically decreased after this improvement.

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,@tiran,@cgohlke and@hsoft, please review this.

@codecov
Copy link

codecovbot commentedSep 7, 2017

Codecov Report

Merging#538 intomaster willdecrease coverage by0.01%.
The diff coverage is79.33%.

Impacted file tree graph

@@            Coverage Diff            @@##           master    #538      +/-   ##=========================================- Coverage   77.12%   77.1%   -0.02%=========================================  Files          65      71       +6       Lines        5547    5857     +310       Branches      889     933      +44     =========================================+ Hits         4278    4516     +238- Misses        981    1033      +52- Partials      288     308      +20
FlagCoverage Δ
#setup_linux73.64% <73.8%> (-2.07%)⬇️
#setup_windows76.28% <75.48%> (-0.19%)⬇️
Impacted FilesCoverage Δ
src/runtime/nativecall.cs100% <ø> (+2.22%)⬆️
src/runtime/pythonengine.cs80.35% <ø> (+1.66%)⬆️
src/runtime/pyscope.cs57.92% <100%> (-0.79%)⬇️
src/runtime/assemblymanager.cs89.83% <100%> (+0.05%)⬆️
src/runtime/genericutil.cs86.36% <100%> (+0.42%)⬆️
src/runtime/metatype.cs71.55% <100%> (ø)⬆️
src/runtime/moduleobject.cs85% <100%> (-0.06%)⬇️
src/runtime/delegatemanager.cs88.18% <100%> (-0.42%)⬇️
src/runtime/typemanager.cs84.16% <100%> (+0.13%)⬆️
src/runtime/classderived.cs88.41% <100%> (+0.07%)⬆️
... and25 more

Continue to review full report at Codecov.

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

@codecov
Copy link

codecovbot commentedSep 7, 2017
edited
Loading

Codecov Report

Merging#538 intomaster willdecrease coverage by0.43%.
The diff coverage is64.77%.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #538      +/-   ##==========================================- Coverage    76.9%   76.47%   -0.44%==========================================  Files          63       69       +6       Lines        5798     6015     +217       Branches      950      991      +41     ==========================================+ Hits         4459     4600     +141- Misses       1025     1081      +56- Partials      314      334      +20
FlagCoverage Δ
#setup_linux68.55% <ø> (ø)⬆️
#setup_windows75.71% <64.77%> (-0.41%)⬇️
Impacted FilesCoverage Δ
src/runtime/assemblymanager.cs87.03% <ø> (ø)⬆️
src/runtime/pyobject.cs39.01% <0%> (-1.33%)⬇️
src/runtime/runtime.cs86.95% <100%> (+0.23%)⬆️
src/runtime/perf_utils/RawImmutableMemBlock.cs48.14% <48.14%> (ø)
src/runtime/CustomMarshaler.cs58.09% <48.93%> (+0.56%)⬆️
src/runtime/perf_utils/RawMemoryFifoDictionary.cs65.21% <65.21%> (ø)
...runtime/perf_utils/EncodedStringsFifoDictionary.cs70.37% <70.37%> (ø)
src/runtime/perf_utils/FifoDictionary.cs70.83% <70.83%> (ø)
...rc/runtime/perf_utils/EncodingGetStringPolyfill.cs75% <75%> (ø)
src/runtime/perf_utils/RawMemUtils.cs84.48% <84.48%> (ø)
... and7 more

Continue to review full report at Codecov.

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

@vmuriart
Copy link
Contributor

Can you rebase this PR? looks like it was started out of a different PR that was already merged in.

@dmitriyse
Copy link
ContributorAuthor

This PR depends on one non merged PR#534

Also I rebased all PR that depends on merged PRs#518 and#519

@den-run-ai
Copy link
Contributor

@jakrivan can you add your comments as inline according to the code changes in this PR:

https://github.com/pythonnet/pythonnet/pull/538/files

JanKrivanek added a commit to JanKrivanek/pythonnet that referenced this pull requestFeb 12, 2018
@JanKrivanek
Copy link
Contributor

@denfromufa - inline comment added:#625

However it's just one from many things that would need to be adjusted to support multi-domain usages. So feel free to reject - not to spoil the code with irrelevant comment.

filmor pushed a commit that referenced this pull requestOct 16, 2018
filmor pushed a commit to filmor/pythonnet that referenced this pull requestOct 16, 2018
@filmor
Copy link
Member

Note to self: This PR needs to be adjusted to the changes I made to PR#534, I renamed theTestsSuite class.

}
catch
{
// Do nothing with this. Very strange problem.
Copy link
Member

Choose a reason for hiding this comment

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

When does this happen?

Marshal.FreeHGlobal(mem);
throw;
stringBytesCount = PyEncoding.GetByteCount(s);
mem = Marshal.AllocHGlobal(stringBytesCount + 4);
Copy link
Member

Choose a reason for hiding this comment

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

Why+4, wouldn't one additional byte be enough?

return Runtime.IsPython3
? Instance.MarshalManagedToNative(s)
: Marshal.StringToHGlobalAnsi(s);
if (Runtime.IsPython3)
Copy link
Member

Choose a reason for hiding this comment

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

This means that your optimisation will only work at all for Python 3, is that necessary?

@filmorfilmor added the next labelNov 15, 2018
@filmorfilmor added this to the2.4.0 milestoneNov 15, 2018
@filmorfilmor mentioned this pull requestJan 18, 2019
@filmorfilmor modified the milestones:2.4.0,2.4.1Apr 12, 2019
@lostmsu
Copy link
Member

As a performance change this needs to be accompanied by a performance test, that sets up a baseline.

E.g. first, a test must be merged, that sets the baseline performance goal without this change, then this PR should update the goal with the improved value.

@filmor
Copy link
Member

This is also probably unmergable in its current form, I have just kept it open for reference.

@lostmsulostmsu removed this from the2.4.1 milestoneMar 4, 2020
@filmorfilmor removed the next labelJun 9, 2020
@filmorfilmor closed thisAug 9, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@filmorfilmorfilmor left review comments

@tonyrobertstonyrobertsAwaiting requested review from tonyroberts

@den-run-aiden-run-aiAwaiting requested review from den-run-ai

@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.

7 participants
@dmitriyse@mention-bot@vmuriart@den-run-ai@JanKrivanek@filmor@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp