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

Change default cache directory to user's home #103

Closed
hangshao0 opened this issue Oct 4, 2018 · 22 comments
Closed

Change default cache directory to user's home #103

hangshao0 opened this issue Oct 4, 2018 · 22 comments
Assignees

Comments

@hangshao0
Copy link
Contributor

hangshao0 commented Oct 4, 2018

Issue or pull request number:
eclipse-openj9/openj9#2862

Overview:
1. The default shared cache and cache snapshot directory is changed to user's home on OpenJ9 Java 11 and up on non-Windows platforms if -Xshareclasses:groupAccess is not used. The default shared cache and snapshot directory is still /tmp/javasharedresources/ if "groupAccess" is used.
2. New sub-options -Xshareclasses:bootClassesOnly and -Xshareclasses:fatal

Applies to the following JDK versions:
1. Java 11 and later for the change of default cache directory
2. Java 8 and up for the new bootClassesOnly and fatal option

Applies to the following platforms:
1. AIX, Linux X|P|Z, z/OS, for the change of default cache directory
2. All platforms, for bootClassesOnly and fatal option

For new command line options:

  • Option name and syntax: -Xshareclasses:bootClassesOnly and -Xshareclasses:fatal
  • If values are set:
    N.A.
  • Purpose:
    Option "bootClassesOnly": Disable caching of classes loaded by the non-bootstrap class loaders. This option also turns on option "nonfatal".
    Option "fatal": Do not start up the shared cache if an error occurs. This option is turned on by default except when "bootClassesOnly" is used. User can use -Xshareclasses:bootClassesOnly,fatal if they want the shared cache error to be fatal.
  • Restrictions:
    With -Xshareclasses, if we cannot user user's home as the cache directory (e.g. home is on a NFS or an error occurs when getting the home directory, etc.):
  1. If "bootClassesOnly" or "nonfatal" is used, the JVM will continue to start up without the shared cache.
  2. Otherwise JVM won't start up. There will be an error message. User can use -Xshareclasses:cacheDir= to specify the new cache directory to start up the JVM. Or change the home directory if it is on a NFS.

Migration:

  1. Users that always use "groupAccess" or "cacheDir=" in the CML won't be affected by this change.

  2. Shared caches and cache snapshots created in the obsolete default directory (/tmp/javasharedresources/) by an old JDK11 without this change cannot be started up by the new JDK11. User can use "-Xshareclasses:cacheDir=/tmp/javasharedresources/,listAllCaches" ("cacheDir=/tmp" for nonpersistent cache and snapshot) to find the caches (and cache snapshots) in the obsolete default directory. If an old shared cache is not useful anymore, use "-Xshareclasses:cacheDir=/tmp/javasharedresources/,name=cacheName,destroy" to remove it, For cache snapshot, use "-Xshareclasses:cacheDir=/tmp,name=snapshotName,destroySnapshot" to remove it.

  3. If user does not destroy the old shared cache or cache snapshot in the obsolete default directory, and the new JDK 11 is creating a new shared cache or cache snapshot with "-Xshareclasses:name=existingCacheName,cacheDir=/tmp/javasharedresources/" ("cacheDir=/tmp" for nonpersistent cache and snapshot), the old shared cache or cache snapshot will be automatically deleted and a new one will be created.

  4. If "cacheDir=" or "groupAccess" is not used in the CML, please make sure the user's home directory is not on a NFS.

@pshipton
Copy link
Member

pshipton commented Oct 4, 2018

We're going to need additional details about "default shared cache directory is changed to user's home". There are some cases where this does not occur.

@hangshao0
Copy link
Contributor Author

Added more content in the "Restrictions" part.

@pshipton
Copy link
Member

pshipton commented Oct 4, 2018

and what about group access?

@pshipton
Copy link
Member

pshipton commented Oct 4, 2018

I think this should be split into two parts since there are two PRs for the changes which can be delivered separately and in different releases. This one should cover the new options, and the other should cover moving the home directory.

@pshipton
Copy link
Member

pshipton commented Oct 4, 2018

Sorry scratch that, I guess the single PR enables caches in the home directory.

@hangshao0
Copy link
Contributor Author

and what about group access?

Added "The default shared cache and snapshot directory is still /tmp/javasharedresources/ if "groupAccess" is used"

@pshipton
Copy link
Member

pshipton commented Oct 4, 2018

Please add a migration story, what users should do if they have created a Java 11 shared cache before this was introduced.

@hangshao0
Copy link
Contributor Author

Added a migration section.

@pshipton
Copy link
Member

pshipton commented Oct 4, 2018

Snapshots should be mentioned as well since they are affected.

@hangshao0
Copy link
Contributor Author

Added cache snapshot in the migration part.

@doveye
Copy link
Contributor

doveye commented Oct 17, 2018

