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

Issue 226: Pass jvm options #247

Merged
merged 10 commits into from
Sep 18, 2019
Merged

Issue 226: Pass jvm options #247

merged 10 commits into from
Sep 18, 2019

Conversation

Tristan1900
Copy link
Member

@Tristan1900 Tristan1900 commented Aug 7, 2019

Signed-off-by: wenqimou [email protected]

Change log description

Pass jvm options to bookie, segmentstore and controller.

Purpose of the change

Fix #226

What the code does

Pass the jvm options, override the default if it exists already.
API change

bookkeeper:
  jvm:
    memoryOpts: []
    gcOpts: []
    gcLoggingOpts: []
    extraOpts: []

pravega:
  jvm:
    controller: []
    segmentstore: []

How to verify it

Unit tests should pass. The manual deployment should also see the options are passed to the jvm.

Signed-off-by: wenqimou <[email protected]>
@andreipaduroiu
Copy link
Member

andreipaduroiu commented Aug 8, 2019

Does this also make them configurable? I only see hardcoded values.

The idea of this fix/PR is to make JVM options configurable from manifest. The operator would still add JVM options it is adding today, but users should be able to override these or add new values they may need.

@Tristan1900
Copy link
Member Author

Thanks for the review! @andreipaduroiu Yes, it is configurable. There is a method OverrideDefaultJVMOptions to override the default values or append the new values. We just need to call that method for the parameters from the manifest, and it will generate the desired set of parameters. There is also a set of unit tests to verify this method.

Copy link
Member

@andreipaduroiu andreipaduroiu left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the clarification.

Signed-off-by: wenqimou <[email protected]>
@codecov-io
Copy link

codecov-io commented Aug 9, 2019

Codecov Report

Merging #247 into master will decrease coverage by 1.65%.
The diff coverage is 8.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #247      +/-   ##
==========================================
- Coverage   32.62%   30.96%   -1.66%     
==========================================
  Files           9        9              
  Lines        1128     1211      +83     
==========================================
+ Hits          368      375       +7     
- Misses        712      788      +76     
  Partials       48       48
Impacted Files Coverage Δ
pkg/apis/pravega/v1alpha1/zz_generated.deepcopy.go 0% <0%> (ø) ⬆️
pkg/apis/pravega/v1alpha1/bookkeeper.go 100% <100%> (ø) ⬆️
pkg/apis/pravega/v1alpha1/pravega.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f1a793...732a851. Read the comment docs.

@fpj
Copy link

fpj commented Aug 11, 2019

The description says Fix #226, but the title says #246. Is #246 a duplicate of #226?

@Tristan1900 Tristan1900 changed the title Issue 246: Pass jvm options Issue 226: Pass jvm options Aug 12, 2019
@Tristan1900
Copy link
Member Author

@fpj Thanks for the notice. I opened a dup issue before. Fixing the name.

Signed-off-by: wenqimou <[email protected]>
Copy link

@RaulGracia RaulGracia left a comment

Choose a reason for hiding this comment

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

LGTM. It would be nice to have the default JVM values in the example yaml (cr-detailed.yaml) so people have a template of how to modify these values. Once you address this, I will approve. Note that this PR is a requirement for pravega/pravega#4074, so let's see if we can get it merged soon.

@RaulGracia
Copy link

@Tristan1900 it would be nice to merge this PR soon. Could you please address my prior comment regarding adding and "example" of how to modify these JVM values in cr-detailed.yaml? I will approve after you add this. Thanks!

@Tristan1900
Copy link
Member Author

Tristan1900 commented Sep 9, 2019

@RaulGracia Oh sure. Doing that now

Could you please review it again? Thanks a lot!

wenqimou added 2 commits September 9, 2019 11:49
Signed-off-by: wenqimou <[email protected]>
Signed-off-by: wenqimou <[email protected]>
@RaulGracia
Copy link

@pbelgundi please, review this PR and merge it asap if there is no additional comments on it. Note that having the functionality of this PR is becoming a pressing issue, as the new streaming cache for Pravega depends on this.

@andreipaduroiu
Copy link
Member

Looks like some tests are failing? @Tristan1900 would you mind taking a quick look and see if they're related?

@Tristan1900
Copy link
Member Author

@andreipaduroiu Thanks for the notice! I am debugging it.

Signed-off-by: wenqimou <[email protected]>
@Tristan1900
Copy link
Member Author

I just found that UnlockExperimentalVMOptions has to be specified in front of UseCGroupMemoryLimitForHeap

Signed-off-by: wenqimou <[email protected]>
pkg/apis/pravega/v1alpha1/bookkeeper.go Outdated Show resolved Hide resolved
pkg/apis/pravega/v1alpha1/bookkeeper.go Show resolved Hide resolved
pkg/apis/pravega/v1alpha1/pravega.go Outdated Show resolved Hide resolved
pkg/apis/pravega/v1alpha1/pravega.go Outdated Show resolved Hide resolved
return fmt.Sprintf("-XX:%v=%v", k, v)
}

func OverrideDefaultJVMOptions(defaultOpts []string, overrideOpts []string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this method way too complicated.....

Since the defaultOptions are in code, we could store them in a map instead of a slice like this:

defaultOptsMap := map[string]string {
"-Xms":"512m",
"-XX:+ExitOnOutOfMemoryError":"",
"-XX:+CrashOnOutOfMemoryError",:"",
"-XX:+HeapDumpOnOutOfMemoryError": "",
"-XX:HeapDumpPath=": heapDumpDir,
}
)

For Overriding default values do the following:

  1. mergedSlice = Create a new slice to holdall options [ overridden defaults + new user provided options + non-overridden default options ]
  2. for key, value := range defaultOptsMap {
    if (key is a prefix for any value in overrideSlice) {
    // do nothing, since we want to pick this value from overrideSlice
    } else {
    // add default value that is not present in overrideSlice
    mergedSlice = append(mergedSlice, key+value)
    }
  3. return mergedSliced.

Copy link
Member Author

@Tristan1900 Tristan1900 Sep 16, 2019

Choose a reason for hiding this comment

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

Thanks for the comment. I see your point and here is what I think,

  1. If the number of default options is m and the number of user-provided options is n, this line if (key is a prefix for any value in overrideSlice) will basically make the time complexity to be m*n, whereas my current way is m+n.
  2. Since iteration for map in Go does not follow the insertion order, this line for key, value := range defaultOptsMap will make the iteration in random order. However, I found that we have to specify UnlockExperimentalVMOptions before UseCGroupMemoryLimitForHeap when passing to the JVM, otherwise JVM will throw an error. So there is an order that needs to be guaranteed when passing those JVM options.

Copy link
Contributor

@pbelgundi pbelgundi Sep 16, 2019

Choose a reason for hiding this comment

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

I don't think we need to worry about execution complexity here, unless we expect the number of options ( default or user provided) to be > 100. In most cases the number of options provided ( default + user provided) should be not more than 10-15 ( At max this can go upto 30-35) which is too small a number to worry about execution complexity.
It is more important to have clear and readable code that is easier to maintain and reason about.
As regards the order of options, only a few options should be order sensitive and it should be easy to just add them first.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added some comments to make it more readable. It would be great if you could take a look at it again and see if it works. Thanks!

example/cr-detailed.yaml Outdated Show resolved Hide resolved
Signed-off-by: wenqimou <[email protected]>
Signed-off-by: wenqimou <[email protected]>
return fmt.Sprintf("-XX:%v=%v", k, v)
}

func OverrideDefaultJVMOptions(defaultOpts []string, overrideOpts []string) []string {
Copy link
Contributor

@pbelgundi pbelgundi Sep 16, 2019

Choose a reason for hiding this comment

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

I don't think we need to worry about execution complexity here, unless we expect the number of options ( default or user provided) to be > 100. In most cases the number of options provided ( default + user provided) should be not more than 10-15 ( At max this can go upto 30-35) which is too small a number to worry about execution complexity.
It is more important to have clear and readable code that is easier to maintain and reason about.
As regards the order of options, only a few options should be order sensitive and it should be easy to just add them first.

Signed-off-by: wenqimou <[email protected]>
@pbelgundi pbelgundi merged commit 656eaf1 into master Sep 18, 2019
@Tristan1900 Tristan1900 deleted the issue-226-pass-java-opts branch September 18, 2019 20:20
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

Successfully merging this pull request may close these issues.

Support passing of java options to bookkeeper from .yaml file
6 participants