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

[exporter][batching] Serialized bytes based batching for logs #12299

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-sili
Copy link
Contributor

@sfc-gh-sili sfc-gh-sili commented Feb 5, 2025

Description

This PR implements serialized bytes based batching. Right now, the feature is exposed to test only via an additional field in MaxSizeConfig, but we plan to evolve the config API soon (see discussion in #12154)

type MaxSizeConfig struct {
	MaxSizeItems int `mapstructure:"max_size_items"`
	MaxSizeBytes int `mapstructure:"max_size_bytes"`
}

Link to tracking issue

#3262

Testing

BenchmarkSplittingBasedOnItemCountManySmallLogs-10                    	     409	   2822478 ns/op	 3148718 B/op	   71082 allocs/op
BenchmarkSplittingBasedOnByteSizeManySmallLogs-10                     	     412	   2890594 ns/op	 3156103 B/op	   71242 allocs/op
BenchmarkSplittingBasedOnItemCountManyLogsSlightlyAboveLimit-10       	      38	  27579702 ns/op	43531582 B/op	  700471 allocs/op
BenchmarkSplittingBasedOnByteSizeManyLogsSlightlyAboveLimit-10        	      24	  43067219 ns/op	43639889 B/op	  702927 allocs/op
BenchmarkSplittingBasedOnItemCountHugeLogs-10                         	      40	  29722710 ns/op	41922925 B/op	  690300 allocs/op
BenchmarkSplittingBasedOnByteSizeHugeLogs-10                          	      16	  64321198 ns/op	42107144 B/op	  694144 allocs/op

Caveat

We book keep both item count and byte size regardless of batching option, which adds an overhead in both cases.

@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from 51d907b to 4f8b1fb Compare February 5, 2025 18:59
@sfc-gh-sili sfc-gh-sili changed the title bytes based batching logs [exporter][batching] Serialized bytes based batching for logs Feb 5, 2025
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 91.95402% with 7 lines in your changes missing coverage. Please review.

Project coverage is 92.17%. Comparing base (f024b0d) to head (60f71c9).

Files with missing lines Patch % Lines
pdata/plog/pb.go 0.00% 6 Missing ⚠️
exporter/exporterhelper/logs_batch.go 98.03% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (91.95%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12299      +/-   ##
==========================================
- Coverage   92.19%   92.17%   -0.03%     
==========================================
  Files         466      467       +1     
  Lines       25325    25371      +46     
==========================================
+ Hits        23348    23385      +37     
- Misses       1577     1585       +8     
- Partials      400      401       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch 2 times, most recently from a3b9539 to 9e7b49f Compare February 5, 2025 19:59
@sfc-gh-sili sfc-gh-sili marked this pull request as ready for review February 5, 2025 20:03
@sfc-gh-sili sfc-gh-sili requested review from bogdandrutu, dmitryax and a team as code owners February 5, 2025 20:03
@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from a4221b4 to 669998a Compare February 8, 2025 00:38
@sfc-gh-sili sfc-gh-sili changed the title [exporter][batching] Serialized bytes based batching for logs [chore][exporter][batching] Serialized bytes based batching for logs Feb 8, 2025
Copy link
Contributor

@ms-jcorley ms-jcorley left a comment

Choose a reason for hiding this comment

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

It still makes me slightly uncomfortable that split will accept a cfg with both MaxSizeItems and MaxSizeBytes set and simply ignore the second. I'd rather this function enforce the expectations that only one is set. But given the context, the change overall seems fine to me.

@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from 57457c8 to d3fcbf5 Compare February 12, 2025 06:08
@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from d3fcbf5 to 01f2a11 Compare February 12, 2025 06:08
@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from 01f2a11 to 4752210 Compare February 12, 2025 06:09
@sfc-gh-sili sfc-gh-sili changed the title [chore][exporter][batching] Serialized bytes based batching for logs [exporter][batching] Serialized bytes based batching for logs Feb 12, 2025
@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from 1c718a4 to 826ab1a Compare February 14, 2025 10:59
@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from 826ab1a to 6c1f0ad Compare February 14, 2025 11:00
@sfc-gh-sili sfc-gh-sili requested a review from dmitryax February 14, 2025 11:12
@dmitryax dmitryax added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Feb 18, 2025
@sfc-gh-sili sfc-gh-sili force-pushed the sili-bytes-based-batching-logs-2 branch from 1bf0777 to 697ed11 Compare February 18, 2025 19:27
@sfc-gh-sili sfc-gh-sili requested a review from dmitryax February 19, 2025 18:06
plog.ProtoMarshaler
}

// DeltaCapacity() returns the delta size of a proto slice when a new item is added.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// DeltaCapacity() returns the delta size of a proto slice when a new item is added.
// DeltaSize() returns the delta size of a proto slice when a new item is added.

//
// currSize := (prevSize + deltaCapacity(proto2.Size()))
//
// This is derived from gogo/protobuf 's Size() function
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a link to the Size() function here

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, and you might add that the constant 1 below is specialized for OTLP; it relies on protobuf tags < 16 (which are expressed w/ a single byte of overhead).

//
// Then currSize of proto1 can be calculated as
//
// currSize := (prevSize + deltaCapacity(proto2.Size()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// currSize := (prevSize + deltaCapacity(proto2.Size()))
// currSize := (prevSize + sizer.DeltaSize(proto2.Size()))

ScopeLogsSize(sl plog.ScopeLogs) int
LogRecordSize(lr plog.LogRecord) int

// DeltaCapacity() returns the delta size when a ResourceLog, ScopeLog or LogRecord is added.
Copy link
Contributor

Choose a reason for hiding this comment

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

	// DeltaSize() returns the delta size when a ResourceLog, ScopeLog or LogRecord is added.

//
// currSize := (prevSize + deltaCapacity(proto2.Size()))
//
// This is derived from gogo/protobuf 's Size() function
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, and you might add that the constant 1 below is specialized for OTLP; it relies on protobuf tags < 16 (which are expressed w/ a single byte of overhead).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants