[
https://issues.apache.org/jira/browse/IGNITE-21225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Aleksey Plekhanov resolved IGNITE-21225.
----------------------------------------
Fix Version/s: 2.17
Release Note: Fixed redundant lambda object allocation in
ClockPageReplacementFlags#
Resolution: Fixed
[~timonin.maksim], thanks for the review! Merged to master.
> Redundant lambda object allocation in ClockPageReplacementFlags#setFlag
> -----------------------------------------------------------------------
>
> Key: IGNITE-21225
> URL: https://issues.apache.org/jira/browse/IGNITE-21225
> Project: Ignite
> Issue Type: Improvement
> Reporter: Aleksey Plekhanov
> Assignee: Aleksey Plekhanov
> Priority: Major
> Labels: ise
> Fix For: 2.17
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Every time we call {{ClockPageReplacementFlags#setFlag/clearFlag}} methods
> the new lambda object is created, since lambda is accessing the variable in
> enclosing scope. \{{ClockPageReplacementFlags#setFlag}} method called every
> time when page is modified, so, it's a relatevily hot method and we should
> avoid new object allocation here.
> Here is the test to show redundant allocations:
>
> {code:java}
> /** */
> @Test
> public void testAllocation() {
> clockFlags = new ClockPageReplacementFlags(MAX_PAGES_CNT,
> region.address());
> int cnt = 1_000_000;
> ThreadMXBean bean = (ThreadMXBean)ManagementFactory.getThreadMXBean();
> // Warmup.
> clockFlags.setFlag(0);
> long allocated0 =
> bean.getThreadAllocatedBytes(Thread.currentThread().getId());
> for (int i = 0; i < cnt; i++)
> clockFlags.setFlag(i % MAX_PAGES_CNT);
> long allocated1 =
> bean.getThreadAllocatedBytes(Thread.currentThread().getId());
> assertTrue("Too many bytes allocated: " + (allocated1 - allocated0),
> allocated1 - allocated0 < cnt);
> } {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)