microstream-one / microstream

High-Performance Java-Native-Persistence. Store and load any Java Object Graph or Subgraphs partially, Relieved of Heavy-weight JPA. Microsecond Response Time. Ultra-High Throughput. Minimum of Latencies. Create Ultra-Fast In-Memory Database Applications & Microservices.
https://microstream.one/
Eclipse Public License 2.0
560 stars 44 forks source link

is it safe to change defaultSlotSize of class BinaryStorer from 1024 to 10240 for performance? #703

Open useryq8 opened 8 months ago

useryq8 commented 8 months ago

Environment Details

Describe the bug

For more higher performance , I adjust the defaultSlotSize of class BinaryStorer from 1024 to 10240, org.eclipse.serializer.persistence.types.DefaultObjectRegistry minimumCapacity from 1 to 1024;

the eclipse store performance is higher then default, Could I do like this and it is safe? do any one know why this change can increase the performance? Thank you very much. @fh-ms @hg-ms

` public class Default implements BinaryStorer, PersistenceStoreHandler, PersistenceLocalObjectIdRegistry { /////////////////////////////////////////////////////////////////////////// // constants // //////////////

    private final static Logger logger = Logging.getLogger(BinaryStorer.class);

    protected static int defaultSlotSize()
    {
        // why permanently occupy additional memory with fields and instances for constant values?
        return 10240; // anything below 1024 doesn't pay of
    }`

public final class DefaultObjectRegistry implements PersistenceObjectRegistry public static DefaultObjectRegistry New(final float hashDensity) { return New(hashDensity, 10240); } img_v3_028e_4cb0e424-60ef-4865-9afe-83b79f0357dg

image

To Reproduce

change the defaultSlotSize of class org.eclipse.serializer.persistence.binary.types.BinaryStorer from 1024 to 10240 change the minimumCapacity of class org.eclipse.serializer.persistence.types.DefaultObjectRegistry from 1 to 1024

Expected behavior

EclipseStore works well

I

hg-ms commented 8 months ago

Yes, it’s safe to increase those values. Both define the initial size of internal data structures that hold management data of processed objects. In case of the DefaultObjectRegistry they hold management data for all persisted objects. In case of the BinaryStorer they contain temporary management data for the objects to be persisted. Those data structures are recreated with there size doubled if they get too small, which is an expensive operation. A drawback of increasing those initial values is that the related data structures may occupy much more memory then required after they got increased.