Package xbird.storage.io

Examples of xbird.storage.io.FixedSegments


        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength + ", pageSize: " + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                final int threadId = i;
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionSync(pager, cache, capacity, round, percent, scanLength, dist[threadId]);
                            } else {
                                runBenchmarkWithZipfDistributionLock(lock, pager, cache, capacity, round, percent, scanLength, dist[threadId]);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }

        long miss = cache.getCacheMiss();
        long hit = total - miss;
        double hitRatio = ((double) hit) / total;
        double missRatio = ((double) miss) / total;
        System.err.println("["
                + algo
                + " - "
                + filename
                + "] synchronization: "
                + (lock == null ? "sync" : ((lock instanceof NoopLock) ? "non-blocking"
                        : "spinlock")) + ", read: " + total + ", miss: " + miss + ", hit ratio: "
                + hitRatio + ", miss ratio: " + missRatio);
        System.err.println(watchdog.toString());
        System.err.flush();

        pager.close();
    }
View Full Code Here


        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength + ", pageSize: " + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                final int threadId = i;
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionLongHashSync(pager, hash, capacity, round, percent, scanLength, dist[threadId]);
                            } else {
                                runBenchmarkWithZipfDistributionLongHashLock(lock, pager, hash, capacity, round, percent, scanLength, dist[threadId]);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }

        long miss = hash.getCacheMiss();
        long hit = total - miss;
        double hitRatio = ((double) hit) / total;
        double missRatio = ((double) miss) / total;
        System.err.println("["
                + algo
                + " longhash - "
                + filename
                + "] synchronization: "
                + (lock == null ? "sync" : ((lock instanceof NoopLock) ? "non-blocking"
                        : "spinlock")) + ", read: " + total + ", miss: " + miss + ", hit ratio: "
                + hitRatio + ", miss ratio: " + missRatio);
        System.err.println(watchdog.toString());
        System.err.flush();

        pager.close();
    }
View Full Code Here

    private static FixedSegments makeTempSegments(int pageSize) throws IOException {
        File tmpFile = new File("/experiment/data/vldb/xmark10.xml.dtms");
        if(!tmpFile.exists()) {
            throw new IllegalStateException("File not found: " + tmpFile.getAbsolutePath());
        }
        FixedSegments segment = new FixedSegments(tmpFile, pageSize * 1024);
        return segment;
    }
View Full Code Here

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionSync(pager, cache, capacity, round, percent, scanLength, reader);
                            } else {
                                runBenchmarkWithZipfDistributionLock(lock, pager, cache, capacity, round, percent, scanLength, reader);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }

        long miss = cache.getCacheMiss();
        long hit = total - miss;
        double hitRatio = ((double) hit) / total;
        double missRatio = ((double) miss) / total;
        System.err.println("["
                + algo
                + " - "
                + filename
                + "] synchronization: "
                + (lock == null ? "sync" : ((lock instanceof NoopLock) ? "non-blocking"
                        : "spinlock")) + ", read: " + total + ", miss: " + miss + ", hit ratio: "
                + hitRatio + ", miss ratio: " + missRatio);
        System.err.println(watchdog.toString());
        System.err.flush();

        pager.close();
    }
