cpp_client_telemetry icon indicating copy to clipboard operation
cpp_client_telemetry copied to clipboard

BondSplicer is creating an unnecessary copy of the buffer vector

Open sid-dahiya opened this issue 6 years ago • 2 comments

Describe your environment. This issue is related to a change between v1 and v3 bond packets. In lib/packager/BondSplicer.cpp, the method BondSplicer::splice was updated to write bond by writing the buffer as pre-record-blobs to an output buffer. However, the unintended outcome of this change is that we're now copying the buffer as it is, just in multiple parts with two nested loops. This copy of the vector is then returned by the splicer method.

Steps to reproduce. Data upload process reproduces it.

What is the expected behavior? We should just return the m_buffer vector in the splicer method instead of creating a copy.

What is the actual behavior? We return a locally created output vector.

Additional context.

sid-dahiya avatar Dec 17 '19 21:12 sid-dahiya

An initial PR to preallocate the output buffer is #208 . I believe that PR can be abandoned or updated to just return the buffer itself.

sid-dahiya avatar Dec 17 '19 21:12 sid-dahiya

OneDrive Sync is also seeing some crashes on Watson due to std_bad_alloc as seen in stack below. I assume it is due to OOM issue in process. Curious if it is related to this bug

0 | KERNELBASE!RaiseException 1 | VCRUNTIME140!_CxxThrowException |   | 0x0000000000000066 |   |   |   | throw.cpp |   | 74 2 | OneDriveTelemetryExperimental!__scrt_throw_std_bad_alloc |   | 0x000000000000001C |   |   |   | throw_bad_alloc.cpp |   | 35 3 | unknown!unknown |   | 0x0000000000000000 |   |   |   |   |   | 0 4 | OneDriveTelemetryExperimental!std::_Allocate_manually_vector_aligned_std::Default_allocate_traits |   | 0x0000000000000017 |   |   |   | xmemory0 |   | 100 5 | OneDriveTelemetryExperimental!std::Allocate_8,std::Default_allocate_traits,0 |   | 0x0000000000000013 |   |   |   | xmemory0 |   | 194 6 | OneDriveTelemetryExperimental!std::vector_unsigned char,std::allocator_unsigned char _::Insert_range_unsigned char * |   | 0x000000000000006D |   |   |   | vector |   | 1156 7 | OneDriveTelemetryExperimental!Microsoft::Applications::Events::BondSplicer::splice

SDK Version : 3.4.276 Environment : Windows 10

shachau avatar Feb 04 '21 22:02 shachau