Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-11531

Merge concurrent registrations of the same binary type

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8
    • Component/s: binary
    • Labels:
      None

      Description

      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:

      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();
                  }
              }
          }
      }
      

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                akalashnikov Anton Kalashnikov
                Reporter:
                dmekhanikov Denis Mekhanikov
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m