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

[rrd4j] Reuse the state for identical values #16379

Merged
merged 1 commit into from Feb 8, 2024

Conversation

joerg1985
Copy link
Contributor

Description

A lot of items report the same value for some time, the same State can be used to avoid creating the identical State instances again and again.

Signed-off-by: Jörg Sautter <joerg.sautter@gmx.net>
@joerg1985 joerg1985 requested a review from a team as a code owner February 5, 2024 20:41
@J-N-K
Copy link
Member

J-N-K commented Feb 6, 2024

Do you have an idea how much memory/time is saved by this code?

@joerg1985
Copy link
Contributor Author

@J-N-K sure, when locking at a graph with one week of data, there are ~ 10000 datapoints.
Here are some numbers based on items in my openHab instance:

Item Same as previouse value Different than previouse value
Temperatur outside item 8113 1941
Temperatur inside item 8097 1957
Solar power item 9350 706
Radon item 9281 773
Raspi Temperature item 6154 3900

For these items 60% to 90% of the state's are duplicates compared to the previouse value.
Creating a state is quite heavy, as it creates a String from the double and parses it back into a BigDecimal.
It's hard to tell the concrete memory / time savings here, i think the high percentages of duplicates speaks for them self.

The effect does depend on the data, so when looking at a random number item, this would be more like 0%.
But the overhead of comparing two doubles is minimal an should not harm in theses cases.

@J-N-K J-N-K merged commit eff4496 into openhab:main Feb 8, 2024
3 checks passed
@J-N-K J-N-K added the enhancement An enhancement or new feature for an existing add-on label Feb 8, 2024
@J-N-K J-N-K added this to the 4.2 milestone Feb 8, 2024
austvik pushed a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
Signed-off-by: Jörg Sautter <joerg.sautter@gmx.net>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants