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

Reduce in-memory size of telemetry values #395

Open
akhenry opened this issue Nov 14, 2023 · 0 comments
Open

Reduce in-memory size of telemetry values #395

akhenry opened this issue Nov 14, 2023 · 0 comments
Labels
performance type:enhancement New feature or request

Comments

@akhenry
Copy link
Owner

akhenry commented Nov 14, 2023

Is your feature request related to a problem? Please describe.
Telemetry value objects returned by the openmct-yamcs adapter include a timestamp, a value, and an id. Adding an object ID to every telemetry values adds significantly to the size of the object (potentially on the order of 30% from my testing). We should find a way to remove the need to carry an ID on every telemetry value.

Additionally, storing the timestamp as a string results in larger in-memory object sizes. We might investigate converting this to an integer which is a much more memory-efficient way of storing time. We might also get a CPU saving because the Time API needs an integer for time comparisons anyway.

Describe the solution you'd like
Remove the ID altogether. Do some performance testing of integer timestamps to understand the cost.

Reproduction steps for measuring memory usage of the different approaches

const bigObj = {id: '~myproject~Gyro.z', timestamp: '2023-11-14T20:44:47.682Z', value: 18.533648};
const smolObj = {timestamp: '2023-11-14T20:44:47.682Z', value: 18.533648};
const smolrObj = {timestamp: 1699994687682, value: 18.533648};
const bigObjects = [];
const smolObjects = [];
const smolrObjects = [];

function fillArray(array, objectToClone, size){
    for (let i=0; i < size; i++){
        // Has to be a clone otherwise you're just repeatedly pushing a reference to the same object, which is not a valid test
        array.push(structuredClone(objectToClone));
    }
}

// Fill each array with 1 million objects
fillArray(bigObjects, bigObj, 1000000);
fillArray(smolObjects, smolObj, 1000000);
fillArray(smolrObjects, smolrObj, 1000000);

Now open Chrome memory tab, take a heap snapshot, order by Retained Size and observe the following -

Screen Shot 2023-11-14 at 1 16 13 PM

Array Size Change
bigObjects 113 216 992 N/A
smolObjects 81 216 920 -28%
smolrObjects 57 216 860 -49%
@akhenry akhenry added the type:enhancement New feature or request label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants