Denis Mekhanikov created IGNITE-11531:
-----------------------------------------
Summary: Merge concurrent registrations of the same binary type
Key: IGNITE-11531
URL: https://issues.apache.org/jira/browse/IGNITE-11531
Project: Ignite
Issue Type: Improvement
Components: binary
Reporter: Denis Mekhanikov
When a binary type is registered multiple times simultaneously, then a lot of
type versions are generated with the same schema. It leads to long binary type
registration especially on big topologies.
The following code sample demonstrates the problem:
{code:java}
public class LongRegistration {
public static void main(String[] args) throws InterruptedException {
Ignite ignite = Ignition.start(igniteConfig());
int threadsNum = 50;
ExecutorService exec = Executors.newFixedThreadPool(threadsNum);
CyclicBarrier barrier = new CyclicBarrier(threadsNum);
long startTime = System.currentTimeMillis();
// register(ignite);
for (int i = 0; i < threadsNum; i++)
exec.submit(new TypeRegistrator(ignite, barrier));
exec.shutdown();
exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
System.out.println("Total registration time: " +
(System.currentTimeMillis() - startTime));
}
private static IgniteConfiguration igniteConfig() {
IgniteConfiguration igniteCfg = new IgniteConfiguration();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setLocalAddress("127.0.0.1");
discoverySpi.setLocalPort(47500);
discoverySpi.setIpFinder(ipFinder);
igniteCfg.setDiscoverySpi(discoverySpi);
return igniteCfg;
}
private static void register(Ignite ignite) {
long startTime = System.currentTimeMillis();
IgniteBinary binary = ignite.binary();
BinaryObjectBuilder builder = binary.builder("TestType");
builder.setField("intField", 1);
builder.build();
System.out.println("Registration time: " + (System.currentTimeMillis()
- startTime));
}
private static class TypeRegistrator implements Runnable {
private Ignite ignite;
private CyclicBarrier cyclicBarrier;
TypeRegistrator(Ignite ignite, CyclicBarrier cyclicBarrier) {
this.ignite = ignite;
this.cyclicBarrier = cyclicBarrier;
}
@Override public void run() {
try {
cyclicBarrier.await();
register(ignite);
} catch (InterruptedException | BrokenBarrierException e) {
e.printStackTrace();
}
}
}
}
{code}
This code sample leads to registration of 50 versions of the same type. The
effect is more noticeable if a cluster contains a lot of nodes.
If you uncomment the call to {{register()}} method, then overall registration
becomes 10 times faster on topology of 5 nodes.
Registration of matching types should be merged to avoid long processing of
such cases.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)