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

8312191: ColorConvertOp.filter for the default destination is too slow #14910

Closed
wants to merge 3 commits into from

Conversation

mrserb
Copy link
Member

@mrserb mrserb commented Jul 17, 2023

I have found that MTPerLineTransformValidation - one of our slowest stress test spends most of the time not in the code related to the colors conversion(as it was intended) but in the initialization of the native cmm-transforms.

ColorConvertOp sharedOp = new ColorConvertOp(srcCS, dstCS, null); <-- slow
BufferedImage dst = sharedOp.filter(src, null); 

The code above triggers the next sequence:

  1. The destination buffered image is not set so it should be created automatically ->>
  2. The buffered image requires the new color model ->>
  3. The color model requires new color space ->>
  4. The color model initialize some LUTs, and cache it per color space ->>
  5. When the ColorConvertOp is used for the first time the color space caches some state internally if the format of the src/dst image is not changed

So the critical thing above is to minimize the creation of the new color spaces, since for each new space all optimizations above should be repeated. Unfortunately, when we create the ColorConvertOp using standard icc_profile/icc_colorspace we store the profile only and lost the reference to the initial color space. And when later we decide to create a color model we create the new icc_color space->all optimizations resets.

We do not save the reference to the color space because that way we distinguish the icc_colorspace saved using profiles, and non-icc_color spaces used as is. I think all that code should be reworked to take into account the current issue. But for now, we can fix it at least for standard types.

Important notes:

  • Performance of MTPerLineTransformValidation test is increased(on my system from 3m30s to the 14s) - the number of used native transforms changed from 80000 to ~500. It can have a side effect since a few crashes(exit code 134) were reported for this test. The crashes of this test and others may disappear since the memory pressure is decreased, or the number of crashes can increase because the code for transforming will be executed in parallel more often.
  • The patch also affects the noop color conversion when the color space of the src and dst are the same, for example, if both are SRGB then:
cmm

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8312191: ColorConvertOp.filter for the default destination is too slow (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14910/head:pull/14910
$ git checkout pull/14910

Update a local copy of the PR:
$ git checkout pull/14910
$ git pull https://git.openjdk.org/jdk.git pull/14910/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14910

View PR using the GUI difftool:
$ git pr show -t 14910

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14910.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 17, 2023

👋 Welcome back serb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 17, 2023

@mrserb The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Jul 17, 2023
@mrserb mrserb marked this pull request as ready for review July 18, 2023 23:11
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 18, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 18, 2023

Webrevs

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 16, 2023

@mrserb This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@mrserb
Copy link
Member Author

mrserb commented Aug 16, 2023

keep open

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 14, 2023

@mrserb This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@mrserb
Copy link
Member Author

mrserb commented Sep 14, 2023

keep open

@openjdk
Copy link

openjdk bot commented Sep 20, 2023

@mrserb This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8312191: ColorConvertOp.filter for the default destination is too slow

Reviewed-by: prr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 20, 2023
@mrserb
Copy link
Member Author

mrserb commented Sep 25, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Sep 25, 2023

Going to push as commit e5f05b5.
Since your change was applied there have been 3 commits pushed to the master branch:

  • be9cc73: 8315871: Opensource five more Swing regression tests
  • b65f4f7: 8313403: Remove unused 'mask' field from JFormattedTextField
  • e3201d1: 8310631: test/jdk/sun/nio/cs/TestCharsetMapping.java is spuriously passing

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 25, 2023
@openjdk openjdk bot closed this Sep 25, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 25, 2023
@openjdk
Copy link

openjdk bot commented Sep 25, 2023

@mrserb Pushed as commit e5f05b5.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@mrserb mrserb deleted the JDK-8312191 branch November 2, 2023 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

2 participants