Skip to content

Conversation

@rpc-fw
Copy link

@rpc-fw rpc-fw commented Dec 20, 2021

With this patch alloc_kv() will scan sectors in a circular fashion, instead of starting from the first sector every time. Alloc_kv will check the sectors in sector cache first, and then continue scanning from the sector it found during the previous alloc. This improves write performance when total number of sectors is large, as fully used sectors no longer need to be inspected.

The improvement should be clearly noticeable when writing to the last sectors of a large kvdb. I used it on a 512 kb flash region, with each sector 4 kb in size.

@armink
Copy link
Owner

armink commented Dec 21, 2021

I will need some time to review it. Do you have some test data before and after the patch?

@rpc-fw
Copy link
Author

rpc-fw commented Dec 21, 2021

I have some logs from a test program that was writing 2 kb values in 4 kb sectors. The log captured shows the progress between two GC runs. The test randomly picks one out of 4 KVs, and each KV is first read, then written. For each read and write I logged the number of CPU cycles it took, the number of sectors read, and the number of sectors written. You can see the number of accessed sectors grow as more sectors are taken into use. After GC the writes are fast again.

default_without_circular_fix_.txt
with_circular_fix_.txt

In another test I write small values in the kvdb and observe that alloc_kv returns with my patch addresses that do not reset to 0 after the GC run (when sectors get full) but instead continue increasing until the end of the flash, after which they return back to zero. Log the value of empty_kv at the end of alloc_kv to see it.

@armink
Copy link
Owner

armink commented Dec 21, 2021

OK, Thx. I' ll test it in this weekend.

@rpc-fw
Copy link
Author

rpc-fw commented Jan 10, 2022

Did you have a chance to try it? Any thoughts?

@armink
Copy link
Owner

armink commented Jan 10, 2022

hi, @rpc-fw , I have reviewed your PR. There are a lot of changes in this PR. I'm trying a simpler way to modify.

Please wait some time for me. Thx. ;>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants