serve icon indicating copy to clipboard operation
serve copied to clipboard

Avoid redundant copies of Model members

Open mycpuorg opened this issue 6 years ago • 6 comments

Snapshot Feature introduces a new class in the following file. frontend/server/src/main/java/org/pytorch/serve/snapshot/ModelInfo.java

It is unclear how this is different from class Model, it seems redundant? If it's redundant, we should remove it. If it's not redundant, then why are moving class ModelInfo under snapshot. Since class Snaphot should, in theory, not be concerned about specifics of the model as per the documentation.

This results in duplication of members in memory. This implementation is OK for as long as the number of models is low. The moment we start scaling things the larger memory occupant members will also be duplicated. AFAIK, currently we are not using any data members that occupy large amounts of memory in ModelInfo that may not always be the case.

Instead, if we can use a class that only references members which are already loaded into memory of, say class Model, in memory that might be efficient. The urgency of this problem is unclear, depending on a "typical" usage scenario the impact of this will vary.

mycpuorg avatar Mar 28 '20 17:03 mycpuorg

Changs available in PR #152

harshbafna avatar Apr 03 '20 14:04 harshbafna

I had a look at the updated code in #152, it seems okay to me. @mycpuorg , I'm leaving this for you to pass judgement on, since you filed the issue.

fbbradheintz avatar Apr 06 '20 20:04 fbbradheintz

@mycpuorg Can you define the next action on this in the context of #152 and see if this issue can be closed?

virgo24i avatar Apr 24 '20 19:04 virgo24i

I had requested for a couple of changes to the PR, in the latest version (with my comments addressed) it looks good. Please submit the PR following the template (what was tested etc). Thanks.

mycpuorg avatar May 05 '20 17:05 mycpuorg

Reopening this since the changes have not made it to master branch yet

mycpuorg avatar May 26 '20 17:05 mycpuorg

Closing as this has been merged to master in 0.1.1 release.

harshbafna avatar Jul 27 '20 14:07 harshbafna