Skip to content

Remove real-time search for routines names and more - #2216

Merged
GillesDuvert merged 28 commits into
gnudatalanguage:masterfrom
GillesDuvert:tentative_remove_search_for_routines
Jul 30, 2026
Merged

Remove real-time search for routines names and more#2216
GillesDuvert merged 28 commits into
gnudatalanguage:masterfrom
GillesDuvert:tentative_remove_search_for_routines

Conversation

@GillesDuvert

Copy link
Copy Markdown
Contributor
  1. GDL is constantly looking for values associated to names: variable names, key names, and routine names. It unfortunately does it with a naive loop on the corresponding unsorted string vector. Worse, it does it each time a routine is called, a variable is passed etc. I have modified the code so that the routine names are in an unordered set, and, when searched, the index of the name is the index of the corresponding Pro() or Fun() entry. This makes it quite faster.
  2. Another point of slowness was the possibility in a C++ routine to look to a keyword using its name, not its index. This is now discouraged (Marc Schellens already warned about this a long time ago). In almost all cases, using a static int as the return of e->KeywordIx() insures that all further calls to the routine will not look again for the (same) index. All the code using non-static such ints has been reveiewed and converted to static when possible (almost always). The value for!ERR was frequently searched in the code, now a specialzed function removes this need.
  3. In contrary, it is very difficult to instrument the GDL code to avoid naive O(N) name searches for keywords and variables (say: sort the name array and perform O(log(N)) binary searches), especially as the variables passed by GDL to a function are in an order that mangles keyword-relted variables and parameter variables. A partial solution has been implemented but tests have shown no improvement at all due to the overhead of adding sorted keys etc. So this has to stay as it is now.
  4. In passing a number of other little improvements have been acted:
  • parser optimization in primary_expr()
  • test of wheter a variable in a loop may be the loop index, and warning if it is modified inside the loop was slowing the execution due to the name-to-value search discussed above: the test is removed, unless the new --warn-loop switch is set when calling gdl.
  • crashes with .RESET or .RESET_SESSION are cured.
  • Idem for WIDGET_CONTROL,/RESET
  • operators overload and internal objects definition (overload.cpp) has been reviewed and simplified. LIST and related now are inheriting correct obejcts (CONTAINER). Undocumented (but useful) List::Set has been added.
  • uninitialized elements in the plplot wxwidget driver have been set to 0, removing the annoying warnings when using Valgrind. Possibly more such warnings could be cured similarly.
  • regression in message when function not found : % FCALLNode::Eval - AutoObj #2212 cured

Giloo and others added 28 commits July 6, 2026 00:36
…d on name.

Rewrite all procedure related to finding a FUN or PRO to avoid old loops and simplify/factorize code
Also, rewrote the overload code to  simplify/factorize and use the new mechanism.
Could be simpler, but I kept the list of PRO and FUN separate for OBJECTS (probably a bad idea, to change in future)
I save this intermediate state before fiddling with the interpreter to have compiled procedures call directly the functions, not use a searched index.
…th STRICTARR, this type of construct implies a function)
…RO or FUN type (and call an expensive search-by-name) since SearchCompilePro knows what type of routine it has compiled.
…loopvar is overwritten uses a lot of inefficient name search (and IDL does not do it).Removed test, that can be however set by flag --warn-loop

replaced search for !ERR (inefficient search that cannot be made static due to .RESET) by a pointer function.

solved a few crashing bugs when .RESET was called

small optimisations using static int for index to defined functions/procedures

removed GDLDelete in ~GDLWidget due to a valgrind-detected invalid free (only for Widget_Table, probably in GetTableValueAsStrings, but needs to be well understood)

"followers" widget were not removed (regression)
…ary search and is faster.

I should test if a direct BS on sorted keywords is possible as it should be faster yet.
…ed arraus and indexes actually penalize the execution time!
@GillesDuvert

Copy link
Copy Markdown
Contributor Author

victory: reference version: all tests passed on all platforms.
But we keep in mind #2200 #2177 #2176

@GillesDuvert

Copy link
Copy Markdown
Contributor Author

successful Windows build is obtained by removing the cache.
This should be done each time a build fails for non-gdl reasons.

@GillesDuvert
GillesDuvert merged commit 4329424 into gnudatalanguage:master Jul 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant