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

[For discussion] Memory management: Disable JIT compilation #1678

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

qparis
Copy link
Member

@qparis qparis commented Dec 30, 2018

This merge request adds few JVM options when package the app. They need to be discussed because they can have some impact.

  • -Xint : The most impacting: It disables JVM options. It saves about 200Mb of memory on my computer. The drawbacks are the performance. Some views take longer to appear. I believe this can be optimized
  • -XX:+UseG1GC : Use G1GC garbage collector. This should be the default so it should have no impact
  • -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:-ShrinkHeapInSteps : More aggressive heap memory size management
  • -Xmx950m -Xms32m -Xss196k : Make the JVM crash if Phoenicis takes more than 950Mo. This also make the GC more aggressive

@qparis qparis requested review from plata and madoar December 30, 2018 19:03
@madoar
Copy link
Collaborator

madoar commented Dec 30, 2018

I'm not sure about the garbage collection strategy.
At the current point in time I think it is of less importance, because a lot of the code is in my opinion not yet final, which makes it hard to tell much about the final performance.
For example I'm still working on the refactoring of our JavaFX components, which can have an impact on the performance of the UI.

I wouldn't set a custom limit for the JVM size, because the limit normally depends on the system underneath and less on the application you execute.

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

You know that saying: "Don't optimize yet". Before we don't know what's going on, we should not fiddle with such options (in my opinion).

@qparis
Copy link
Member Author

qparis commented Dec 30, 2018

This is not a code optimization, this is just some packaging options. They do not affect the développer settings and they do not require any change.

Even though, after deeper analasys, our average heap consumption is very good (~100Mb), so I do not expect @madouar optimization to change anything.

What takes a lot of memory is the code cache, especially when the JIT compiles nashorn code. At this point, it puts some compiled code that won’t ever be used again in memory.

Another thing that consumes memory is the difference between the java heap size and the used size.

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

See, this is exactly what I was talking about: If you now figured out that the JIT compilation for Nashorn is causing this behavior of the allocated memory, we can optimize the JVM args accordingly.
I'm aware that this sentence is normally used for code optimization but I think it applies to this situation as well.

Any ideas which Javascript code exactly is producing the unused code cache? Is there a way we could avoid this without touching the garbage collection settings?

@qparis
Copy link
Member Author

qparis commented Dec 30, 2018

See, this is exactly what I was talking about: If you now figured out that the JIT compilation for Nashorn is causing this behavior of the allocated memory, we can optimize the JVM args accordingly.

This is a suspicion. In fact it is really hard to profile memory.

At the end, when I run PoM with -Xint takes 160Mo at startup of memory with -Xlint and 250Mo without. However, it is wayyyy slower

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

Personally, I would prefer fast vs big in that case. In the end, I have enough memory.

@qparis
Copy link
Member Author

qparis commented Dec 30, 2018

Personally, I would prefer fast vs big in that case. In the end, I have enough memory.

It depends what is slow. For example, if you take a python program, it is way slower than a Java program and no one bother

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

"Slower" in the context of an application like Phoenicis makes only sense if it means "you can feel it".

@madoar
Copy link
Collaborator

madoar commented Dec 30, 2018

I agree with @plata, we're not developing a real time game but a management application.
Here it is not so important whether the application is a quarter second fast as long as using the application feels smooth.
Which makes the performance of the startup phase and the later loading time for the content (applications, engines, etc.) so important.

@qparis
Copy link
Member Author

qparis commented Dec 30, 2018

This is the problem we have to deal with. Performance is not a real issue, memory footprint is (POLv4 shows 70-80Mo of memory at worst whereas POLv5 can go up to 600Mo)

The differences is that POLv4 is "cheating" because it uses a lot of external processes that are not taken into account

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

If you think it is caused by the Javascript JIT: Can you turn off all Nashorn calls and see what happens?

@madoar
Copy link
Collaborator

madoar commented Dec 30, 2018

I'm basically fine with using a specific garbage collection algorithm, which fits to our current implementation, but I'm asking myself: Do we need to tackle this issue now?
I mean we're still in alpha, I think it is ok if the application is not yet tuned for performance.
In addition, if we decide to use a specific garbage collection algorithm now, we'll need to reevaluate it before each release, because the code could have changed so that a different garbage collection performs better.

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

I agree to this point.

@qparis
Copy link
Member Author

qparis commented Dec 30, 2018

We don't need to tackle this issue now, but we need to get proof the we can tackle this issue later

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

I think you provided the proof, didn't you?

Apart from this: If this is really Nashorn JIT, it might behave completely different with Graal.

@qparis
Copy link
Member Author

qparis commented Dec 30, 2018

I think you provided the proof, didn't you?

Apart from this: If this is really Nashorn JIT, it might behave completely different with Graal.

I'm not convinced for the moment

@plata
Copy link
Collaborator

plata commented Dec 30, 2018

I'm confident that we will find some solution. After all, we don't do anything crazy here. So whatever it is should be possible to fix.

@qparis qparis changed the title [To be discussed] Memory management: Disable JIT compilation [For discussion] Memory management: Disable JIT compilation Jan 5, 2019
@madoar
Copy link
Collaborator

madoar commented Jun 9, 2019

@qparis this PR has a merge conflict with the master branch. In addition I'm not sure about the current state of the performance of Phoenicis are there any changes that are introduced to Java 12 (or 13 in the future) and is there anything we can do as the developers of Phoenicis?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants