- 
                Notifications
    
You must be signed in to change notification settings  - Fork 285
 
Add scoreboard 🏆 #1236
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
base: master
Are you sure you want to change the base?
Add scoreboard 🏆 #1236
Conversation
| 
           Thanks to @duckaxe for combing over my NG stuff 🤝  | 
    
          
 As with all flash we need to be careful to not erase from NVS at high frequency as this can wear out the flash. I think keeping the high score list in NVS is a great idea. Just need to be aware that we only get something like 100,000 erase cycles on a ESP32 flash sector before it will wear out and be unreliable. An erase every minute would be bad (~ 2 months MTBF), an erase every hour (~ 11 years MTBF) would probably be fine. The esp-idf NVS library does some wear leveling afaik, but I wouldn't want to rely on that. generally speaking, just changing a value in flash involves a erase cycle on the whole sector.  | 
    
          
 Apologies for the long reply, it was a deeper rabbit hole than I expected. I did some reading, and initially bad news: the current NVS partition is only 24kb, which means 6 pages of 4kb. However, the write pattern is more subtle, and that's good news: each page is an append log, and writes are append onto the same page without an erase. Updates are also appended, and the old value is marked as deleted. Only when a page is full, it starts to use a next page. If all but the last empty page is used, a full page is recycled, where still valid key/values are moved to a new page and it's actually flash erased. link We are currently at ~33% usage of NVS, Added some statistics: The difference between free and available is old values that are marked as deleted, and will at some time be garbage collected page. Each entry is 32 bytes: small values (8, 16 or 32 bit) are a single entry, blobs and strings can be more than one entry. Blobs have 2 entries overhead and string have 1 entry overhead. I also looked at repartitioning, but that's a tricky avenue. It has been done, but makes f.e. downgrades very challenging. This PR doesn't warrant that. So, not sure here. It's possible to add 20 NVS string entries with all values concatenated per line. This would be around 80 NVS entries. IMO this is a reasonable trade-off for write granularity. Having the scoreboard persistent is making it a lot more fun. More ways of celebrating high difficulties and to have an idea when they happened and how rare a high difficulty is gives a lot of insight in the process.  | 
    
| 
           Besides the NVS storage aspect, are there other fields that should be added or replaced?  | 
    
| 
           This does feel a little bit outside of the practical use of the ESP32's limited NVS. I could image the high scoreboard being a good thing to punt to the client dashboard to keep track of.. Or maybe just ESP32 RAM?  | 
    
| 
           lol I added it, as I wanted to test if it would work. With 20 entries as strings, I get the following NVS statistics: Exactly 80 entries are added, the math works out. It uses about 10% of NVS storage, it's now at 43%. The first few minutes have quite a few updates, but as the difficulty rises quickly, the number of updates will drop really fast. A minimum threshold before saving an entry would reduce that. 
 I agree, it's pushing it a bit. But as I mentioned above, at the same time it's also a really informative addition, IMO. And having the scoreboard survive a reboot is chefs kiss 😆 To not paint ourselves into the corner, I'll experiment a bit with adding a second NVS partition at the end of the partition table. I can't find a conclusive answer from the documentation if this is allowed/possible or not.  | 
    
| 
           Some improvements mutatrum#4  | 
    
Some layout improvements
| 
           A little fix for smaller screens mutatrum#6  | 
    
| 
           Wouldn't it be good if the highest difficulty level to date could be adopted? Of course, not all the information is available anymore. Perhaps it could be replaced with ‘*’ or something else. But then the list would be complete. At least in first place.  | 
    
        
          
                main/http_server/axe-os/src/app/components/scoreboard/scoreboard.component.html
              
                Outdated
          
            Show resolved
            Hide resolved
        
      
          
 I though about that, but think that's more grief than necessary. I'm running my Gamma now for ~ 9 months, so to get a new higher best, it would take on average another 9 months. (I didn't calculate, but it has a 5G best difficulty, no idea what the odds are for that.) To get that score flushed out of the top 20, it would need 20 higher scores, which would probably take longer than the lifetime of the device. Then for the rest of the lifetime of the device, there will be a single line item that can't be sorted and shows empty fields.  | 
    
          
 I agree with you. However, as is easy to see, people are very focused on the interest/pursuit of high difficulty.  | 
    
| 
           A Summary would be helpful:  | 
    
| 
           A top 20 of all worker (swarm) would also be nice.  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested, my main concern is def the nvs though
could the scoreboard be updated in ram and written periodically?
          
 After a week or two there's maybe one update a day or so, it's good for decades.  | 
    
This PR adds a scoreboard screen that shows the top 20 shares:
And an
api/system/scoreboardapi call:Currently it captures all the fields from
mining.submit, but others can be added. Not sure if adding the full header and resulting hash should be added.