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

Gracefully recover from nested value-key marshalling #97

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

masih
Copy link
Member

@masih masih commented Oct 6, 2022

The previous behaviour of value-key merger in certain scenarios may have been resulted in value-keys being marshalled repeatedly. This was the underlying cause of the issue captured in #94 and corrected in #95.

The work here adds to the corrections by gracefully fixing such records by unmarshalling them recursively until we reach values with the expected key prefix, and de-duplicating them as necessary. The fix is done opportunistically, in that whenever such values are detected during reads and writes they are fixed.

Additional tests are added to simulate nested marshalling of value-keys and assert that the resulting merge is as expected for both merge-older and merge-newer cases.

The previous behaviour of value-key merger in certain scenarios may have
been resulted in value-keys being marshalled repeatedly. This was the
underlying cause of the issue captured in #94 and corrected in #95.

The work here adds to the corrections by gracefully fixing such records
by unmarshalling them recursively until we reach values with the
expected key prefix, and de-duplicating them as necessary. The fix is
done opportunistically, in that whenever such values are detected during
reads and writes they are fixed.

Additional tests are added to simulate nested marshalling of value-keys
and assert that the resulting merge is as expected for both merge-older
and merge-newer cases.
@masih
Copy link
Member Author

masih commented Oct 6, 2022

Workload 0 benchmark results:

$ go test ./bench -bench='(Pebble|Storethehash)(Put|Get)_W(0)'  -count=3 -timeout=300m

PASS
ok      github.com/filecoin-project/go-indexer-core/bench       98.029s
name                        time/op
Store_PebblePut_W0-8           1.84s ±23%
Store_PebbleGet_W0-8           8.84s ± 9%
Store_StorethehashPut_W0-8     3.61s ± 7%
Store_StorethehashGet_W0-8     8.72s ± 6%

name                        speed
Store_PebblePut_W0-8        19.0MB/s ±21%
Store_PebbleGet_W0-8        3.88MB/s ± 9%
Store_StorethehashPut_W0-8  9.47MB/s ± 6%
Store_StorethehashGet_W0-8  3.92MB/s ± 6%

name                        size
Store_PebblePut_W0-8           48.4M ± 0%
Store_PebbleGet_W0-8           45.5M ± 0%
Store_StorethehashPut_W0-8     87.4M ± 0%
Store_StorethehashGet_W0-8     87.4M ± 0%

name                        alloc/op
Store_PebblePut_W0-8           154MB ± 4%
Store_PebbleGet_W0-8          19.7GB ± 0%
Store_StorethehashPut_W0-8     992MB ± 2%
Store_StorethehashGet_W0-8    1.72GB ± 5%

name                        allocs/op
Store_PebblePut_W0-8           2.84M ± 5%
Store_PebbleGet_W0-8           36.7M ± 0%
Store_StorethehashPut_W0-8     11.8M ± 2%
Store_StorethehashGet_W0-8     31.5M ± 5%

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2022

Codecov Report

Merging #97 (d372a91) into main (3f4a7b4) will increase coverage by 0.13%.
The diff coverage is 90.90%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #97      +/-   ##
==========================================
+ Coverage   63.47%   63.61%   +0.13%     
==========================================
  Files          15       15              
  Lines        2779     2803      +24     
==========================================
+ Hits         1764     1783      +19     
- Misses        753      757       +4     
- Partials      262      263       +1     
Impacted Files Coverage Δ
store/pebble/vk_merger.go 91.20% <90.74%> (-4.32%) ⬇️
store/pebble/pebble.go 59.89% <100.00%> (ø)

if _, pendingDelete := v.deletes[string(value)]; pendingDelete {
return true
}
for _, x := range v.merges {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many elements do you expect to be in v.merges? Would it make sense to have an additional hashtable to avoid full scan?

Copy link
Member Author

@masih masih Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for not using a map to store merges is that we need to maintain the insertion order. Iteration order over map in Golang is non-deterministic I'm afraid.

Copy link
Contributor

@ischasny ischasny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one minor comment.

@masih masih merged commit 70adc52 into main Oct 6, 2022
@masih masih deleted the masih/graceful_recov_nested_vk_marshal branch October 6, 2022 13:53
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.

3 participants