View Full Code Here

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
                + ", invocations: " + total + ", scanPercentage: " + percent + ", scanLength: "
                + scanLength);

        final FixedSegments pager = makeTempSegments(pageSize);

        final ExecutorService exec = Executors.newFixedThreadPool(threads);
        try {
            for(int i = 0; i < threads; i++) {
                exec.submit(new Runnable() {
                    public void run() {
                        try {
                            if(lock == null) {
                                runBenchmarkWithZipfDistributionLongHashSync(pager, hash, capacity, round, percent, scanLength, reader);
                            } else {
                                runBenchmarkWithZipfDistributionLongHashLock(lock, pager, hash, capacity, round, percent, scanLength, reader);
                            }
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        } finally {
            exec.shutdown();
            try {
                exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                ;
            }
        }

        long miss = hash.getCacheMiss();
        long hit = total - miss;
        double hitRatio = ((double) hit) / total;
        double missRatio = ((double) miss) / total;
        System.err.println("["
                + algo
                + " longhash - "
                + filename
                + "] synchronization: "
                + (lock == null ? "sync" : ((lock instanceof NoopLock) ? "non-blocking"
                        : "spinlock")) + ", read: " + total + ", miss: " + miss + ", hit ratio: "
                + hitRatio + ", miss ratio: " + missRatio);
        System.err.println(watchdog.toString());
        System.err.flush();

        pager.close();
    }
View Full Code Here

    private static FixedSegments makeTempSegments(int pageSize) throws IOException {
        File tmpFile = new File("/experiment/data/vldb/xmark10.xml.dtms");
        if(!tmpFile.exists()) {
            throw new IllegalStateException("File not found: " + tmpFile.getAbsolutePath());
        }
        FixedSegments segment = new FixedSegments(tmpFile, pageSize * 1024);
        return segment;
    }
View Full Code Here

            throw new IllegalStateException("File not found: " + tmpFile.getAbsolutePath());
        }
        if(useNIO) {
            return new NioFixedSegment(tmpFile, pageSize * 1024, true);
        } else {
            return new FixedSegments(tmpFile, pageSize * 1024);
        }
    }
View Full Code Here

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
                + ", scanPercentage: " + percent + ", scanLength: " + scanLength + ", pageSize: "
                + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];

        final ReadWriteLock rwlock = new FairReadWriteLock();//new ReentrantReadWriteLock();

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
        for(int i = 0; i < threads; i++) {
            final int threadId = i;
            final Status stat = new Status();
            stats[i] = stat;
            thrs[i] = new Thread() {
                public void run() {
                    while(!_start) {
                        // Spin till Time To Go
                        try {
                            Thread.sleep(1);
                        } catch (Exception e) {
                        }
                    }
                    try {
                        if(lock == null) {
                            if(useRWlock) {
                                runBenchmarkWithZipfDistributionReadWriteLock(rwlock, stat, pager, cache, capacity, round, percent, scanLength, dist[threadId]);
                            } else {
                                runBenchmarkWithZipfDistributionSync(stat, pager, cache, capacity, round, percent, scanLength, dist[threadId]);
                            }
                        } else {
                            runBenchmarkWithZipfDistributionLock(stat, lock, pager, cache, capacity, round, percent, scanLength, dist[threadId]);
                        }
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                }
            };
        }
        // Run threads
        for(int i = 0; i < threads; i++) {
            thrs[i].start();
        }
        _start = true;
        try {
            Thread.sleep(TIME_TO_EST);
        } catch (InterruptedException e) {
        }
        _stop = true;
        for(int i = 0; i < threads; i++) {
            thrs[i].join();
        }

        long numOps = 0L, cacheMisses = 0L, elapsed = 0L, execInterval = 0L, durationHold = 0L;
        for(int i = 0; i < threads; i++) {
            numOps += stats[i].ops;
            cacheMisses += stats[i].miss;
            elapsed += stats[i].mills;
            execInterval += stats[i].execInterval;
            durationHold += stats[i].durationHold;
        }
        long avgElapsedInSec = (elapsed / threads) / 1000L;
        long opsPerSec = numOps / avgElapsedInSec;

        long hit = numOps - cacheMisses;
        double hitRatio = ((double) hit) / numOps;
        double missRatio = ((double) cacheMisses) / numOps;
        System.err.println("["
                + algo
                + " - "
                + filename
                + "] synchronization: "
                + (lock == null ? (useRWlock ? "readWrite" : "sync")
                        : ((lock instanceof NoopLock) ? "non-blocking" : "spinlock")) + ", read: "
                + numOps + ", miss: " + cacheMisses + ", hit ratio: " + hitRatio + ", miss ratio: "
                + missRatio);
        System.err.println(watchdog.toString());
        System.err.println("number of ops: " + numOps + ", average number of ops per second: "
                + opsPerSec + ", total execution interval(msec): " + execInterval
                + ", total duration hold(msec): " + durationHold);
        System.err.flush();

        pager.close();
    }
View Full Code Here

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
                + ", scanPercentage: " + percent + ", scanLength: " + scanLength + ", pageSize: "
                + pageSize);

        final FixedSegments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
        for(int i = 0; i < threads; i++) {
            final int threadId = i;
            final Status stat = new Status();
            stats[i] = stat;
            thrs[i] = new Thread() {
                public void run() {
                    while(!_start) {
                        // Spin till Time To Go
                        try {
                            Thread.sleep(1);
                        } catch (Exception e) {
                        }
                    }
                    try {
                        if(lock == null) {
                            runBenchmarkWithZipfDistributionLongHashSync(stat, pager, hash, capacity, round, percent, scanLength, dist[threadId]);
                        } else {
                            runBenchmarkWithZipfDistributionLongHashLock(stat, lock, pager, hash, capacity, round, percent, scanLength, dist[threadId]);
                        }
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                }
            };
        }
        // Run threads
        for(int i = 0; i < threads; i++) {
            thrs[i].start();
        }
        _start = true;
        try {
            Thread.sleep(TIME_TO_EST);
        } catch (InterruptedException e) {
        }
        _stop = true;
        for(int i = 0; i < threads; i++) {
            thrs[i].join();
        }

        long numOps = 0L, cacheMisses = 0L, elapsed = 0L;
        for(int i = 0; i < threads; i++) {
            numOps += stats[i].ops;
            cacheMisses += stats[i].miss;
            elapsed += stats[i].mills;
        }
        long avgElapsedInSec = (elapsed / threads) / 1000;
        long opsPerSec = numOps / avgElapsedInSec;

        long hit = numOps - cacheMisses;
        double hitRatio = ((double) hit) / numOps;
        double missRatio = ((double) cacheMisses) / numOps;
        System.err.println("["
                + algo
                + " longhash - "
                + filename
                + "] synchronization: "
                + (lock == null ? "sync" : ((lock instanceof NoopLock) ? "non-blocking"
                        : "spinlock")) + ", read: " + numOps + ", miss: " + cacheMisses
                + ", hit ratio: " + hitRatio + ", miss ratio: " + missRatio);
        System.err.println(watchdog.toString());
        System.err.println("number of ops: " + numOps + ", average number of ops per second: "
                + opsPerSec);
        System.err.flush();

        pager.close();
    }
View Full Code Here

    private static FixedSegments makeTempSegments(int pageSize) throws IOException {
        File tmpFile = new File("/experiment/data/xmark32G.xml");
        if(!tmpFile.exists()) {
            throw new IllegalStateException("File not found: " + tmpFile.getAbsolutePath());
        }
        FixedSegments segment = new FixedSegments(tmpFile, pageSize * 1024);
        return segment;
    }
View Full Code Here

TOP

Related Classes of xbird.storage.io.FixedSegments

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.