Question
Mack Altman III · Jul 12, 2017

Need clarification on usage of globals and global memory

It is my understanding that when a routine accesses a global it is temporarily stored in global memory. While the global is within global memory, any other routine would be able to readily access the global from memory and not from disk so long as the same node is being utilized.

For example, RoutineB() would be able to access ^Global(1) and ^Global(1,2) since RoutineA() utilized them, but RoutineB() would have to read ^Global(1,7) from disk as it was not utilized by RoutineA().

For my own sanity, I wanted to reach out and obtain clarification from the community as I have recently begun to doubt my understanding.

Thank you!

20
1 0 2 269
Log in or sign up to continue

Replies

Global memory works with blocks and not with nodes :

When a global  node is accessed, the block where this global node is stored will be put into memory.

Any routine that needs to access the nodes that are in this block will be served from memory.

So, in your example, if the nodes (1), (1,2) and (1,7) are all stored in the same block, these will all be served from memory after the initial access by routineA.

Blocks are nowadays 8Kb (used to be 2Kb).

I just want to add to this some other benefits of the way the data is stored. The first access of a global will have to read the pointer tree to find the particular node. A subsequent access of another node in the same global would only need to read from disk at the point where that node diverges in the pointer tree from the first. Even if the data blocks are not the same, a 2nd global access would likely be faster, since some of the tree would be cached, so fewer disk reads would be necessary.