Hi,

I tested rs274 in batch mode and performance is absolutely poor, when using it 
as a filter, which is default for unix programs.
I found out, that readline - the slowest known unix program - causes that lag.
When using rs274 as filter, you don't need any of the features of readline, so 
I did some research and got these changes:

first src/emc/sai/driver.cc
----------------
--- driver.cc   2020-05-03 06:20:08.751086314 +0200
+++ driver.cc.new       2020-06-06 20:06:50.397288147 +0200
@@ -677,11 +677,14 @@
       interp_set_loglevel(log_level);
 
 
-  if (argc == 1)
+  if (argc == 1 && !go_flag)
     status = interpret_from_keyboard(block_delete, print_stack);
   else /* if (argc == 2 or argc == 3) */
     {
-      status = interp_open(argv[1]);
+      // in batch-mode without input filename we use stdin as inpt file
+      // but use interp_open so just signal, that there is no filename ...
+      if (argc == 1 && go_flag) status = interp_open(NULL);
+      else status = interp_open(argv[1]);
       if (status != INTERP_OK) /* do not need to close since not open */
         {
           report_error(status, print_stack);
----------------

and next file src/emc/rs274ngc/rs274ngc_pre.cc
----------------
--- rs274ngc_pre.cc     2020-06-06 20:26:01.746496497 +0200
+++ rs274ngc_pre.cc.new 2020-06-06 20:22:49.639600731 +0200
@@ -252,7 +252,7 @@
     }
 
   if (_setup.file_pointer != NULL) {
-     if (_setup.file_pointer != stdin) fclose(_setup.file_pointer);
+    fclose(_setup.file_pointer);
     _setup.file_pointer = NULL;
     _setup.percent_flag = false;
   }
@@ -1408,12 +1408,8 @@
       _setup.lazy_closing = 0;
     }
   CHKS((_setup.file_pointer != NULL), NCE_A_FILE_IS_ALREADY_OPEN);
-  
-  if (filename == NULL) _setup.file_pointer = stdin;
-  else {
-     CHKS((strlen(filename) > (LINELEN - 1)), NCE_FILE_NAME_TOO_LONG);
-    _setup.file_pointer = fopen(filename, "r");
-  }
+  CHKS((strlen(filename) > (LINELEN - 1)), NCE_FILE_NAME_TOO_LONG);
+  _setup.file_pointer = fopen(filename, "r");
   CHKS((_setup.file_pointer == NULL), NCE_UNABLE_TO_OPEN_FILE, filename);
   line = _setup.linetext;
   for (index = -1; index == -1;) {      /* skip blank lines */
----------------

difference of old and new version, called like this:

        time rs274 -t ~/linuxcnc/configs/FM45/tool.tbl -v 
~/linuxcnc/configs/FM45/
linuxcnc.var -i ~/linuxcnc/configs/FM45/AFM45.ini -g < 3D_Chips.ngc > 
3D_Chips.test.out


current version from master:
        real            0m20,118s
        user            0m19,530s
        sys             0m0,523s

improved variant:
        real            0m0,186s
        user            0m0,095s
        sys             0m0,087s


Hope you find it useful.


cheers Reinhard




_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to