You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "skorotkov (via GitHub)" <gi...@apache.org> on 2025/05/18 06:36:28 UTC
[PR] IGNITE-17734 Try to find test which would cover CutTail [ignite]
skorotkov opened a new pull request, #12074:
URL: https://github.com/apache/ignite/pull/12074
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
### The Contribution Checklist
- [ ] There is a single JIRA ticket related to the pull request.
- [ ] The web-link to the pull request is attached to the JIRA ticket.
- [ ] The JIRA ticket has the _Patch Available_ state.
- [ ] The pull request body describes changes that have been made.
The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
- [ ] The pull request title is treated as the final commit message.
The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
- [ ] A reviewer has been mentioned through the JIRA comments
(see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers))
- [ ] The pull request has been checked by the Teamcity Bot and
the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
### Notes
- [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
- [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
- [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
- [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off [ignite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #12074:
URL: https://github.com/apache/ignite/pull/12074#issuecomment-2919134974
## [](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12074) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=12074&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=12074&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=12074&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=12074&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=12074&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12074)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off [ignite]
Posted by "skorotkov (via GitHub)" <gi...@apache.org>.
skorotkov commented on code in PR #12074:
URL: https://github.com/apache/ignite/pull/12074#discussion_r2113454596
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS_COUNT = 5_000;
+
+ /** Signals once method under test is C2 Jit compiled in server node. */
+ CountDownLatch c2JitCompiled = new CountDownLatch(1);
+
+ /** JVM options to start the server node in remote JVM. */
+ @Parameterized.Parameter
+ public List<String> jvmOpts;
+
+ /** */
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<List<String>> params() {
+ ArrayList<List<String>> params = new ArrayList<>(List.of(
+ List.of("-XX:+UseShenandoahGC"),
+ List.of("-XX:+UseShenandoahGC", "-ea"),
+
+ List.of("-XX:+UseG1GC"),
+ List.of("-XX:+UseG1GC", "-ea")
+ ));
+
+ if (Runtime.version().feature() >= 17 || U.isLinux())
+ addZgc(params);
+
+ return params;
+ }
+
+ /**
+ * Ensure that the PagesList$CutTail::run handler is not broken if C2 Jit-compiled.
+ * With various garbage collectors and with assertions both turned on and off.
+ */
+ @Test
+ public void testCutTail() throws Exception {
+ try (Ignite ignite = prepareCluster(jvmOpts,
+ "org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList$CutTail::run")) {
+ IgniteFuture<Void> jobFut = ignite.compute().runAsync(new TestCutTailJob());
+
+ assertTrue(c2JitCompiled.await(getTestTimeout() / 2, TimeUnit.MILLISECONDS));
+
+ try {
+ // Let it work for 2 seconds with the optimized C2 Jit-compiled variant of the
+ // PagesList$CutTail::run method. It's enough to reproduce problem if it is broken.
+ jobFut.get(2000, TimeUnit.MILLISECONDS);
+ }
+ catch (IgniteFutureTimeoutException e) {
+ jobFut.cancel();
+ }
+ }
+ }
+
+ /**
+ * Starts server node in remote JVM with the JVM options passed.
+ * Registers listener to signal once the method passed is C2 Jit-compiled in server node.
+ * Starts client node in local JVM.
+ *
+ * @param jvmOpts JVM options for the server node.
+ * @param method Fully qualified name of method.
+ * @return Client node.
+ */
+ private Ignite prepareCluster(List<String> jvmOpts, String method) throws Exception {
+ CountDownLatch remoteJvmServerStarted = new CountDownLatch(1);
+
+ ListeningTestLogger lsnrLog = new ListeningTestLogger(log);
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(".*Topology snapshot \\[ver=1,.*",
+ remoteJvmServerStarted::countDown));
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(
+ ".*Compiled method \\(c2\\).*" + method.replace("$", "\\$") + ".*",
+ c2JitCompiled::countDown));
+
+ IgniteConfiguration cfg = optimize(getConfiguration("remote-jvm-server"));
+
+ new IgniteProcessProxy(cfg, lsnrLog, null, false) {
+ @Override protected Collection<String> filteredJvmArgs() throws Exception {
+ Collection<String> args = super.filteredJvmArgs();
+
+ args.remove("-ea");
+
+ args.add("-XX:+UnlockDiagnosticVMOptions");
+ args.add("-XX:PrintAssemblyOptions=intel");
+ args.add("-XX:CompileCommand=print," + method);
+
+ args.addAll(jvmOpts);
+
+ return args;
+ }
+ };
+
+ remoteJvmServerStarted.await(getTestTimeout(), TimeUnit.MILLISECONDS);
+
+ return startClientGrid("local-jvm-client");
+ }
+
+ /**
+ * Perfrom concurrent updates and deletes ensuring the CutTail called enough
+ * times to invoke the C2 optimizing Jit compiler.
+ */
+ private static class TestCutTailJob implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ Ignite ignite;
+
+ /** */
+ Random random = new Random(3793);
Review Comment:
Just to reduce randomness. Besides looks like contention on global Random increased chances to reproduce the problem.
Now with the introduction of explicit barrier it's not needed any more.
Will replace with ThreadLocalRandom.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off [ignite]
Posted by "skorotkov (via GitHub)" <gi...@apache.org>.
skorotkov commented on code in PR #12074:
URL: https://github.com/apache/ignite/pull/12074#discussion_r2113498980
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
Review Comment:
moved
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
Review Comment:
renamed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off [ignite]
Posted by "alex-plekhanov (via GitHub)" <gi...@apache.org>.
alex-plekhanov commented on code in PR #12074:
URL: https://github.com/apache/ignite/pull/12074#discussion_r2113402768
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
Review Comment:
Test don't use persistence, I think it can be moved to org/apache/ignite/internal/processors/database
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS_COUNT = 5_000;
+
+ /** Signals once method under test is C2 Jit compiled in server node. */
+ CountDownLatch c2JitCompiled = new CountDownLatch(1);
+
+ /** JVM options to start the server node in remote JVM. */
+ @Parameterized.Parameter
+ public List<String> jvmOpts;
+
+ /** */
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<List<String>> params() {
+ ArrayList<List<String>> params = new ArrayList<>(List.of(
+ List.of("-XX:+UseShenandoahGC"),
+ List.of("-XX:+UseShenandoahGC", "-ea"),
+
+ List.of("-XX:+UseG1GC"),
+ List.of("-XX:+UseG1GC", "-ea")
+ ));
+
+ if (Runtime.version().feature() >= 17 || U.isLinux())
+ addZgc(params);
+
+ return params;
+ }
+
+ /**
+ * Ensure that the PagesList$CutTail::run handler is not broken if C2 Jit-compiled.
+ * With various garbage collectors and with assertions both turned on and off.
+ */
+ @Test
+ public void testCutTail() throws Exception {
+ try (Ignite ignite = prepareCluster(jvmOpts,
+ "org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList$CutTail::run")) {
+ IgniteFuture<Void> jobFut = ignite.compute().runAsync(new TestCutTailJob());
+
+ assertTrue(c2JitCompiled.await(getTestTimeout() / 2, TimeUnit.MILLISECONDS));
+
+ try {
+ // Let it work for 2 seconds with the optimized C2 Jit-compiled variant of the
+ // PagesList$CutTail::run method. It's enough to reproduce problem if it is broken.
+ jobFut.get(2000, TimeUnit.MILLISECONDS);
+ }
+ catch (IgniteFutureTimeoutException e) {
+ jobFut.cancel();
+ }
+ }
+ }
+
+ /**
+ * Starts server node in remote JVM with the JVM options passed.
+ * Registers listener to signal once the method passed is C2 Jit-compiled in server node.
+ * Starts client node in local JVM.
+ *
+ * @param jvmOpts JVM options for the server node.
+ * @param method Fully qualified name of method.
+ * @return Client node.
+ */
+ private Ignite prepareCluster(List<String> jvmOpts, String method) throws Exception {
+ CountDownLatch remoteJvmServerStarted = new CountDownLatch(1);
+
+ ListeningTestLogger lsnrLog = new ListeningTestLogger(log);
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(".*Topology snapshot \\[ver=1,.*",
+ remoteJvmServerStarted::countDown));
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(
+ ".*Compiled method \\(c2\\).*" + method.replace("$", "\\$") + ".*",
+ c2JitCompiled::countDown));
+
+ IgniteConfiguration cfg = optimize(getConfiguration("remote-jvm-server"));
+
+ new IgniteProcessProxy(cfg, lsnrLog, null, false) {
+ @Override protected Collection<String> filteredJvmArgs() throws Exception {
+ Collection<String> args = super.filteredJvmArgs();
+
+ args.remove("-ea");
+
+ args.add("-XX:+UnlockDiagnosticVMOptions");
+ args.add("-XX:PrintAssemblyOptions=intel");
+ args.add("-XX:CompileCommand=print," + method);
+
+ args.addAll(jvmOpts);
+
+ return args;
+ }
+ };
+
+ remoteJvmServerStarted.await(getTestTimeout(), TimeUnit.MILLISECONDS);
+
+ return startClientGrid("local-jvm-client");
+ }
+
+ /**
+ * Perfrom concurrent updates and deletes ensuring the CutTail called enough
+ * times to invoke the C2 optimizing Jit compiler.
+ */
+ private static class TestCutTailJob implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ Ignite ignite;
+
+ /** */
+ Random random = new Random(3793);
Review Comment:
Magic number.
Why not use Random() without seed?
Perhaps ThreadLocalRandom?
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS_COUNT = 5_000;
+
+ /** Signals once method under test is C2 Jit compiled in server node. */
+ CountDownLatch c2JitCompiled = new CountDownLatch(1);
+
+ /** JVM options to start the server node in remote JVM. */
+ @Parameterized.Parameter
+ public List<String> jvmOpts;
+
+ /** */
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<List<String>> params() {
+ ArrayList<List<String>> params = new ArrayList<>(List.of(
+ List.of("-XX:+UseShenandoahGC"),
+ List.of("-XX:+UseShenandoahGC", "-ea"),
+
+ List.of("-XX:+UseG1GC"),
+ List.of("-XX:+UseG1GC", "-ea")
+ ));
+
+ if (Runtime.version().feature() >= 17 || U.isLinux())
+ addZgc(params);
+
+ return params;
+ }
+
+ /**
+ * Ensure that the PagesList$CutTail::run handler is not broken if C2 Jit-compiled.
+ * With various garbage collectors and with assertions both turned on and off.
+ */
+ @Test
+ public void testCutTail() throws Exception {
+ try (Ignite ignite = prepareCluster(jvmOpts,
+ "org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList$CutTail::run")) {
+ IgniteFuture<Void> jobFut = ignite.compute().runAsync(new TestCutTailJob());
+
+ assertTrue(c2JitCompiled.await(getTestTimeout() / 2, TimeUnit.MILLISECONDS));
+
+ try {
+ // Let it work for 2 seconds with the optimized C2 Jit-compiled variant of the
+ // PagesList$CutTail::run method. It's enough to reproduce problem if it is broken.
+ jobFut.get(2000, TimeUnit.MILLISECONDS);
+ }
+ catch (IgniteFutureTimeoutException e) {
+ jobFut.cancel();
+ }
+ }
+ }
+
+ /**
+ * Starts server node in remote JVM with the JVM options passed.
+ * Registers listener to signal once the method passed is C2 Jit-compiled in server node.
+ * Starts client node in local JVM.
+ *
+ * @param jvmOpts JVM options for the server node.
+ * @param method Fully qualified name of method.
+ * @return Client node.
+ */
+ private Ignite prepareCluster(List<String> jvmOpts, String method) throws Exception {
+ CountDownLatch remoteJvmServerStarted = new CountDownLatch(1);
+
+ ListeningTestLogger lsnrLog = new ListeningTestLogger(log);
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(".*Topology snapshot \\[ver=1,.*",
+ remoteJvmServerStarted::countDown));
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(
+ ".*Compiled method \\(c2\\).*" + method.replace("$", "\\$") + ".*",
+ c2JitCompiled::countDown));
+
+ IgniteConfiguration cfg = optimize(getConfiguration("remote-jvm-server"));
+
+ new IgniteProcessProxy(cfg, lsnrLog, null, false) {
+ @Override protected Collection<String> filteredJvmArgs() throws Exception {
+ Collection<String> args = super.filteredJvmArgs();
+
+ args.remove("-ea");
+
+ args.add("-XX:+UnlockDiagnosticVMOptions");
+ args.add("-XX:PrintAssemblyOptions=intel");
+ args.add("-XX:CompileCommand=print," + method);
+
+ args.addAll(jvmOpts);
+
+ return args;
+ }
+ };
+
+ remoteJvmServerStarted.await(getTestTimeout(), TimeUnit.MILLISECONDS);
+
+ return startClientGrid("local-jvm-client");
+ }
+
+ /**
+ * Perfrom concurrent updates and deletes ensuring the CutTail called enough
+ * times to invoke the C2 optimizing Jit compiler.
+ */
+ private static class TestCutTailJob implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ Ignite ignite;
+
+ /** */
+ Random random = new Random(3793);
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ IgniteCache<Object, Object> cache = ignite.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
+
+ for (int i = 0; i < KEYS_COUNT; i++)
+ cache.put(i, value());
+
+ AtomicBoolean stop = new AtomicBoolean(false);
+
+ CyclicBarrier barrier = new CyclicBarrier(6);
+
+ IgniteInternalFuture<Long> updateFut = runMultiThreadedAsync(() -> {
+ while (!stop.get()) {
+ try {
+ barrier.await(100, TimeUnit.MILLISECONDS);
+
+ cache.put(key(), value());
+ }
+ catch (InterruptedException | BrokenBarrierException ignored) {
+ stop.set(true);
+ }
+ catch (TimeoutException ignored) {
+ // No-op.
+ }
+ catch (Exception ex) {
+ stop.set(true);
+
+ throw ex;
+ }
+ }
+ }, 24, "update");
+
+ while (!stop.get())
+ cache.remove(key());
+
+ barrier.reset();
+
+ try {
+ updateFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** */
+ private int key() {
+ return random.nextInt(KEYS_COUNT);
+ }
+
+ /** */
+ private byte[] value() {
+ return new byte[random.nextInt(12000) + 3000];
+ }
+ }
+
+ /**
+ * Add test parameters for the ZGC garbage collector.
+ */
+ private static void addZgc(ArrayList<List<String>> params) {
+ ArrayList<String> opts = new ArrayList<>();
+
+ if (Runtime.version().feature() < 12)
+ opts.add("-XX:+UnlockExperimentalVMOptions");
+
+ opts.add("-XX:+UseZGC");
+ params.add(new ArrayList<>(opts));
+
+ opts.add("-ea");
+ params.add(new ArrayList<>(opts));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName)
+ .setDiscoverySpi(new TcpDiscoverySpi()
+ .setLocalAddress("127.0.0.1")
+ .setIpFinder(new TcpDiscoveryVmIpFinder()
+ .setAddresses(Collections.singleton("127.0.0.1:" +
+ TcpDiscoverySpi.DFLT_PORT + ".." + (TcpDiscoverySpi.DFLT_PORT + 1)))
+ ));;
+
+ DataStorageConfiguration dsCfg = new DataStorageConfiguration();
+
+ int pageSize = dsCfg.getPageSize() == 0 ? DataStorageConfiguration.DFLT_PAGE_SIZE : dsCfg.getPageSize();
+
+ dsCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+ .setPersistenceEnabled(false)
Review Comment:
Default value, can be removed
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS_COUNT = 5_000;
+
+ /** Signals once method under test is C2 Jit compiled in server node. */
+ CountDownLatch c2JitCompiled = new CountDownLatch(1);
+
+ /** JVM options to start the server node in remote JVM. */
+ @Parameterized.Parameter
+ public List<String> jvmOpts;
+
+ /** */
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<List<String>> params() {
+ ArrayList<List<String>> params = new ArrayList<>(List.of(
+ List.of("-XX:+UseShenandoahGC"),
+ List.of("-XX:+UseShenandoahGC", "-ea"),
+
+ List.of("-XX:+UseG1GC"),
+ List.of("-XX:+UseG1GC", "-ea")
+ ));
+
+ if (Runtime.version().feature() >= 17 || U.isLinux())
+ addZgc(params);
+
+ return params;
+ }
+
+ /**
+ * Ensure that the PagesList$CutTail::run handler is not broken if C2 Jit-compiled.
+ * With various garbage collectors and with assertions both turned on and off.
+ */
+ @Test
+ public void testCutTail() throws Exception {
+ try (Ignite ignite = prepareCluster(jvmOpts,
+ "org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList$CutTail::run")) {
+ IgniteFuture<Void> jobFut = ignite.compute().runAsync(new TestCutTailJob());
+
+ assertTrue(c2JitCompiled.await(getTestTimeout() / 2, TimeUnit.MILLISECONDS));
+
+ try {
+ // Let it work for 2 seconds with the optimized C2 Jit-compiled variant of the
+ // PagesList$CutTail::run method. It's enough to reproduce problem if it is broken.
+ jobFut.get(2000, TimeUnit.MILLISECONDS);
+ }
+ catch (IgniteFutureTimeoutException e) {
+ jobFut.cancel();
+ }
+ }
+ }
+
+ /**
+ * Starts server node in remote JVM with the JVM options passed.
+ * Registers listener to signal once the method passed is C2 Jit-compiled in server node.
+ * Starts client node in local JVM.
+ *
+ * @param jvmOpts JVM options for the server node.
+ * @param method Fully qualified name of method.
+ * @return Client node.
+ */
+ private Ignite prepareCluster(List<String> jvmOpts, String method) throws Exception {
+ CountDownLatch remoteJvmServerStarted = new CountDownLatch(1);
+
+ ListeningTestLogger lsnrLog = new ListeningTestLogger(log);
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(".*Topology snapshot \\[ver=1,.*",
+ remoteJvmServerStarted::countDown));
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(
+ ".*Compiled method \\(c2\\).*" + method.replace("$", "\\$") + ".*",
+ c2JitCompiled::countDown));
+
+ IgniteConfiguration cfg = optimize(getConfiguration("remote-jvm-server"));
+
+ new IgniteProcessProxy(cfg, lsnrLog, null, false) {
+ @Override protected Collection<String> filteredJvmArgs() throws Exception {
+ Collection<String> args = super.filteredJvmArgs();
+
+ args.remove("-ea");
+
+ args.add("-XX:+UnlockDiagnosticVMOptions");
+ args.add("-XX:PrintAssemblyOptions=intel");
+ args.add("-XX:CompileCommand=print," + method);
+
+ args.addAll(jvmOpts);
+
+ return args;
+ }
+ };
+
+ remoteJvmServerStarted.await(getTestTimeout(), TimeUnit.MILLISECONDS);
+
+ return startClientGrid("local-jvm-client");
+ }
+
+ /**
+ * Perfrom concurrent updates and deletes ensuring the CutTail called enough
+ * times to invoke the C2 optimizing Jit compiler.
+ */
+ private static class TestCutTailJob implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ Ignite ignite;
+
+ /** */
+ Random random = new Random(3793);
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ IgniteCache<Object, Object> cache = ignite.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
+
+ for (int i = 0; i < KEYS_COUNT; i++)
+ cache.put(i, value());
+
+ AtomicBoolean stop = new AtomicBoolean(false);
+
+ CyclicBarrier barrier = new CyclicBarrier(6);
+
+ IgniteInternalFuture<Long> updateFut = runMultiThreadedAsync(() -> {
+ while (!stop.get()) {
+ try {
+ barrier.await(100, TimeUnit.MILLISECONDS);
+
+ cache.put(key(), value());
+ }
+ catch (InterruptedException | BrokenBarrierException ignored) {
+ stop.set(true);
+ }
+ catch (TimeoutException ignored) {
+ // No-op.
+ }
+ catch (Exception ex) {
+ stop.set(true);
+
+ throw ex;
+ }
+ }
+ }, 24, "update");
+
+ while (!stop.get())
+ cache.remove(key());
+
+ barrier.reset();
+
+ try {
+ updateFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** */
+ private int key() {
+ return random.nextInt(KEYS_COUNT);
+ }
+
+ /** */
+ private byte[] value() {
+ return new byte[random.nextInt(12000) + 3000];
+ }
+ }
+
+ /**
+ * Add test parameters for the ZGC garbage collector.
+ */
+ private static void addZgc(ArrayList<List<String>> params) {
+ ArrayList<String> opts = new ArrayList<>();
+
+ if (Runtime.version().feature() < 12)
+ opts.add("-XX:+UnlockExperimentalVMOptions");
+
+ opts.add("-XX:+UseZGC");
+ params.add(new ArrayList<>(opts));
+
+ opts.add("-ea");
+ params.add(new ArrayList<>(opts));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName)
+ .setDiscoverySpi(new TcpDiscoverySpi()
+ .setLocalAddress("127.0.0.1")
+ .setIpFinder(new TcpDiscoveryVmIpFinder()
+ .setAddresses(Collections.singleton("127.0.0.1:" +
+ TcpDiscoverySpi.DFLT_PORT + ".." + (TcpDiscoverySpi.DFLT_PORT + 1)))
+ ));;
Review Comment:
```
.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(LOCAL_IP_FINDER));
```
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
Review Comment:
Let's use more descriptive class name (somethink like FreeListCutTailDifferentGcTest)
##########
modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite5.java:
##########
@@ -84,6 +85,7 @@ public static List<Class<?>> suite(Collection<Class> ignoredTests) {
GridTestUtils.addTestIfNeeded(suite, PageIdDistributionTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, TrackingPageIOTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, PageIOFreeSizeTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, FreeListTest.class, ignoredTests);
Review Comment:
Test do not use pds, can be moved to another suite
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off [ignite]
Posted by "skorotkov (via GitHub)" <gi...@apache.org>.
skorotkov commented on code in PR #12074:
URL: https://github.com/apache/ignite/pull/12074#discussion_r2113501402
##########
modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite5.java:
##########
@@ -84,6 +85,7 @@ public static List<Class<?>> suite(Collection<Class> ignoredTests) {
GridTestUtils.addTestIfNeeded(suite, PageIdDistributionTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, TrackingPageIOTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, PageIOFreeSizeTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, FreeListTest.class, ignoredTests);
Review Comment:
moved to IgniteBasicTestSuite2 (which is Basic4 in team city)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off [ignite]
Posted by "skorotkov (via GitHub)" <gi...@apache.org>.
skorotkov commented on code in PR #12074:
URL: https://github.com/apache/ignite/pull/12074#discussion_r2113499543
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS_COUNT = 5_000;
+
+ /** Signals once method under test is C2 Jit compiled in server node. */
+ CountDownLatch c2JitCompiled = new CountDownLatch(1);
+
+ /** JVM options to start the server node in remote JVM. */
+ @Parameterized.Parameter
+ public List<String> jvmOpts;
+
+ /** */
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<List<String>> params() {
+ ArrayList<List<String>> params = new ArrayList<>(List.of(
+ List.of("-XX:+UseShenandoahGC"),
+ List.of("-XX:+UseShenandoahGC", "-ea"),
+
+ List.of("-XX:+UseG1GC"),
+ List.of("-XX:+UseG1GC", "-ea")
+ ));
+
+ if (Runtime.version().feature() >= 17 || U.isLinux())
+ addZgc(params);
+
+ return params;
+ }
+
+ /**
+ * Ensure that the PagesList$CutTail::run handler is not broken if C2 Jit-compiled.
+ * With various garbage collectors and with assertions both turned on and off.
+ */
+ @Test
+ public void testCutTail() throws Exception {
+ try (Ignite ignite = prepareCluster(jvmOpts,
+ "org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList$CutTail::run")) {
+ IgniteFuture<Void> jobFut = ignite.compute().runAsync(new TestCutTailJob());
+
+ assertTrue(c2JitCompiled.await(getTestTimeout() / 2, TimeUnit.MILLISECONDS));
+
+ try {
+ // Let it work for 2 seconds with the optimized C2 Jit-compiled variant of the
+ // PagesList$CutTail::run method. It's enough to reproduce problem if it is broken.
+ jobFut.get(2000, TimeUnit.MILLISECONDS);
+ }
+ catch (IgniteFutureTimeoutException e) {
+ jobFut.cancel();
+ }
+ }
+ }
+
+ /**
+ * Starts server node in remote JVM with the JVM options passed.
+ * Registers listener to signal once the method passed is C2 Jit-compiled in server node.
+ * Starts client node in local JVM.
+ *
+ * @param jvmOpts JVM options for the server node.
+ * @param method Fully qualified name of method.
+ * @return Client node.
+ */
+ private Ignite prepareCluster(List<String> jvmOpts, String method) throws Exception {
+ CountDownLatch remoteJvmServerStarted = new CountDownLatch(1);
+
+ ListeningTestLogger lsnrLog = new ListeningTestLogger(log);
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(".*Topology snapshot \\[ver=1,.*",
+ remoteJvmServerStarted::countDown));
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(
+ ".*Compiled method \\(c2\\).*" + method.replace("$", "\\$") + ".*",
+ c2JitCompiled::countDown));
+
+ IgniteConfiguration cfg = optimize(getConfiguration("remote-jvm-server"));
+
+ new IgniteProcessProxy(cfg, lsnrLog, null, false) {
+ @Override protected Collection<String> filteredJvmArgs() throws Exception {
+ Collection<String> args = super.filteredJvmArgs();
+
+ args.remove("-ea");
+
+ args.add("-XX:+UnlockDiagnosticVMOptions");
+ args.add("-XX:PrintAssemblyOptions=intel");
+ args.add("-XX:CompileCommand=print," + method);
+
+ args.addAll(jvmOpts);
+
+ return args;
+ }
+ };
+
+ remoteJvmServerStarted.await(getTestTimeout(), TimeUnit.MILLISECONDS);
+
+ return startClientGrid("local-jvm-client");
+ }
+
+ /**
+ * Perfrom concurrent updates and deletes ensuring the CutTail called enough
+ * times to invoke the C2 optimizing Jit compiler.
+ */
+ private static class TestCutTailJob implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ Ignite ignite;
+
+ /** */
+ Random random = new Random(3793);
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ IgniteCache<Object, Object> cache = ignite.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
+
+ for (int i = 0; i < KEYS_COUNT; i++)
+ cache.put(i, value());
+
+ AtomicBoolean stop = new AtomicBoolean(false);
+
+ CyclicBarrier barrier = new CyclicBarrier(6);
+
+ IgniteInternalFuture<Long> updateFut = runMultiThreadedAsync(() -> {
+ while (!stop.get()) {
+ try {
+ barrier.await(100, TimeUnit.MILLISECONDS);
+
+ cache.put(key(), value());
+ }
+ catch (InterruptedException | BrokenBarrierException ignored) {
+ stop.set(true);
+ }
+ catch (TimeoutException ignored) {
+ // No-op.
+ }
+ catch (Exception ex) {
+ stop.set(true);
+
+ throw ex;
+ }
+ }
+ }, 24, "update");
+
+ while (!stop.get())
+ cache.remove(key());
+
+ barrier.reset();
+
+ try {
+ updateFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** */
+ private int key() {
+ return random.nextInt(KEYS_COUNT);
+ }
+
+ /** */
+ private byte[] value() {
+ return new byte[random.nextInt(12000) + 3000];
+ }
+ }
+
+ /**
+ * Add test parameters for the ZGC garbage collector.
+ */
+ private static void addZgc(ArrayList<List<String>> params) {
+ ArrayList<String> opts = new ArrayList<>();
+
+ if (Runtime.version().feature() < 12)
+ opts.add("-XX:+UnlockExperimentalVMOptions");
+
+ opts.add("-XX:+UseZGC");
+ params.add(new ArrayList<>(opts));
+
+ opts.add("-ea");
+ params.add(new ArrayList<>(opts));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName)
+ .setDiscoverySpi(new TcpDiscoverySpi()
+ .setLocalAddress("127.0.0.1")
+ .setIpFinder(new TcpDiscoveryVmIpFinder()
+ .setAddresses(Collections.singleton("127.0.0.1:" +
+ TcpDiscoverySpi.DFLT_PORT + ".." + (TcpDiscoverySpi.DFLT_PORT + 1)))
+ ));;
+
+ DataStorageConfiguration dsCfg = new DataStorageConfiguration();
+
+ int pageSize = dsCfg.getPageSize() == 0 ? DataStorageConfiguration.DFLT_PAGE_SIZE : dsCfg.getPageSize();
+
+ dsCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+ .setPersistenceEnabled(false)
Review Comment:
fixed
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListTest.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.freelist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteFutureTimeoutException;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.CallbackExecutorLogListener;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList.IGNITE_PAGES_LIST_STRIPES_PER_BUCKET;
+import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
+
+/**
+ * Test freelists ensuring that the optimization by the C2 Jit compilator was done.
+ */
+@RunWith(Parameterized.class)
+@WithSystemProperty(key = IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, value = "1")
+public class FreeListTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS_COUNT = 5_000;
+
+ /** Signals once method under test is C2 Jit compiled in server node. */
+ CountDownLatch c2JitCompiled = new CountDownLatch(1);
+
+ /** JVM options to start the server node in remote JVM. */
+ @Parameterized.Parameter
+ public List<String> jvmOpts;
+
+ /** */
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<List<String>> params() {
+ ArrayList<List<String>> params = new ArrayList<>(List.of(
+ List.of("-XX:+UseShenandoahGC"),
+ List.of("-XX:+UseShenandoahGC", "-ea"),
+
+ List.of("-XX:+UseG1GC"),
+ List.of("-XX:+UseG1GC", "-ea")
+ ));
+
+ if (Runtime.version().feature() >= 17 || U.isLinux())
+ addZgc(params);
+
+ return params;
+ }
+
+ /**
+ * Ensure that the PagesList$CutTail::run handler is not broken if C2 Jit-compiled.
+ * With various garbage collectors and with assertions both turned on and off.
+ */
+ @Test
+ public void testCutTail() throws Exception {
+ try (Ignite ignite = prepareCluster(jvmOpts,
+ "org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList$CutTail::run")) {
+ IgniteFuture<Void> jobFut = ignite.compute().runAsync(new TestCutTailJob());
+
+ assertTrue(c2JitCompiled.await(getTestTimeout() / 2, TimeUnit.MILLISECONDS));
+
+ try {
+ // Let it work for 2 seconds with the optimized C2 Jit-compiled variant of the
+ // PagesList$CutTail::run method. It's enough to reproduce problem if it is broken.
+ jobFut.get(2000, TimeUnit.MILLISECONDS);
+ }
+ catch (IgniteFutureTimeoutException e) {
+ jobFut.cancel();
+ }
+ }
+ }
+
+ /**
+ * Starts server node in remote JVM with the JVM options passed.
+ * Registers listener to signal once the method passed is C2 Jit-compiled in server node.
+ * Starts client node in local JVM.
+ *
+ * @param jvmOpts JVM options for the server node.
+ * @param method Fully qualified name of method.
+ * @return Client node.
+ */
+ private Ignite prepareCluster(List<String> jvmOpts, String method) throws Exception {
+ CountDownLatch remoteJvmServerStarted = new CountDownLatch(1);
+
+ ListeningTestLogger lsnrLog = new ListeningTestLogger(log);
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(".*Topology snapshot \\[ver=1,.*",
+ remoteJvmServerStarted::countDown));
+
+ lsnrLog.registerListener(new CallbackExecutorLogListener(
+ ".*Compiled method \\(c2\\).*" + method.replace("$", "\\$") + ".*",
+ c2JitCompiled::countDown));
+
+ IgniteConfiguration cfg = optimize(getConfiguration("remote-jvm-server"));
+
+ new IgniteProcessProxy(cfg, lsnrLog, null, false) {
+ @Override protected Collection<String> filteredJvmArgs() throws Exception {
+ Collection<String> args = super.filteredJvmArgs();
+
+ args.remove("-ea");
+
+ args.add("-XX:+UnlockDiagnosticVMOptions");
+ args.add("-XX:PrintAssemblyOptions=intel");
+ args.add("-XX:CompileCommand=print," + method);
+
+ args.addAll(jvmOpts);
+
+ return args;
+ }
+ };
+
+ remoteJvmServerStarted.await(getTestTimeout(), TimeUnit.MILLISECONDS);
+
+ return startClientGrid("local-jvm-client");
+ }
+
+ /**
+ * Perfrom concurrent updates and deletes ensuring the CutTail called enough
+ * times to invoke the C2 optimizing Jit compiler.
+ */
+ private static class TestCutTailJob implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ Ignite ignite;
+
+ /** */
+ Random random = new Random(3793);
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ IgniteCache<Object, Object> cache = ignite.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
+
+ for (int i = 0; i < KEYS_COUNT; i++)
+ cache.put(i, value());
+
+ AtomicBoolean stop = new AtomicBoolean(false);
+
+ CyclicBarrier barrier = new CyclicBarrier(6);
+
+ IgniteInternalFuture<Long> updateFut = runMultiThreadedAsync(() -> {
+ while (!stop.get()) {
+ try {
+ barrier.await(100, TimeUnit.MILLISECONDS);
+
+ cache.put(key(), value());
+ }
+ catch (InterruptedException | BrokenBarrierException ignored) {
+ stop.set(true);
+ }
+ catch (TimeoutException ignored) {
+ // No-op.
+ }
+ catch (Exception ex) {
+ stop.set(true);
+
+ throw ex;
+ }
+ }
+ }, 24, "update");
+
+ while (!stop.get())
+ cache.remove(key());
+
+ barrier.reset();
+
+ try {
+ updateFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** */
+ private int key() {
+ return random.nextInt(KEYS_COUNT);
+ }
+
+ /** */
+ private byte[] value() {
+ return new byte[random.nextInt(12000) + 3000];
+ }
+ }
+
+ /**
+ * Add test parameters for the ZGC garbage collector.
+ */
+ private static void addZgc(ArrayList<List<String>> params) {
+ ArrayList<String> opts = new ArrayList<>();
+
+ if (Runtime.version().feature() < 12)
+ opts.add("-XX:+UnlockExperimentalVMOptions");
+
+ opts.add("-XX:+UseZGC");
+ params.add(new ArrayList<>(opts));
+
+ opts.add("-ea");
+ params.add(new ArrayList<>(opts));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName)
+ .setDiscoverySpi(new TcpDiscoverySpi()
+ .setLocalAddress("127.0.0.1")
+ .setIpFinder(new TcpDiscoveryVmIpFinder()
+ .setAddresses(Collections.singleton("127.0.0.1:" +
+ TcpDiscoverySpi.DFLT_PORT + ".." + (TcpDiscoverySpi.DFLT_PORT + 1)))
+ ));;
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off [ignite]
Posted by "asf-gitbox-commits (via GitHub)" <gi...@apache.org>.
asf-gitbox-commits closed pull request #12074: IGNITE-17734 Fix freelist corruption in JDK17 with ShenandoahGC and assertions turned off
URL: https://github.com/apache/ignite/pull/12074
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org