Browse Source

HPCC-9017 Use less kernel page cache for roxie copies, update6

Signed-off-by: Mark Kelly <mark.kelly@lexisnexis.com>
Mark Kelly 11 years ago
parent
commit
4e90656aab
2 changed files with 162 additions and 3 deletions
  1. 8 3
      common/remote/sockfile.cpp
  2. 154 0
      testing/unittests/jlibtests.cpp

+ 8 - 3
common/remote/sockfile.cpp

@@ -2260,7 +2260,8 @@ public:
         MemoryBuffer replyBuffer;
         const char *localname = parent->queryLocalName();
         localname = skipSpecialPath(localname);
-        sendBuffer.append((RemoteFileCommandType)RFCopenIO).append(localname).append((byte)_mode).append((byte)_compatmode);
+        // also send _extraFlags
+        sendBuffer.append((RemoteFileCommandType)RFCopenIO).append(localname).append((byte)_mode).append((byte)_compatmode).append((byte)_extraFlags);
         parent->sendRemoteCommand(sendBuffer, replyBuffer);
 
         replyBuffer.read(handle);
@@ -3421,6 +3422,10 @@ public:
         byte mode;
         byte share;
         msg.read(name->text).read(mode).read(share);  
+        // also try to recv extra
+        byte extra = 0;
+        if (msg.remaining() >= sizeof(byte))
+            msg.read(extra);
         try {
             Owned<IFile> file = createIFile(name->text);
             switch ((compatIFSHmode)share) {
@@ -3443,8 +3448,8 @@ public:
                 break;
             }
             if (TF_TRACE_PRE_IO)
-                PROGLOG("before open file '%s',  (%d,%d)",name->text.get(),(int)mode,(int)share);
-            IFileIO *fileio = file->open((IFOmode)mode);
+                PROGLOG("before open file '%s',  (%d,%d,%d)",name->text.get(),(int)mode,(int)share,(int)extra);
+            IFileIO *fileio = file->open((IFOmode)mode,(IFEflags)extra);
             int handle;
             if (fileio) {
                 CriticalBlock block(sect);

+ 154 - 0
testing/unittests/jlibtests.cpp

@@ -22,6 +22,9 @@
 
 #ifdef _USE_CPPUNIT
 #include "jsem.hpp"
+#include "jfile.hpp"
+#include "jdebug.hpp"
+#include "sockfile.hpp"
 
 #include "unittests.hpp"
 
@@ -80,5 +83,156 @@ protected:
 CPPUNIT_TEST_SUITE_REGISTRATION( JlibSemTest );
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( JlibSemTest, "JlibSemTest" );
 
+/* =========================================================== */
+
+class JlibFileIOTest : public CppUnit::TestFixture
+{
+    unsigned rs, nr10pct, nr150pct;
+    char *record;
+    StringBuffer tmpfile;
+    StringBuffer server;
+
+    CPPUNIT_TEST_SUITE( JlibFileIOTest );
+        CPPUNIT_TEST(testIOSmall);
+        CPPUNIT_TEST(testIORemote);
+        CPPUNIT_TEST(testIOLarge);
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    JlibFileIOTest()
+    {
+        HardwareInfo hdwInfo;
+        getHardwareInfo(hdwInfo);
+        rs = 65536;
+        unsigned nr = (unsigned)(1024.0 * (1024.0 * (double)hdwInfo.totalMemory / (double)rs));
+        nr10pct = nr / 10;
+        nr150pct = nr * 1.5;
+        record = (char *)malloc(rs);
+        for (int i=0;i<rs;i++)
+            record[i] = 'a';
+        record[rs-1] = '\n';
+
+        tmpfile.set("JlibFileIOTest.txt");
+        server.set(".");
+        // server.set("192.168.1.18");
+    }
+
+    ~JlibFileIOTest()
+    {
+        free(record);
+    }
+
+protected:
+    void testIO(unsigned nr, SocketEndpoint *ep)
+    {
+        IFile *ifile;
+        IFileIO *ifileio;
+        unsigned fsize = (unsigned)(((double)nr * (double)rs) / (1024.0 * 1024.0));
+
+        fflush(NULL);
+        fprintf(stdout,"\n");
+        fflush(NULL);
+
+        for(int j=0; j<2; j++)
+        {
+            if (j==0)
+                fprintf(stdout, "File size: %d (MB) Cache, ", fsize);
+            else
+                fprintf(stdout, "\nFile size: %d (MB) Nocache, ", fsize);
+
+            if (ep != NULL)
+            {
+                ifile = createRemoteFile(*ep, tmpfile);
+                fprintf(stdout, "Remote: (%s)\n", server.toCharArray());
+            }
+            else
+            {
+                ifile = createIFile(tmpfile);
+                fprintf(stdout, "Local:\n");
+            }
+
+            ifile->remove();
+
+            unsigned st = msTick();
+
+            IFEflags extraFlags = IFEnone;
+            if (j==1)
+                extraFlags = IFEnocache;
+            ifileio = ifile->open(IFOcreate, extraFlags);
+
+            unsigned iter = nr / 40;
+
+            __int64 pos = 0;
+            for (int i=0;i<nr;i++)
+            {
+                ifileio->write(pos, rs, record);
+                pos += rs;
+                if ((i % iter) == 0)
+                {
+                    fprintf(stdout,".");
+                    fflush(NULL);
+                }
+            }
+
+            ifileio->close();
+
+            double rsec = (double)(msTick() - st)/1000.0;
+            unsigned iorate = (unsigned)((double)fsize / rsec);
+
+            fprintf(stdout, "\nwrite - elapsed time = %6.2f (s) iorate = %4d (MB/s)\n", rsec, iorate);
+
+            st = msTick();
+
+            extraFlags = IFEnone;
+            if (j==1)
+                extraFlags = IFEnocache;
+            ifileio = ifile->open(IFOread, extraFlags);
+
+            pos = 0;
+            for (int i=0;i<nr;i++)
+            {
+                ifileio->read(pos, rs, record);
+                pos += rs;
+                if ((i % iter) == 0)
+                {
+                    fprintf(stdout,".");
+                    fflush(NULL);
+                }
+            }
+
+            ifileio->close();
+
+            rsec = (double)(msTick() - st)/1000.0;
+            iorate = (unsigned)((double)fsize / rsec);
+
+            fprintf(stdout, "\nread -- elapsed time = %6.2f (s) iorate = %4d (MB/s)\n", rsec, iorate);
+
+            ifileio->Release();
+            ifile->remove();
+            ifile->Release();
+        }
+    }
+
+    void testIOSmall()
+    {
+        testIO(nr10pct, NULL);
+    }
+
+    void testIOLarge()
+    {
+        testIO(nr150pct, NULL);
+    }
+
+    void testIORemote()
+    {
+        SocketEndpoint ep;
+        ep.set(server, 7100);
+        testIO(nr10pct, &ep);
+    }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( JlibFileIOTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( JlibFileIOTest, "JlibFileIOTest" );
 
 #endif // _USE_CPPUNIT