A few questions for starters (feel free to point out that the answers will be obvious to Java users if that's the case!):

  1. Why is the default shared class cache dir changing?
  2. Why/when would a user want to use the bootClassesOnly sub-option?
  3. I guess the fatal sub-option is there to enable better troubleshooting, ie find any issues with cache dirs up front? So why does the bootClassesOnly sub-option turn on nonfatal by default?
  4. There will be an error message. (From Restrictions point 2.) What is the error message please?

@pshipton
Copy link
Member

pshipton commented Oct 17, 2018

Why is the default shared class cache dir changing?

To put the default cache in a location that is not writable by all users.

Why/when would a user want to use the bootClassesOnly sub-option?

Mostly for debugging pr service purposes. These changes are a pre-cursor to enabling bootClassesOnly by default. Having the option allows additional command line options to be enabled at the same time, such as the verbose options. It is also possible a user may want to enable shared classes only for bootstrap classes, perhaps to reduce the risk of using shared classes, although no one has ever requested this.

I guess the fatal sub-option is there to enable better troubleshooting, ie find any issues with cache dirs up front? So why does the bootClassesOnly sub-option turn on nonfatal by default?

See the answer above. bootClassesOnly will be enabled by default at a future time, and by default we want nonfatal as well. Having bootClassesOnly enable it avoid mistakes. Adding fatal allows control over this behavior for debugging or service, or by some chance a user wants to enable bootClassesOnly but have the JVM fail to start if something is wrong with the shared cache.

@pshipton
Copy link
Member

@hangshao0 please answer 4.

@doveye
Copy link
Contributor

doveye commented Oct 17, 2018

Thanks Peter. Another question - there are statements like

please make sure the user's home directory is not on a NFS.

but currently the docs say that's a restriction only for persistent caches on AIX - is that still the case?

For AIX, the directory must not be on an NFS mount for persistent caches.

@pshipton
Copy link
Member

The AIX part is misleading, it is a restriction for persistent caches on all Windows, Linux and AIX (z/OS doesn't support persistent caches).

doveye added a commit to doveye/openj9-docs that referenced this issue Oct 17, 2018
See issue eclipse-openj9#103: eclipse-openj9#103

- New suboptions are bootClassesOnly and fatal.
- The default dir has changed from a temp dir to the user's home dir, on non-Windows platforms only, and only if groupAccess is not also specified.

[skip ci]

Signed-off-by: Esther Dovey <doveye@uk.ibm.com>
@doveye
Copy link
Contributor

doveye commented Oct 17, 2018

Hi @hangshao0 and @pshipton . I've made the doc updates (inadvertently skipped the staging part, oops). They are visible here:

I've removed the AIX mention in the existing NFS sentence too, thanks Peter for clarifying that.

@pshipton
Copy link
Member

lgtm except the following in the What's New draft is not entirely accurate.

Caches cannot be shared across different Java releases, so you cannot re-use a cache that was created by a previous level of Java 11; if you use the name and cacheDir suboptions to specify an existing cache, the cache is deleted and a new one created.

The JVM attempts to delete the obsolete cache and create a new one. Unlike on Linux/AIX, on Windows a file cannot be deleted if it is in use. In this case the new JVM will continue to use the older cache if the older cache cannot be deleted.

I missed a point in #103 (comment). The bootClassesOnly option is also useful if you want this behavior but need to change the default cacheDir location.

@hangshao0
Copy link
Contributor Author

  1. There will be an error message. (From Restrictions point 2.) What is the error message please?

There will be an NLS saying what stopped shared class from starting up. The message is different depending on what the error condition is.

@doveye
Copy link
Contributor

doveye commented Oct 17, 2018

Re #103 (comment):
Thanks Peter. How about the following replacement sentence:

In general, caches cannot be shared across different Java releases, so you cannot re-use a cache that was created by a previous level of Java 11; if you use the name and cacheDir suboptions to specify an existing cache, the VM attempts to delete the cache and create a new one. However, on Windows, the cache cannot be deleted if it is in use, in which case the VM continues to use the existing cache.

I'm not sure what you mean by "this behavior" in this sentence?

The bootClassesOnly option is also useful if you want this behavior but need to change the default cacheDir location

@pshipton
Copy link
Member

pshipton commented Oct 17, 2018

lgtm.

I'm not sure what you mean by "this behavior" in this sentence?

The bootClassesOnly option is useful if you want to have the equivalent of that is going to be enabled by default, but change the default cacheDir. I don't expect this needs to be called out in the doc, its just a point I missed mentioning earlier.

@doveye
Copy link
Contributor

doveye commented Oct 18, 2018

Ok, thanks for the clarification :)

@doveye
Copy link
Contributor

doveye commented Oct 18, 2018

Think we can close this now.

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

No branches or pull requests

3 participants