You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2019/04/26 10:19:26 UTC
[GitHub] [activemq-artemis] franz1981 commented on issue #2646: ARTEMIS-2317
Reuse file buffer wrapper instances to reduce allocations
franz1981 commented on issue #2646: ARTEMIS-2317 Reuse file buffer wrapper instances to reduce allocations
URL: https://github.com/apache/activemq-artemis/pull/2646#issuecomment-487007870
The speed of `Page::read` has been measured by a handrolled test added on `org.apache.activemq.artemis.tests.unit.core.paging.impl.PageTest`:
```java
@Test
public void testReadSpeedWithNIO() throws Exception {
recreateDirectory(getTestDir());
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(getTestDirfile(), 1);
SequentialFile file = factory.createSequentialFile("00010.page");
Page impl = new Page(new SimpleString("something"), new NullStorageManager(), factory, file, 10);
Assert.assertEquals(10, impl.getPageId());
impl.open();
Assert.assertEquals(1, factory.listFiles("page").size());
SimpleString simpleDestination = new SimpleString("Test");
final int numberOfElements = 10 * 1024 * 1024 / 100;
addPageElements(simpleDestination, impl, numberOfElements);
final int fileSize = impl.getSize();
System.out.println("fileSize = " + fileSize);
impl.sync();
impl.close();
file = factory.createSequentialFile("00010.page");
file.open();
impl = new Page(new SimpleString("something"), new NullStorageManager(), factory, file, 10);
final int tests = 10;
final int times = 100;
NullStorageManager manager = new NullStorageManager();
for( int t = 0; t<tests;t++) {
long totalTime = 0;
for (int m = 0; m<times;m++) {
final long start = System.nanoTime();
List<PagedMessage> msgs = impl.read(manager);
final long elapsed = System.nanoTime() - start;
totalTime+=elapsed;
Assert.assertEquals(numberOfElements, msgs.size());
Assert.assertEquals(numberOfElements, impl.getNumberOfMessages());
for (int i = 0; i < msgs.size(); i++) {
Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddressSimpleString());
}
}
final long totalBytes = fileSize * times;
final long megaPerSec = (totalBytes * 1000L)/ totalTime;
System.out.println(megaPerSec + " MB/sec");
System.gc();
}
impl.delete(null);
Assert.assertEquals(0, factory.listFiles(".page").size());
}
```
Although it is a naive one, this test stress the best case scenario of `Page::read` ie when a file page is already into the OS page cache.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services