Skip to content

Conversation

@micrology
Copy link

After running y-websocket-server with a moderate load (e.g. 12 concurrent clients) for some hours, the memory it used grew to around 4GB. On investigation, this was due to (a) yDocs not being disposed of after use (see the y-websocket-server PR#7 (b) levelDB iterators not being properly destroyed in y-leveldb. This PR deals with the latter. In combination, the changes result in a reduction in memory use (rss=) from about 3950MB to 1100MB under identical conditions, with the memory used by levelDB reducing from about 1500MB to 4MB.

This dramatic reduction in leveldb memory is achieved by using native iterators for the bulk functions such as getLevelBulkEntries, and providing some explicit memory thresholds for its cache to guard against excessive memory use (the values should be adequate for most loads).

There are no consequent changes to the y-leveldb interface - this version is a drop in replacement for the old.

The inline documentation has also been rationalised.

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.

1 participant