Skip to content

get the curation statuses faster: no expensive get calls#12552

Open
ffritze wants to merge 1 commit into
IQSS:developfrom
TIK-NFL:curationStatus_fix
Open

get the curation statuses faster: no expensive get calls#12552
ffritze wants to merge 1 commit into
IQSS:developfrom
TIK-NFL:curationStatus_fix

Conversation

@ffritze

@ffritze ffritze commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Setting a new curation label can take very long and could lead to an internal server error.

Which issue(s) this PR closes:
This pull request addresses the following issue: #12399

  • Closes #

Special notes for your reviewer:
It is tested on my dev machine. This machine does not have to handle very high load. It was not possible to test in a real scenario with heavy load on the Payara server.

Suggestions on how to test this:

Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No

Is there a release notes update needed for this change?:

Additional documentation:
This fix has been developed with the help of Claude code. It says: The original approach sorted the list by calling getCreateTime() directly inside the comparator. The drawback is that a comparison-based sort calls the comparator roughly n·log(n) times for n elements, so the getter ends up being invoked far more often than there are actual objects.

The optimization introduces a key cache: before sorting, the code walks the list once and builds a lookup structure that maps each object to its createTime value, calling the getter exactly once per element. The sort then reads from this cache instead of calling the getter again, turning each comparison into a cheap lookup rather than a repeated method call.

I assume that the original sorting logic was to expensive and so I co-developed with Claude this fix.

@pdurbin pdurbin moved this to Ready for Triage in IQSS Dataverse Project Jul 22, 2026

@qqmyers qqmyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks correct (it should work), but I'm a bit surprised that it would do anything. CurationStatus.getCreateTime simply returns an existing value -

public Date getCreateTime() {
return createTime;
}
which shouldn't be slow, and may be faster than a map lookup. I'd suggest we really get proof this helps before merging it.
If we do merge, I suggest a little cleanup to avoid repeating the multiline update cache statement several times.

CurationStatus::getCreateTime,
(a, b) -> a,
IdentityHashMap::new
));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you make this a method to avoid repeating the code several times? (I see it's one line, but it would be nice to not have to check that the multiple uses are all the same.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for Triage

Development

Successfully merging this pull request may close these issues.

3 participants