Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPEED problem with pointers to structure elements #1804

Open
GillesDuvert opened this issue Apr 12, 2024 · 2 comments
Open

SPEED problem with pointers to structure elements #1804

GillesDuvert opened this issue Apr 12, 2024 · 2 comments
Assignees
Labels
SPEED! WIP Work In Progress: PR acceptance will be considered when this label is removed.

Comments

@GillesDuvert
Copy link
Contributor

GillesDuvert commented Apr 12, 2024

There is a huge loss of efficiency in GDL between accessing directly structure members, like !X.TICKV and indirectly via a pointer to it. See this:
toto=replicate(!X,100000L)

GDL> tic & a=max(toto.tickv) & toc
% Time elapsed : 0.038621187 seconds
IDL> tic & a=max(toto.tickv) & toc
% Time elapsed: 0.038397074 seconds.

so far so good.

z=toto.tickv

GDL> tic & a=max(z) & toc 
% Time elapsed : 0.0026879311 seconds.
IDL> tic & a=max(z) & toc         
% Time elapsed: 0.0063710213 seconds.

ok again.
p=ptr_new(toto)

IDL> tic & a=max((*p).tickv) & toc
% Time elapsed: 0.030293941 seconds.
GDL> tic & a=max((*p).tickv) & toc
% Time elapsed : 0.49356413 seconds.

that is, GDL is SIX TIMES slower.

@GillesDuvert
Copy link
Contributor Author

So probably GDL is a bit incapacited when it comes to ptr-to-struct (aka OO 😃 ) programming (widely used in NASA's SSW package --- hence HESSI performances issues) ...

@GillesDuvert GillesDuvert self-assigned this Apr 13, 2024
@GillesDuvert GillesDuvert added the WIP Work In Progress: PR acceptance will be considered when this label is removed. label Apr 13, 2024
@GillesDuvert
Copy link
Contributor Author

hm this will need a bit of ANTLR alas.
max((*p).tickv) is interpreted as (*p) -> creates a copy of (*p) , in this case a huge amount of memory,
then .tickv -> creates a new variable corresponding to this array and apply max() on it to get result.

Speed difference can be largely worse than example if tag size on which we operate is small (say, one byte) and the rest of the structure is huge!

The only possibility IMHO is to get ANTLR to register (*p).tickv as a special kind of node, and have it treat (*p).tickv in one pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SPEED! WIP Work In Progress: PR acceptance will be considered when this label is removed.
Projects
None yet
Development

No branches or pull requests

1 participant