Forráskód Böngészése

HPCC-23925 Enable regex timings by default

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 5 éve
szülő
commit
36bfde6f99
4 módosított fájl, 35 hozzáadás és 51 törlés
  1. 7 2
      ecl/hqlcpp/hqlcpp.cpp
  2. 0 1
      ecl/hqlcpp/hqlcpp.ipp
  3. 8 8
      ecl/hqlcpp/hqlcppsys.ecl
  4. 20 40
      ecl/hqlcpp/hqlhtcpp.cpp

+ 7 - 2
ecl/hqlcpp/hqlcpp.cpp

@@ -1860,7 +1860,6 @@ void HqlCppTranslator::cacheOptions()
         DebugOption(options.generateDiskFormats, "generateDiskFormats", false),
         DebugOption(options.maxOptimizeSize, "maxOptimizeSize", 5),             // Remove the overhead from very small functions e.g. function prolog
         DebugOption(options.minNoOptimizeSize, "minNoOptimizeSize", 10000),     // functions larger than this will take a long time to optimize, better to not try
-        DebugOption(options.timeRegex, "timeRegex", false),
     };
 
     //get options values from workunit
@@ -6361,7 +6360,13 @@ void HqlCppTranslator::doBuildCall(BuildCtx & ctx, const CHqlBoundTarget * tgt,
 
     CHqlBoundExpr boundTimer, boundStart;
     if (external->hasAttribute(timeAtom))
-        buildStartTimer(ctx, boundTimer, boundStart, str(external->queryId()));
+    {
+        StringBuffer nameTemp;
+        const char * name = str(external->queryId());
+        if (getStringValue(nameTemp, queryAttributeChild(external, timeAtom, 0)).length())
+            name = nameTemp;
+        buildStartTimer(ctx, boundTimer, boundStart, name);
+    }
 
     //either copy the integral value across, or a var string to fixed string
     if (returnMustAssign)

+ 0 - 1
ecl/hqlcpp/hqlcpp.ipp

@@ -831,7 +831,6 @@ struct HqlCppOptions
     bool                genericDiskReads;
     bool                generateActivityFormats;
     bool                generateDiskFormats;
-    bool                timeRegex;
 };
 
 //Any information gathered while processing the query should be moved into here, rather than cluttering up the translator class

+ 8 - 8
ecl/hqlcpp/hqlcppsys.ecl

@@ -553,19 +553,19 @@ const char * cppSystemText[]  = {
     "   unicode wregexReplaceX(unsigned8 compiled, const unicode text, const unicode replace)   :   eclrtl,pure,include='eclrtl.hpp',library='eclrtl',entrypoint='rtlWRegExprReplace';",
     "   unicode wregexGetFindStr(unsigned8 compiled, unsigned4 idx):    eclrtl,pure,include='eclrtl.hpp',library='eclrtl',entrypoint='rtlWRegExprGetFindStr';",
 
-    "   regexNewSetStrPattern(const varstring _pattern, boolean isCaseSensitive) : omethod,entrypoint='setPattern';"
-    "   regexNewStrFind(boolean _compiled, const string _search, boolean _cloneSearch) : omethod,entrypoint='find';"
+    "   regexNewSetStrPattern(const varstring _pattern, boolean isCaseSensitive) : omethod,entrypoint='setPattern',time('CompileStringRegex');"
+    "   regexNewStrFind(boolean _compiled, const string _search, boolean _cloneSearch) : omethod,entrypoint='find',time('REGEXFIND');"
     "   boolean regexNewStrFound() : method,pure,entrypoint='found';"
     "   string regexNewStrFoundX(unsigned4 idx) : method,pure,entrypoint='getMatchX';"
-    "   string regexNewStrReplaceX(const string _search, const string _replace) : method,pure,entrypoint='replace';"
-    "   set of string regexMatchSet(const string _search) : method,pure,entrypoint='getMatchSet';"
+    "   string regexNewStrReplaceX(const string _search, const string _replace) : method,pure,entrypoint='replace',time('REGEXREPLACE');"
+    "   set of string regexMatchSet(const string _search) : method,pure,entrypoint='getMatchSet',time('REGEXFINDSET');"
 
-    "   regexNewSetUStrPattern(const varunicode _pattern, boolean isCaseSensitive) : omethod,entrypoint='setPattern';"
-    "   regexNewUStrFind(boolean _compiled, const unicode _search) : omethod,entrypoint='find';"
+    "   regexNewSetUStrPattern(const varunicode _pattern, boolean isCaseSensitive) : omethod,entrypoint='setPattern',time('CompileUnicodeRegex');"
+    "   regexNewUStrFind(boolean _compiled, const unicode _search) : omethod,entrypoint='find',time('REGEXFIND');"
     "   boolean regexNewUStrFound() : method,pure,entrypoint='found';"
     "   unicode regexNewUStrFoundX(unsigned4 idx) : method,pure,entrypoint='getMatchX';"
-    "   unicode regexNewUStrReplaceX(const unicode _search, const unicode _replace) : method,pure,entrypoint='replace';"
-    "   set of unicode regexUStrMatchSet(const unicode _search) : method,pure,entrypoint='getMatchSet';"
+    "   unicode regexNewUStrReplaceX(const unicode _search, const unicode _replace) : method,pure,entrypoint='replace',time('REGEXREPLACE');"
+    "   set of unicode regexUStrMatchSet(const unicode _search) : method,pure,entrypoint='getMatchSet',time('REGEXFINDSET');"
 
     //clibrary functions that are called from the code generation
     "   free(noconst data1 src) : eclrtl,library='eclrtl',entrypoint='rtlFree';",

+ 20 - 40
ecl/hqlcpp/hqlhtcpp.cpp

@@ -18328,6 +18328,8 @@ void HqlCppTranslator::doBuildNewRegexFindReplace(BuildCtx & ctx, const CHqlBoun
     bool isUnicode = isUnicodeType(search->queryType());
     IHqlExpression * compiled = doBuildRegexCompileInstance(ctx, pattern, isUnicode, !expr->hasAttribute(noCaseAtom));
 
+    // Because the search instance is created locally, the search parameter is always going to be valid
+    // as long as the find instance.  Only exception could be if call created a temporary class instance.
     if (expr->getOperator() == no_regex_replace)
     {
         HqlExprArray args;
@@ -18338,51 +18340,29 @@ void HqlCppTranslator::doBuildNewRegexFindReplace(BuildCtx & ctx, const CHqlBoun
         OwnedHqlExpr call = bindFunctionCall(func, args);
         //Need to associate???
         buildExprOrAssign(ctx, target, call, bound);
-        return;
     }
-
-    // Because the search instance is created locally, the search parameter is always going to be valid
-    // as long as the find instance.  Only exception could be if call created a temporary class instance.
-    bool cloneSearch = false;
-    CHqlBoundExpr boundTimer, boundStart;
-    if (options.timeRegex)
+    else
     {
-        StringBuffer regexName;
-        regexName.append(getOpString(expr->getOperator()));
-
-        if (pattern->queryId())
-            regexName.append("(").append(str(pattern->queryId())).append(")");
-        else if (pattern->isConstant())
+        bool cloneSearch = false;
+        IHqlExpression * findInstance = doBuildRegexFindInstance(ctx, compiled, search, cloneSearch);
+        if(expr->queryType() == queryBoolType())
         {
-            StringBuffer patternText;
-            getUTF8Value(patternText, pattern);
-            // Replace colons in the pattern to avoid issues with scopes, and single quotes to avoid xpath quoting issues
-            patternText.replace(':', '_').replace('\'', '_');
-            regexName.append("(").append(patternText).append(")");
+            HqlExprArray args;
+            args.append(*LINK(findInstance));
+            IIdAtom * func= isUnicode ? regexNewUStrFoundId : regexNewStrFoundId;
+            OwnedHqlExpr call = bindFunctionCall(func, args);
+            buildExprOrAssign(ctx, target, call, bound);
+        }
+        else
+        {
+            HqlExprArray args;
+            args.append(*LINK(findInstance));
+            args.append(*LINK(expr->queryChild(2)));
+            IIdAtom * func= isUnicode ? regexNewUStrFoundXId : regexNewStrFoundXId;
+            OwnedHqlExpr call = bindFunctionCall(func, args);
+            buildExprOrAssign(ctx, target, call, bound);
         }
-
-        buildStartTimer(ctx, boundTimer, boundStart, regexName);
-    }
-    IHqlExpression * findInstance = doBuildRegexFindInstance(ctx, compiled, search, cloneSearch);
-    if(expr->queryType() == queryBoolType())
-    {
-        HqlExprArray args;
-        args.append(*LINK(findInstance));
-        IIdAtom * func= isUnicode ? regexNewUStrFoundId : regexNewStrFoundId;
-        OwnedHqlExpr call = bindFunctionCall(func, args);
-        buildExprOrAssign(ctx, target, call, bound);
-    }
-    else
-    {
-        HqlExprArray args;
-        args.append(*LINK(findInstance));
-        args.append(*LINK(expr->queryChild(2)));
-        IIdAtom * func= isUnicode ? regexNewUStrFoundXId : regexNewStrFoundXId;
-        OwnedHqlExpr call = bindFunctionCall(func, args);
-        buildExprOrAssign(ctx, target, call, bound);
     }
-    if (options.timeRegex)
-        buildStopTimer(ctx, boundTimer, boundStart);
 }
 
 void HqlCppTranslator::doBuildExprRegexFindReplace(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & bound)