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

Fix slow allocation of memory #2743

Merged
merged 5 commits into from
Jul 20, 2018
Merged

Conversation

keithc-ca
Copy link
Contributor

Some systems (e.g. Windows Subsystem for Linux) ignore the requested allocation address and repeatedly return the same address. When this happens we terminate the loop early to avoid excessive delays.

More recently, we've seen slow startup on z Linux as well. This change helps there too.

This is marked as 'WIP' because we need to understand what, if any, detrimental effects this has.

@keithc-ca
Copy link
Contributor Author

Here's some data comparing times for java -version first without and with this change.

Without this change:

openjdk version "10.0.1-internal" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1-internal+0-adhoc.keithc.jdk10)
Eclipse OpenJ9 VM (build ddr-06b6050, JRE 10 Linux s390x-64-Bit Compressed References 20180711_000000 (JIT enabled, AOT enabled)
OpenJ9   - 06b6050
OMR      - 9a62d4f
JCL      - e180ae0 based on jdk-10.0.1+10)

     1: real 0m1.620s user 0m0.191s sys 0m1.454s
     2: real 0m1.045s user 0m0.196s sys 0m0.873s
     3: real 0m1.816s user 0m0.177s sys 0m1.661s
     4: real 0m1.849s user 0m0.183s sys 0m1.691s
     5: real 0m8.907s user 0m0.185s sys 0m8.728s
     6: real 0m1.005s user 0m0.182s sys 0m0.847s
     7: real 0m3.601s user 0m0.174s sys 0m3.446s
     8: real 0m3.798s user 0m0.187s sys 0m3.625s
     9: real 0m8.452s user 0m0.194s sys 0m8.252s
    10: real 0m2.755s user 0m0.178s sys 0m2.593s
    11: real 0m0.621s user 0m0.185s sys 0m0.464s
    12: real 0m8.888s user 0m0.183s sys 0m8.710s
    13: real 0m0.532s user 0m0.170s sys 0m0.388s
    14: real 0m4.354s user 0m0.204s sys 0m4.174s
    15: real 0m1.951s user 0m0.180s sys 0m1.797s
    16: real 0m0.561s user 0m0.170s sys 0m0.415s
    17: real 0m7.002s user 0m0.166s sys 0m6.844s
    18: real 0m4.587s user 0m0.196s sys 0m4.390s
    19: real 0m3.106s user 0m0.178s sys 0m2.947s
    20: real 0m0.955s user 0m0.185s sys 0m0.779s

With this change:

openjdk version "10.0.1-internal" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1-internal+0-adhoc.keithc.jdk10)
Eclipse OpenJ9 VM (build ddr-06b6050, JRE 10 Linux s390x-64-Bit Compressed References 20180711_000000 (JIT enabled, AOT enabled)
OpenJ9   - 06b6050
OMR      - 7519383
JCL      - e180ae0 based on jdk-10.0.1+10)

     1: real 0m0.082s user 0m0.098s sys 0m0.012s
     2: real 0m0.074s user 0m0.091s sys 0m0.010s
     3: real 0m0.073s user 0m0.088s sys 0m0.010s
     4: real 0m0.076s user 0m0.090s sys 0m0.009s
     5: real 0m0.075s user 0m0.090s sys 0m0.008s
     6: real 0m0.073s user 0m0.090s sys 0m0.008s
     7: real 0m0.071s user 0m0.090s sys 0m0.007s
     8: real 0m0.076s user 0m0.089s sys 0m0.011s
     9: real 0m0.074s user 0m0.094s sys 0m0.007s
    10: real 0m0.077s user 0m0.093s sys 0m0.010s
    11: real 0m0.076s user 0m0.093s sys 0m0.009s
    12: real 0m0.078s user 0m0.090s sys 0m0.008s
    13: real 0m0.071s user 0m0.088s sys 0m0.008s
    14: real 0m0.073s user 0m0.086s sys 0m0.008s
    15: real 0m0.072s user 0m0.087s sys 0m0.007s
    16: real 0m0.076s user 0m0.093s sys 0m0.008s
    17: real 0m0.076s user 0m0.089s sys 0m0.009s
    18: real 0m0.075s user 0m0.089s sys 0m0.010s
    19: real 0m0.071s user 0m0.086s sys 0m0.007s
    20: real 0m0.076s user 0m0.089s sys 0m0.011s

@charliegracie
Copy link
Contributor

@genie-omr build zlinux plinux zlinux

@charliegracie
Copy link
Contributor

@genie-omr build xlinux

Add more debugging details in findAvailableMemoryBlockNoMalloc

Signed-off-by: Keith W. Campbell <[email protected]>
Just use 'flag' instead of 'TRUE == flag'.

Signed-off-by: Keith W. Campbell <[email protected]>
* use OMR_ARE_ANY_BITS_SET & OMR_ARE_NO_BITS_SET

Signed-off-by: Keith W. Campbell <[email protected]>
The caller provides start and end addresses that constrain a non-null
address that can be returned by the function. Internally, however,
the function operates on ranges which are inclusive of the space
requested by the caller: the allowed range must be initialized taking
this difference into account by adding the requested block size to the
end address.

Signed-off-by: Keith W. Campbell <[email protected]>
@keithc-ca
Copy link
Contributor Author

It turns out the code isn't normally expected to take a path that leads to a (long) linear search for an acceptable allocation address: the problem was in findAvailableMemoryBlockNoMalloc() which should not have failed to satisfy requests with the OMRPORT_VMEM_ALLOC_QUICK option. Callers to that function specify the range of start addresses for the requested, while internally it deals with the extents of candidate blocks. This mismatch meant blocks that would satisfy the caller were being ignored.

We may someday want to introduce new behaviors for that backup search which is now encapsulated in some helper functions.

BTW, the same problem was present in the ZTPF copy of omrvmem.c: it is now fixed too.

@keithc-ca keithc-ca changed the title WIP: Fix slow allocation of memory Fix slow allocation of memory Jul 18, 2018
@irinarada
Copy link

@charliegracie - do we have the review?

@charliegracie
Copy link
Contributor

@genie-omr build xlinux

@mstoodle
Copy link
Contributor

@genie-omr build all

@charliegracie
Copy link
Contributor

@genie-omr build aix,zos

Copy link
Contributor

@charliegracie charliegracie left a comment

Choose a reason for hiding this comment

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

Approved. Just waiting for the CI to finish.

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.

4 participants