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

Remove heap allocations when flushing the nodes or cached leaves #196

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

cec489
Copy link
Contributor

@cec489 cec489 commented Jul 23, 2024

Address issue #195

@cec489
Copy link
Contributor Author

cec489 commented Aug 4, 2024

Learning about golang "escape analysis". I tried a building with -gcflags="-m", and shows that my changes from calling "make" to declaring a var, are not helping. For example, func (m *NodesBackEnd) dbPut (line 74:80)

blockchain/utreexoio.go:74:7: leaking param content: m
blockchain/utreexoio.go:75:6: moved to heap: buf
blockchain/utreexoio.go:78:2: moved to heap: serialized

@cec489
Copy link
Contributor Author

cec489 commented Aug 4, 2024

My other change, adding ClearMaps doesn't allocate to the heap:

blockchain/internal/utreexobackends/cachedleavesmap.go:126:7: leaking param content: ms
blockchain/internal/utreexobackends/cachedleavesmap.go:130:16: make([]map[utreexo.Hash]uint64, len(ms.maxEntries)) escapes to heap
blockchain/internal/utreexobackends/cachedleavesmap.go:132:20: make(map[utreexo.Hash]uint64, ms.maxEntries[i]) escapes to heap
blockchain/internal/utreexobackends/cachedleavesmap.go:139:7: leaking param content: ms
blockchain/internal/utreexobackends/cachedleavesmap.go:153:7: leaking param content: ms

@kcalvinalvin
Copy link
Contributor

Ran memory profiling on 853aa68d vs current master. Verified that the memory profiling does show that there's less overhead for 853aa68d.

Before:
IMG_0056

After:
IMG_0057

@kcalvinalvin kcalvinalvin merged commit b9fcbfc into utreexo:main Aug 6, 2024
4 checks passed
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