-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
critical refactoring: attempt to solve graal-js callonce / callSingle issues and excessive memory use for call #1685
Comments
glad could get rid of scenario-listener - that was really clunky and a new approach seems promising - clone the js engine if needed for another thread etc
so @workwithprashant I think you already figured that this solves your problem. set variables to * def out = null
* def response = null
* def response = call read('classpath:examples/library.feature@getLibraryData') |
now we have learnt that java native host-object like functions can be passed around freely in graal exploring if we convert to runnable / consumer / function as in java lambdas seems to work well - this commit tries this with the active-mq example one possible limitation is only single argument functions are supported, sure this can be overcome but it is a reasonable limit - e.g. use maps to pass data in / out
Well, it's going to be painful with setting Not sure about the approach but exploring different options. |
@workwithprashant well, please suggest a different design then. let me first say that I personally discourage over-use of so in this case if you have some complicated re-use, please use Java code and not feature files or JavaScript a suggestion given in #1675 was to use a Java singleton and write to a temp file if needed. if your tests are complicated, there will be pain. a core principle is that any variable defined using |
@workwithprashant I found a reasonable solution. use a "wrapper" variable. because "inner" variables will not be cloned. try this change: @unexpected
Scenario: Not over-writing nested variable
* def data = {}
* data.response = karate.call('classpath:examples/library.feature@getLibraryData')
* string out = data.response
* karate.log('FIRST RESPONSE = ', data.response)
* karate.log('FIRST RESPONSE SIZE = ', out.length)
* def out = null
* data.response = karate.call('classpath:examples/library.feature@getLibraryData')
* string out = data.response
* karate.log('SECOND RESPONSE = ', data.response)
* karate.log('SECOND RESPONSE SIZE = ', out.length)
* def out = null
* data.response = karate.call('classpath:examples/library.feature@getLibraryData')
* string out = data.response
* karate.log('THIRD RESPONSE SIZE = ', out.length)
* karate.log('UNEXPECTED RESPONSE = ', data.response) i'm setting |
@workwithprashant actually. you were right and we were doing an un-necessary variable definition. you can ignore my comment above. made a fix - so will be great if you can test with the latest version in |
@ptrthomas Your fix worked beautifully on sample project. PREVIOUS EXAMPLE: Called feature returning variables of calling context...
WITH THE FIX NOW:
I am going to try the fix with performance testing on actual project and compare JVM heap usage. I will update this thread with my findings (probably in 24 hours) Thank you @ptrthomas for reconsidering the approach :) |
@workwithprashant great to hear. apologies for all the grumbling - at the end I'm very glad we caught this. thanks for raising this, it possibly improves the other |
@ptrthomas I have some results to share for performance testing before and after the fix as below. Environment
Setup
Before the FIXSystem Stats : (System where tests are executed)
After the FIXSystem Stats : (System where tests are executed)
Even though results are much better, I believe that we may be able to decrease the JVM usage during performance testing. When I used the memory profiler during the start of the test, it looks like Since we don't need lot of results during performance testing, I was thinking of detecting if it's perf tests then skip some of the result calls which are not needed for Gatling (Not sure about its impact on gatling result collection). Do you have any ideas? |
@workwithprashant this is fantastic work. I will try avoid the |
@workwithprashant okay, made the change, please try now ! |
After 6d8aa7c FIXIt has helped little and I will keep investigating more. If I find something more then will raise a new request. |
@workwithprashant thanks. if you use if you can remove |
@workwithprashant an update - I tried to improve the callSingle / callonce code to avoid cloning too many objects. so ignore my message above, just run again with the latest from |
@ptrthomas I did not see any changes so I will investigate by migrating my karate scripts (performance testing scenarios) to Thank you for all the improvements!! |
@ptrthomas I had log levels set to I will try to reproduce this in sample project. |
@workwithprashant thanks that helps. this is the fix for the other issue you reported with gatling + call. but I will think of a better fix. maybe it is this hashmap coming from gatling which is the problem |
@ptrthomas I migrated my Karate scripts to Following is the profiling after first 5 minutes and these top 3 classes keeps increasing. I was passing following GC settings to gatling plugin in my framework.
It looks like JDK 16 has significant changes in GC strategy. I will try running same tests with JDK 16 and maven 3.8.1 and will update this thread. |
@workwithprashant I have been able to get VisualVM running and with the the next step here in my opinion is please simulate the problem you see within the |
@ptrthomas RC5 sounds good!! This effort is going to be iterative process and I will try to simulate the similar trend using |
1.1.0 released |
note to self to run this benchmark as part of #2546 |
cc @workwithprashant who raised this: https://stackoverflow.com/q/68411732/143475
not really looking forward to this fix. but maybe we shouldn't "return" any variables that were in the calling context
and would like to attempt a re-factor for the horrible graal-js limitation for using js objects emanating from one context on another thread e.g. #1633 and #1558
have a rough idea of moving callonce and callSingle onto a separate "special" context and try to make any use of that context thread safe. wish me luck :|
The text was updated successfully, but these errors were encountered: