Flash Writes - on what is it based?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
chromo23
Normal user
Posts: 827
Joined: 10 Sep 2020, 16:02
Location: germany

Flash Writes - on what is it based?

#1 Post by chromo23 » 09 Dec 2022, 10:35

Since i do a lot of testing (especially for easyfetch) i exceed the "daily flash write limit" several times a day.
So i looked how many flashwrites a change and a hit the submit button is causing. Sometimes its two sometimes three.
Now I'm wondering how these numbers come about.
What is a flash write cycle based on?

(And would it be hard to make an special build where all changes are only stored in ram. :D A special chromo23-easyfetch-developer-edition :ugeek: )

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Flash Writes - on what is it based?

#2 Post by TD-er » 09 Dec 2022, 10:53

There is a check for changes in checksum, to prevent saving unchanged settings.

There are several things that may be saved:
- Security Settings (every password like stuff, has checksum)
- SettingsStruct (almost all settings of ESPEasy, has checksum)
- ExtraTaskSettings (taskname/taskvarname/formula/nrdecimals, all at the bottom of the task pages)
- CustomTaskSettings (Used by some plugins, like those display plugins)

To see the whole list, including where it is stored in the config.dat file, run the command "meminfodetail"
Then open the sysinfo page and scroll to the bottom.

Each separate block described in that chart that has to be written will be counted as a flash write.

User avatar
chromo23
Normal user
Posts: 827
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Flash Writes - on what is it based?

#3 Post by chromo23 » 09 Dec 2022, 11:42

TD-er wrote: 09 Dec 2022, 10:53 run the command "meminfodetail"
Woooooooahhhhh... 8-)

User avatar
chromo23
Normal user
Posts: 827
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Flash Writes - on what is it based?

#4 Post by chromo23 » 09 Dec 2022, 12:19

There is a check for changes in checksum, to prevent saving unchanged settings.
But maybe i have found a bug then?

When i open a Device (e.g. Dummy Device) and hit Submit > 2 flash writes > hit submit again (nothing changed) > 2 flash writes > and so on...

This shouldn’t happen than, right?

Edit:
(And would it be hard to make an special build where all changes are only stored in ram. :D A special chromo23-easyfetch-developer-edition :ugeek: )
And what do you think of this? Is this something easy to change. (i guess not but thought i ask anyway)

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Flash Writes - on what is it based?

#5 Post by TD-er » 09 Dec 2022, 13:47

Depends... the ExtraTaskSettings (the taskname/taskvaluename, etc) is cached. But when you save stuff, the caches are cleared.
And not sure what will be decided when the cache is cleared and you have not changed anything.
So it could be a "missed opportunity for optimization" when it does save it.
But on the other hand, it is always a trade-off between space/speed and making sure things work correctly and to be honest, I prefer the last one ;)

On ESP32 we do have a lot more memory, so this could be used to check if things have changed, but again it also requires a lot of extra checks to see if the cache is still valid.

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Flash Writes - on what is it based?

#6 Post by TD-er » 09 Dec 2022, 13:55

What you could do, is you can increase the write count max to like 1000x.
But keep in mind this limit is there for a reason....

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Flash Writes - on what is it based?

#7 Post by TD-er » 09 Dec 2022, 13:57

Suggested define to use:

CUSTOM_FLASH_WRITE_LIMIT_YES_I_KNOW_WHAT_I_AM_DOING_IS_WRONG_BUT_LEAVE_ME_ALONE

User avatar
chromo23
Normal user
Posts: 827
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Flash Writes - on what is it based?

#8 Post by chromo23 » 09 Dec 2022, 14:01

ResetFlashWriteCounter works just fine for me :)

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Flash Writes - on what is it based?

#9 Post by TD-er » 09 Dec 2022, 14:05

OK, you can call it from the rules to reset this periodically ;)

User avatar
chromo23
Normal user
Posts: 827
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Flash Writes - on what is it based?

#10 Post by chromo23 » 09 Dec 2022, 14:42

Jep.
And i gladly like to share the code:
resetflashwrite.gif
resetflashwrite.gif (160.22 KiB) Viewed 1506 times

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Flash Writes - on what is it based?

#11 Post by TD-er » 09 Dec 2022, 17:34

The only thing missing is a goto....

Post Reply

Who is online

Users browsing this forum: No registered users and 58 guests