Explorar o código

HPCC-16683 Avoid unnecessary traversing the body of delayed calls

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday %!s(int64=8) %!d(string=hai) anos
pai
achega
9a146008bc
Modificáronse 6 ficheiros con 22 adicións e 18 borrados
  1. 3 2
      ecl/eclcc/eclcc.cpp
  2. 9 6
      ecl/hql/hqlexpr.cpp
  3. 4 4
      ecl/hql/hqlexpr.ipp
  4. 1 1
      ecl/hql/hqltrans.cpp
  5. 2 1
      ecl/hql/hqltrans.ipp
  6. 3 4
      system/jlib/jarray.hpp

+ 3 - 2
ecl/eclcc/eclcc.cpp

@@ -1851,6 +1851,9 @@ void EclCompileInstance::logStats()
         DBGLOG("Stats:,parse,%u,generate,%u,peakmem,%u,xml,%" I64F "u,cpp,%" I64F "u",
                 stats.parseTime, stats.generateTime, (unsigned)(peakResident / 0x100000),
                 (unsigned __int64)stats.xmlSize, (unsigned __int64)stats.cppSize);
+
+        //Following only produces output if the system has been compiled with TRANSFORM_STATS defined
+        dbglogTransformStats(true);
     }
 }
 
@@ -2279,8 +2282,6 @@ void EclCC::processBatchedFile(IFile & file, bool multiThreaded)
             Owned<IErrorReceiver> localErrs = createFileErrorReceiver(logFile);
             EclCompileInstance info(&file, *localErrs, logFile, outFilename, optLegacyImport, optLegacyWhen);
             processFile(info);
-            //Following only produces output if the system has been compiled with TRANSFORM_STATS defined
-            dbglogTransformStats(true);
             if (info.wu &&
                 (info.wu->getDebugValueBool("generatePartialOutputOnError", false) || info.queryErrorProcessor().errCount() == 0))
             {

+ 9 - 6
ecl/hql/hqlexpr.cpp

@@ -10476,10 +10476,13 @@ IHqlExpression *CHqlExternalDatasetCall::clone(HqlExprArray &newkids)
 
 //==============================================================================================================
 
-CHqlDelayedCall::CHqlDelayedCall(IHqlExpression * _param, ITypeInfo * _type, HqlExprArray &_ownedOperands) : CHqlExpressionWithType(no_call, _type, _ownedOperands), param(_param)
+CHqlDelayedCall::CHqlDelayedCall(IHqlExpression * _funcdef, ITypeInfo * _type, HqlExprArray &_ownedOperands) : CHqlExpressionWithType(no_call, _type, _ownedOperands), funcdef(_funcdef)
 {
-    infoFlags |= (param->getInfoFlags() & HEFalwaysInherit);
-    infoFlags2 |= (param->getInfoFlags2() & HEF2alwaysInherit);
+    IHqlExpression * body = funcdef;
+    if (body->getOperator() == no_funcdef)
+        body = body->queryChild(0);
+    infoFlags |= (body->getInfoFlags() & HEFalwaysInherit);
+    infoFlags2 |= (body->getInfoFlags2() & HEF2alwaysInherit);
 }
 
 bool CHqlDelayedCall::equals(const IHqlExpression & _other) const
@@ -10488,7 +10491,7 @@ bool CHqlDelayedCall::equals(const IHqlExpression & _other) const
         return false;
 
     const CHqlDelayedCall & other = static_cast<const CHqlDelayedCall &>(_other);
-    if (param != other.param)
+    if (funcdef != other.funcdef)
         return false;
     return true;
 }
@@ -10496,12 +10499,12 @@ bool CHqlDelayedCall::equals(const IHqlExpression & _other) const
 void CHqlDelayedCall::sethash()
 {
     CHqlExpression::sethash();
-    HASHFIELD(param);
+    HASHFIELD(funcdef);
 }
 
 IHqlExpression *CHqlDelayedCall::clone(HqlExprArray &newkids)
 {
-    return makeDelayedCall(LINK(param), newkids);
+    return makeDelayedCall(LINK(funcdef), newkids);
 }
 
 

+ 4 - 4
ecl/hql/hqlexpr.ipp

@@ -988,15 +988,15 @@ typedef class MapXToMyClassViaBase<IAtom *, IAtom *, IFileContents, IFileContent
 
 class CHqlDelayedCall: public CHqlExpressionWithType
 {
-    OwnedHqlExpr param;
+    OwnedHqlExpr funcdef;
 protected:
     CHqlDelayedCall(IHqlExpression * _param, ITypeInfo * type, HqlExprArray &parms);
-    virtual IAtom * queryName() const { return param->queryName(); }
-    virtual IIdAtom * queryId() const { return param->queryId(); }
+    virtual IAtom * queryName() const { return funcdef->queryName(); }
+    virtual IIdAtom * queryId() const { return funcdef->queryId(); }
     virtual void sethash();
     virtual bool equals(const IHqlExpression & other) const;
     virtual IHqlExpression *clone(HqlExprArray &newkids);
-    virtual IHqlExpression *queryFunctionDefinition() const { return param; };
+    virtual IHqlExpression *queryFunctionDefinition() const { return funcdef; };
 public:
     static IHqlExpression *makeDelayedCall(IHqlExpression * _param, HqlExprArray &operands);
 };

+ 1 - 1
ecl/hql/hqltrans.cpp

@@ -215,7 +215,7 @@ HqlTransformerInfo::~HqlTransformerInfo()
 #ifdef TRANSFORM_STATS
     StringBuffer s;
     if (getStatsText(s))
-        printf(s.newline().str());
+        printf("%s\n", s.str());
 #endif
 }
 

+ 2 - 1
ecl/hql/hqltrans.ipp

@@ -33,13 +33,14 @@
 
 typedef MapOwnedToOwned<IHqlExpression, IHqlExpression> MapOwnedHqlToOwnedHql;
 
+//NOTE: eclcc needs to be run with the -m option for the summary to be output
 //#define TRANSFORM_STATS
 //#define TRANSFORM_STATS_OPS
 //#define TRANSFORM_STATS_TIME
 //#define TRANSFORM_STATS_MEMORY
 //#define ALLOW_TRANSFORM_TRACING
 
-class HqlTransformStats
+class HQL_API HqlTransformStats
 {
 public:
     HqlTransformStats();

+ 3 - 4
system/jlib/jarray.hpp

@@ -45,7 +45,6 @@ typedef int (* StdCompare)(const void *_e1, const void *_e2);
 class jlib_decl Allocator
 {
 public:
-    Allocator() { _init(); }
     void  kill();
     inline bool isItem(aindex_t pos = 0) const    { return pos < used; }      /* Is there an item at pos */
     inline aindex_t length() const                 { return used; } /* Return number of items  */
@@ -67,9 +66,9 @@ protected:
     void doSwapWith(Allocator & other);
 
 protected:
-    void * _head;
-    aindex_t used;
-    aindex_t max;
+    void * _head = nullptr;
+    aindex_t used = 0;
+    aindex_t max = 0;
 };