Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Change API Performance

If I use a ChangeSet with an SQLQuery that returns 1000 objects it takes longer to execute than a readMultiple with the same SQLQuery followed by a variable assignment and a subsequent writeMultiple. Tested with 12.1.1 against a 2,1 sync2backup on the same machine. Is there any reason why?

asked 2018-03-22 09:44:51 -0500

jb.ext gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Hi, Can you please attache related code.Change should indeed be faster than read and write.

Thanks, Ester.

answered 2018-03-26 04:19:51 -0500

Ester gravatar image
edit flag offensive delete link more

Comments

Ester

Part of the problem is that were using a range query on the Id, but it only had a basic index; using an extended improved the performance. However it's still not as fast as we would expect.

Steps:

1 - run with create=true to populate

2- run with create=false and either cache or view=true

3- run with write=true and then with cache=true

Regards

John

PS - You will need the generic client code I created

package com.socgen.itec.sds.tools.client;

import java.sql.Date;

import org.openspaces.core.GigaSpace; import org.openspaces.core.GigaSpaceConfigurer; import org.openspaces.core.space.SpaceProxyConfigurer; import org.openspaces.core.space.cache.LocalCacheSpaceConfigurer; import org.openspaces.core.space.cache.LocalViewSpaceConfigurer;

import com.gigaspaces.client.ChangeSet; import com.j_spaces.core.client.SQLQuery; import com.socgen.itec.sds.tools.object.PojoObject;

public class CacheClient extends GigaClient {

private static Boolean CREATE=false;

private static Boolean CACHE=true;
private static Boolean VIEW=false;

private static Boolean WRITE=true;
private static Boolean CHANGE=false;


@Override
public void run() {

    LocalCacheSpaceConfigurer localCacheConfigurer = null;
    LocalViewSpaceConfigurer localViewConfigurer = null;

    if (CACHE) {
        SpaceProxyConfigurer urlConfigurer = new SpaceProxyConfigurer("space");
        urlConfigurer.lookupLocators(getLocators());
        localCacheConfigurer = new LocalCacheSpaceConfigurer(urlConfigurer);
        GigaSpace localCache = new GigaSpaceConfigurer(localCacheConfigurer).gigaSpace();
    }

    if (VIEW) {
        SpaceProxyConfigurer urlConfigurer = new SpaceProxyConfigurer("space");
        urlConfigurer.lookupLocators(getLocators());
        localViewConfigurer = new LocalViewSpaceConfigurer(urlConfigurer)
            .batchSize(1000)
            .batchTimeout(100)
            .maxDisconnectionDuration(1000*60*60)
            .addProperty("space-config.engine.memory_usage.high_watermark_percentage", "90")
            .addProperty("space-config.engine.memory_usage.write_only_block_percentage", "88")
            .addProperty("space-config.engine.memory_usage.write_only_check_percentage", "86")
            .addProperty("space-config.engine.memory_usage.retry_count", "5")
            .addProperty("space-config.engine.memory_usage.explicit", "false")
            .addProperty("space-config.engine.memory_usage.retry_yield_time", "50")
            .addViewQuery(new SQLQuery(PojoObject.class, "id >= 0"));
        // Create local view:
        GigaSpace localView = new GigaSpaceConfigurer(localViewConfigurer).gigaSpace();
    }

    if (CREATE) {
        for (int i = 0; i < 200000; i++) {
            PojoObject p = new PojoObject(i, "Hello, World!", new Date(System.currentTimeMillis()));
            space.write(p);
        }
    }

    long total = 0;
    if (WRITE) {
        for (int i = 0; i < 200; i++) {
            SQLQuery<PojoObject> query = new SQLQuery<PojoObject>(PojoObject.class, "id >= ? and id < ?" );
            query.setParameter(1, i * 1000);
            query.setParameter(2, i * 1000 + 1000);
            long beg = System.currentTimeMillis();
            PojoObject[] pojos = space.readMultiple(query);
            for (PojoObject p : pojos) {
                p.setProcessed(! p.getProcessed());
            }
            space.writeMultiple(pojos);
            long end = System.currentTimeMillis();
            System.out.println("writeMultiple took " + (end-beg));
            total += (end-beg);
        }
        System.out.println("average writeMultiple took " + (total/200));
    }

    if (CHANGE) {
        total = 0;
        for (int i = 0; i < 200; i++) {
            SQLQuery<PojoObject> query = new SQLQuery<PojoObject>(PojoObject.class, "id >= ? and id < ?" );
            query.setParameter(1, i * 1000);
            query.setParameter(2, i * 1000 + 1000);
            ChangeSet changes = new ChangeSet().set("processed", true);
            long beg = System.currentTimeMillis();
            space.change(query, changes);
            long end = System.currentTimeMillis();
            System.out.println("changeSet took " + (end-beg));
            total += (end-beg);
        }
        System.out.println("average changeSet took " + (total/200));
    }
    if (localCacheConfigurer != null) localCacheConfigurer.close();
    if (localViewConfigurer != null) localViewConfigurer.close();

    System.out.println("done");

}

public static void main(String[] args) {

    CacheClient cc = new CacheClient();

    cc.run(args);
}

}

jb.ext gravatar imagejb.ext ( 2018-03-26 04:33:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-22 09:44:51 -0500

Seen: 90 times

Last updated: Mar 26