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

Use too many heap objects to get the log stream's data size. #210

Closed
ijsong opened this issue Nov 2, 2022 · 0 comments · Fixed by #211 or #181
Closed

Use too many heap objects to get the log stream's data size. #210

ijsong opened this issue Nov 2, 2022 · 0 comments · Fixed by #211 or #181
Assignees

Comments

@ijsong
Copy link
Member

ijsong commented Nov 2, 2022

When clients ask for the metadata, a log stream replica gets its data size through internal/storage.(*Storage).DiskUsage. Internally, the DiskUsage method walks each item in a given directory and sums those file sizes. However, it causes the use of too many heap objects like the below:

Screen Shot 2022-11-02 at 1 50 15 PM

Rather than directly computing a log stream's data size, we can use functions of underlying storage - pebble. See https://pkg.go.dev/github.com/cockroachdb/pebble#Metrics.DiskSpaceUsage. The DiskSpaceUsage method returns a value already calculated with just a straightforward sum.

@ijsong ijsong self-assigned this Nov 2, 2022
ijsong added a commit to ijsong/varlog that referenced this issue Nov 2, 2022
…torage

The previous method to get the data size of storage belonging to a log stream was costly. Concretely
it used too many heap objects to call `filepath.Walk` API. To avoid this problem, this patch changes
the implementation of `internal/storage.(*Storage).DiskUsage` to use the built-in method of pebble
DB - `DiskSpaceUsage`.

Resolves kakao#210
@ijsong ijsong closed this as completed in 0965fd9 Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant