clee704 opened a new pull request, #565: URL: https://github.com/apache/datasketches-cpp/pull/565
Fixes #551. Allocation failure during HLL construction, promotion, copying or updating can leak storage or leave a sketch pointing to freed or inconsistent state. Guard unfinished objects and conversion/promotion results, roll back sparse and auxiliary insertions, and make HLL_4 shifts transactional. Copy assignment uses copy-and-swap. Sparse unions install each promoted owner before processing another coupon. Unequal-allocator merges preserve the union's allocator and upstream precision rules. Auxiliary-map clones use the original allocator for the object and entries. The sketch's documented guarantee is: > Allocation failures propagate without leaking storage. Updates, copy assignment and > reset leave the sketch unchanged if an allocation fails. The union's documented guarantee is: > Allocation failures propagate without leaking storage. If an allocation fails while > a LIST or SET sketch is merged into a union in LIST or SET mode, the union stays valid > and usable, holding the coupons inserted before the failure. Repeating the merge gives > the result of an uninterrupted merge. All other updates, copy assignment and reset > leave the union unchanged if an allocation fails. Reject overfull compact SET images and invalid SET precision before allocation. HLL_4 shifts also reject orphan exception tokens; rejected shifts preserve the image, and shared exception diagnostics remain unchanged. The tests sweep allocation failures, verify cleanup and rollback, retry merges and check source-pool lifetimes. With GCC 13.3.0 and Clang 18.1.3, one-shot and sticky failure probes pass address/undefined-behavior checks; valid-image, estimate and bounds comparisons match the base corpus. Selecting-pool and non-raw-pointer fixtures also pass with libc++ 18. Cross-language checks with datasketches-java 8.0.0 pass in both directions for the upstream serde test images, with results identical to the base. At lg12, assignment region-instruction increases reach 4.62% with GCC 13.3.0 and 3.46% with Clang 18.1.3. Other operation-region increases stay below 1%. Copy-and-swap retains the old destination until copying succeeds. GCC 13.3.0 paired timing changes: - Overlapping SET-source unions: lg12 2.4-2.7%; lg12 warmed control 2.7-2.8%. - Dense unions: lg12 1.5-1.6%. - Threshold unions: lg12 LIST 0.1-0.9%. - Slower LIST/SET assignment aggregate medians: 2-7%. Clang 18.1.3 paired timing changes: - Fresh LIST work: HLL_4/lg12 1.6-1.7%; HLL_8/lg12 -0.1 to 1.2%; HLL_4/lg21 1.8-1.9%. - Short promotion streams: HLL_8/lg12 2.3-2.5%; HLL_6/lg21 2.4-3.9%; HLL_8/lg21 0.3-1.9%. - Single-sketch HLL_8 stream (20 million updates, lg12): 3.0% (49-pair median; 95% paired-median interval 0.6-6.3%). - SET work: HLL_4/lg21 2.8-3.5%; HLL_6/lg21 3.1-3.3%; HLL_8/lg21 2.4-3.8%. - Distinct five-item-source unions: lg12 9.5-10.5%; lg21 0.3-1.1%. - Overlapping SET-source unions: lg12 1.5-1.6%; lg12 warmed control 0.8-1%; lg21 0.9-1.3%; lg21 warmed control 0.5-1.1%. - Overlapping LIST-source unions: lg12 1.8-3.7%; lg12 warmed control 3-9%. - HLL_8-to-HLL_4 conversion: lg12 3-3.5%; lg21 2-2.1%. - Threshold unions: lg12 LIST 3.1-3.2%. - Slower LIST/SET assignment aggregate medians: 6.5-17.5%. SET batch medians reached about 19% here (about 21% in earlier work). - Dense assignment: HLL_4/lg12 1.8-4.2%. These are observed paired results on a shared host, not bounds. No other non-assignment workload showed a consistent increase of 0.5% or more. The ownership/rollback implementation is retained; timing-cause attribution remains unverified. This change was developed with assistance from GitHub Copilot. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
