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

graph: move graph cache out of CRUD layer #9544

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c0389f2
graph/db: rename graph.go file
ellemouton Feb 18, 2025
a058774
graph/db: rename ChannelGraph and introduce the new ChannelGraph layer
ellemouton Feb 18, 2025
311a14a
graph/db: fix linter issues of old code
ellemouton Feb 19, 2025
cc3ded8
graph/db: rename Options to KVStoreOptions
ellemouton Feb 18, 2025
c95e753
multi: add ChannelGraph Config struct
ellemouton Feb 18, 2025
ac107ab
graph/db: let ChannelGraph init the graphCache
ellemouton Feb 18, 2025
138e846
graph/db: move cache read checks to ChannelGraph.
ellemouton Feb 18, 2025
54208bc
graph/db: move various cache write calls to ChannelGraph
ellemouton Feb 18, 2025
1788668
graph/db: refactor delChannelEdgeUnsafe to return edge info
ellemouton Feb 17, 2025
28dd4e0
graph/db: move some cache writes to ChannelGraph.
ellemouton Feb 17, 2025
39964ce
graph/db: move cache update out of pruneGraphNodes
ellemouton Feb 17, 2025
b3f75fb
graph/db: move cache writes for Prune methods
ellemouton Feb 17, 2025
c4294b2
graph/db: move FilterKnownChanIDs zombie logic up one layer
ellemouton Feb 19, 2025
44c4c19
graph/db: move cache write for MarkEdgeZombie
ellemouton Feb 25, 2025
7454c15
graph/db: move cache write for UpdateEdgePolicy
ellemouton Feb 17, 2025
7d17e5f
graph/db: completely remove cache from KVStore
ellemouton Feb 18, 2025
fb4ec92
multi: add Start and Stop methods for ChannelGraph
ellemouton Feb 19, 2025
c9e57c2
graph/db: populate the graph cache in Start instead of during constru…
ellemouton Feb 19, 2025
b97e322
itest: rename closure for clarity
ellemouton Mar 3, 2025
50e0702
docs: update release notes
ellemouton Mar 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion autopilot/prefattach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ func newDiskChanGraph(t *testing.T) (testGraph, error) {
})
require.NoError(t, err)

graphDB, err := graphdb.NewChannelGraph(backend)
graphDB, err := graphdb.NewChannelGraph(&graphdb.Config{KVDB: backend})
require.NoError(t, err)

require.NoError(t, graphDB.Start())
t.Cleanup(func() {
require.NoError(t, graphDB.Stop())
})

return &testDBGraph{
db: graphDB,
databaseChannelGraph: databaseChannelGraph{
Expand Down
16 changes: 10 additions & 6 deletions config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,26 +1026,30 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
"instances")
}

graphDBOptions := []graphdb.OptionModifier{
graphDBOptions := []graphdb.KVStoreOptionModifier{
graphdb.WithRejectCacheSize(cfg.Caches.RejectCacheSize),
graphdb.WithChannelCacheSize(cfg.Caches.ChannelCacheSize),
graphdb.WithBatchCommitInterval(cfg.DB.BatchCommitInterval),
}

chanGraphOpts := []graphdb.ChanGraphOption{
graphdb.WithUseGraphCache(!cfg.DB.NoGraphCache),
}

// We want to pre-allocate the channel graph cache according to what we
// expect for mainnet to speed up memory allocation.
if cfg.ActiveNetParams.Name == chaincfg.MainNetParams.Name {
graphDBOptions = append(
graphDBOptions, graphdb.WithPreAllocCacheNumNodes(
chanGraphOpts = append(
chanGraphOpts, graphdb.WithPreAllocCacheNumNodes(
graphdb.DefaultPreAllocCacheNumNodes,
),
)
}

dbs.GraphDB, err = graphdb.NewChannelGraph(
databaseBackends.GraphDB, graphDBOptions...,
)
dbs.GraphDB, err = graphdb.NewChannelGraph(&graphdb.Config{
KVDB: databaseBackends.GraphDB,
KVStoreOpts: graphDBOptions,
}, chanGraphOpts...)
if err != nil {
cleanUp()

Expand Down
2 changes: 2 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ The underlying functionality between those two options remain the same.
- [Abstract autopilot access](https://github.com/lightningnetwork/lnd/pull/9480)
- [Abstract invoicerpc server access](https://github.com/lightningnetwork/lnd/pull/9516)
- [Refactor to hide DB transactions](https://github.com/lightningnetwork/lnd/pull/9513)
- Move the [graph cache out of the graph
CRUD](https://github.com/lightningnetwork/lnd/pull/9544) layer.

* [Golang was updated to
`v1.22.11`](https://github.com/lightningnetwork/lnd/pull/9462).
Expand Down
Loading
Loading