Commit Graph

3120 Commits

Author SHA1 Message Date
Derek Mauro
8d0221ce21 Apply LTS transformations for 20260107 LTS branch (#1989) 20260107.rc1 2026-01-07 11:11:28 -05:00
Derek Mauro
6d8e1a5cf0 Mark legacy Mutex methods and MutexLock pointer constructors as deprecated
Updates `absl::Mutex` and related RAII lockers (`absl::MutexLock`,
etc) to deprecate legacy APIs in favor of standard-compliant
alternatives.
  * `absl::Mutex`: Adds `[[deprecated]]` to legacy CamelCase methods
    (e.g., `Lock`, `ReaderLock`) in favor of standard C++ lower-case
    methods (`lock`, `lock_shared`) which support `std::scoped_lock`.
  * `absl::MutexLock` (and friends): Adds `[[deprecated]]` to
    constructors accepting raw pointers, favoring new
    reference-accepting constructors.

To support this change, warnings coming from external repositories
are now suppressed in Bazel CI builds.

PiperOrigin-RevId: 852978576
Change-Id: I54ae951f28a1b7d90fcb46ceeaf09f192af257df
2026-01-06 16:22:35 -08:00
Aaron Jacobs
685995bea7 cleanup: specify that it's safe to use the class in a signal handler.
The class is intentionally designed for exactly what is needed here: no type
erasure, and therefore allocations and no locks taken. It's also not conceivable
that we would ever change this without introducing a new API, as doing so would
serve no purpose and harm performance.

PiperOrigin-RevId: 852955861
Change-Id: I67bb75cf17c1184392bbec6ed9d15faee2f6376b
2026-01-06 15:18:20 -08:00
Abseil Team
37147f50e6 Suppress bugprone-use-after-move in benign cases
PiperOrigin-RevId: 852923303
Change-Id: I41ef782f514ad4301b928b49f3659f4dac3d11fd
2026-01-06 13:55:13 -08:00
Abseil Team
9391635247 StrFormat: format scientific notation without heap allocation
PiperOrigin-RevId: 852845312
Change-Id: I26dcfc5784383d1cf86fab795ba931445f24c575
2026-01-06 10:44:01 -08:00
Abseil Team
bbb342c6de Introduce a legacy copy of GetDebugStackTraceHook API.
PiperOrigin-RevId: 852842182
Change-Id: Iadec9bb2fec60b9962a557f82ac998f3cf8d56fe
2026-01-06 10:37:18 -08:00
Vitaly Goldshteyn
6bd8e2b51a Report 1ns instead of 0ns for probe_benchmarks. Some tools incorrectly assume that benchmark was not run if 0ns reported.
PiperOrigin-RevId: 852831533
Change-Id: Ibf2e60dcb308928358ddf80dc4d2f7eda8a78530
2026-01-06 10:15:56 -08:00
Derek Mauro
7599e36e7c Add absl::chunked_queue
This change introduces absl::chunked_queue, a sequence container
optimized for use as a FIFO (First-In, First-Out) queue. It is similar
in purpose to std::deque but with different performance trade-offs and
features.

absl::chunked_queue stores elements in a series of
exponentially-growing chunks of memory.

absl::chunked_queue is often a better choice than std::deque in the
following situations:
  * Large queues: For very large numbers of elements, the exponential
    growth strategy of absl::chunked_queue can lead to fewer, larger
    memory allocations compared to std::deque, which can be a
    performance advantage.
  * Strict FIFO processing: When you only need to add elements to the
    back (push_back) and remove them from the front (pop_front).

std::deque should be preferred in the following cases:
  * Operations at both ends: std::deque is designed for efficient
    insertions and deletions at both the front and the
    back. absl::chunked_queue is optimized for push_back and pop_front
    and does not offer a pop_back method.
  * Random access: std::deque provides amortized O(1) random access to
    elements via operator[]. absl::chunked_queue does not support
    random access.
PiperOrigin-RevId: 850999629
Change-Id: Ie71737c10b6125b9e498109267cac87a4ca2f9e8
2026-01-01 05:09:05 -08:00
Vitaly Goldshteyn
60b607be5b CRC32 version of CombineContiguous for length <= 32.
For length in [17, 32] we compute two chain of dependent CRC32  operations to have good entropy in the resulting two 32 bit numbers.
1. x := CRC32(CRC32(state, A), D)
2. y := CRC32(CRC32(bswap(state), C), B)

On ARM:
  CRC32 has 2 cycles latency and throughput equal to 1.
  Computations will be pipelined without any wait.
On x86:
  CRC32 has 3 cycles latency and throughput equal to 1.
  There will be 1 extra cycle wait, but we can do `cmp` in parallel.

At the end we multiply (mul - x) * (y - mul). mul is added to fill upper 32 bits of CRC result with good entropy bits. `mul = rotr(kMul, len)`

We also mixing length differently:
1. `state + 8 * len` (`lea` instruction), later one or two CRC shuffle these bits well into low 32 bit.
2. `rotr(kMul, len)` is used for filling high 32 bits before multiplication in `Mix`. This avoid reading from `kStaticRandomData`.

For smaller strings we try to extremely minimize binary size and register pressure.
CRC instruction fused with memory read is used. llvm-mca reporting 1 cycle smaller latency compared to separate `mov` + `crc`.

ASM analysis https://godbolt.org/z/e1xrKzhdc:
1. 100+ bytes binary size saving (per inline instance)
2. 25+ instruction saving
3. 2 registers are not used (r8 and r9).

Latency in isolation without accounting comparison are controversial.
1. latency for 8 bytes in isolation is 1 cycle better: https://godbolt.org/z/zc39eM3K9
2. latency for 1-3 bytes in isolation is 2 cycles better: https://godbolt.org/z/qMKfbv438
3. latency for 16 bytes in isolation is 3 cycles worse: https://godbolt.org/z/vcqr8oGv3
4. latency for 32 bytes in isolation is 5 cycles worse:
https://godbolt.org/z/nEPP5jP58

PiperOrigin-RevId: 850659551
Change-Id: I02a2434f2d98473b099c171ef1c56adffa821c60
2025-12-31 00:51:54 -08:00
Abseil Team
7b40ebf946 Add absl::down_cast
PiperOrigin-RevId: 850445526
Change-Id: I15e34dc543dc5aa72ae58ff471410d219fef2444
2025-12-30 10:05:03 -08:00
Derek Mauro
f788bc3d62 Fix FixedArray iterator constructor, which should require
input_iterator, not forward_iterator

PiperOrigin-RevId: 850356318
Change-Id: If728cc6f4c0eedd4729b73860df8498f4fe6a139
2025-12-30 03:56:02 -08:00
Evan Brown
647ed70eff Add a latency benchmark for hashing a pair of integers.
Note: we don't use std::pair because PodRand requires a pod type.
PiperOrigin-RevId: 850090182
Change-Id: I01d46ede3371d2424a8f392d3f192e55b86afd6a
2025-12-29 10:04:52 -08:00
Derek Mauro
2d4a5a87fd Delete absl::strings_internal::STLStringReserveAmortized()
PiperOrigin-RevId: 850064010
Change-Id: Ieb280f2ba70726bbd4f27d2aed1f0ff4e5a683d1
2025-12-29 08:15:26 -08:00
Derek Mauro
a529ebc843 As IsAtLeastInputIterator helper
PiperOrigin-RevId: 850059542
Change-Id: I35bcd2cb43d3ce33fd316e89ac93e7574a7e151c
2025-12-29 08:01:20 -08:00
Derek Mauro
87c547923d Use StringAppendAndOverwrite() in CEscapeAndAppendInternal()
PiperOrigin-RevId: 850046633
Change-Id: I5ed7d3031c8e60ddac80df9d0bea073f07017236
2025-12-29 07:04:27 -08:00
Abseil Team
24a5eb08e7 Add support for absl::(u)int128 in FastIntToBuffer()
PiperOrigin-RevId: 849837011
Change-Id: I3b742863d328f01a2461f2b876b2aaf04ce9cd5f
2025-12-28 15:54:26 -08:00
Chris Kennelly
5d365d332a absl/strings: Prepare helper for printing objects to string representations.
PiperOrigin-RevId: 847935770
Change-Id: I7f96940e5ba11d6a602d34e7dc3dbfde112bb142
2025-12-22 17:29:23 -08:00
Derek Mauro
1037021200 Use SimpleAtob() for parsing bool flags
This is equivalent to the current logic.

PiperOrigin-RevId: 847847676
Change-Id: Ibd99b2db34fec7cd23247f6de2b22e8ea4b89a15
2025-12-22 12:24:30 -08:00
Derek Mauro
de9ab52205 No-op changes to relative timeout support code.
PiperOrigin-RevId: 847827629
Change-Id: I84dec0fafa6cdbb8ffee013f9d5ad9b3cb977ee4
2025-12-22 11:19:58 -08:00
Derek Mauro
a8960c053b Adjust visibility of heterogeneous_lookup_testing.h
PiperOrigin-RevId: 846842509
Change-Id: I91a82eb9bafd01b3341efcd9aef3b699dc8fe10a
2025-12-19 13:13:54 -08:00
Derek Mauro
746ae76d0a Remove -DUNORDERED_SET_CXX17 since the macro no longer exists
PiperOrigin-RevId: 846785448
Change-Id: Ic21788f29f6c42382d49a64246eebf92964af6e4
2025-12-19 10:31:28 -08:00
Chris Kennelly
6c846a3540 [log] Prepare helper for streaming container contents to strings.
PiperOrigin-RevId: 846769302
Change-Id: Ice80fd61edaf7fa4b97286444251abccb204679f
2025-12-19 09:43:56 -08:00
Derek Mauro
885e4ff0df Restrict the visibility of some internal testing utilities
PiperOrigin-RevId: 846705319
Change-Id: I27c925ead3415b11f5eee5f8657d234d464225b5
2025-12-19 06:16:20 -08:00
Derek Mauro
630e92d5d5 Add absl::linked_hash_set and absl::linked_hash_map
These are hash containers ordered by insertion.

PiperOrigin-RevId: 846682470
Change-Id: I1c7fc54197d074666754f94b477782400197a14e
2025-12-19 04:50:33 -08:00
Chris Kennelly
ab8fec82ff [meta] Add constexpr testing helper.
PiperOrigin-RevId: 846383067
Change-Id: Ia8dbbb805f59eb4cb5334290c3e24e0117777ca2
2025-12-18 12:58:18 -08:00
Chris Kennelly
641721e94f BUILD file reformatting.
PiperOrigin-RevId: 846286050
Change-Id: Ib2b6bd5c1f69146cdccc8d14b661abb6e1a17498
2025-12-18 08:44:04 -08:00
Chris Kennelly
03ea849fa2 absl/meta: Add C++17 port of C++20 requires expression for internal use
PiperOrigin-RevId: 846259270
Change-Id: I0126a78949b15fbbafca7c8dba3e3b60df30914b
2025-12-18 07:29:32 -08:00
Derek Mauro
9ebd93a774 Remove the implementation of absl::string_view, which was only needed
prior to C++17. `absl::string_view` is now an alias for `std::string_view`.
It is recommended that clients simply use `std::string_view`.

PiperOrigin-RevId: 845822478
Change-Id: I220530c84118e5b9ef110baa002c232ac8f2c5f2
2025-12-17 10:23:48 -08:00
Abseil Team
d2dd9b9ee9 No public description
PiperOrigin-RevId: 845418157
Change-Id: Iddb10304eaff9c507920eda04f2244e67fdc45cb
2025-12-16 13:45:18 -08:00
Abseil Team
17947175b5 absl:🎏 Stop echoing file content in flagfile parsing errors
Modified ArgsList::ReadFromFlagfile to redact the content of unexpected lines from error messages. \

PiperOrigin-RevId: 845327732
Change-Id: I6e0bf8f443b534cc9fa14e214e0d275e30116261
2025-12-16 10:12:02 -08:00
Samuel Benzaquen
4ab5394975 Refactor the declaration of raw_hash_set/btree to omit default template parameters from the subclasses.
This reduces binary bloat by making mangled names smaller and by reducing strings like `__PRETTY_FUNCTION__.`
The default types can be inferred and do not provide extra information.

PiperOrigin-RevId: 844837029
Change-Id: I67f3c9445bd018ea829fa584784095e2e84cb739
2025-12-15 10:50:08 -08:00
Abseil Team
fa7bc39e59 Import of CCTZ from GitHub.
PiperOrigin-RevId: 843741408
Change-Id: If33ececb0a498c35d4bbdde7f4f0bfb918c8a75d
2025-12-12 10:20:41 -08:00
Abseil Team
b9a26fe1bc Add ABSL_ATTRIBUTE_LIFETIME_BOUND to Flag help generator
Since this method is only called by `NonConst` which immediately converts it to a `std::string`, this is currently safe. Add annotation nevertheless to show the contract.

This currently makes the majority of lifetime annotation suggestion provided by the lifetime analysis https://godbolt.org/z/hKvrE1hG1

PiperOrigin-RevId: 843275432
Change-Id: Ib1a0513eca944a9c7c4c612c3111bf05881c746d
2025-12-11 10:19:38 -08:00
Vitaly Goldshteyn
ba9fa8c3ab Correct Mix4x16Vectors comment.
PiperOrigin-RevId: 842844890
Change-Id: Id4c765f79520ccc8aea8d33bee5ad53983e4aa53
2025-12-10 13:01:32 -08:00
Vitaly Goldshteyn
4bd9ee20a2 Special implementation for string hash with sizes greater than 64.
AES instructions are used, when available. We load blocks of 64 bytes of the string into 4 independently hashed 128-bit vectors. We use AES encrypt and decrypt to mix the bits. Instructions are running in parallel.

Last <=64 bytes are loaded to 4 (or 2 if rest length is <=32) overlapping vectors and encrypted additionally. At the end we mix by another encryption similar to the case in 33-64.

```
name                                     CYCLES/op     CYCLES/op   vs base
BM_HASHING_Combine_contiguous_Fleet_hot  479.0m ± 1%   437.0m ± 0%   -8.77% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_Fleet_cold 1.700 ± 2%    1.526 ± 2%  -10.24% (p=0.000 n=30)

arcadia-rome:
BM_HASHING_Combine_contiguous_Fleet_hot  465.0m ± 1%   452.0m ± 1%   -2.80% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_Fleet_cold 4.024 ± 1%    3.676 ± 0%   -8.66% (p=0.000 n=30)
```

ASM analysis https://godbolt.org/z/5EzEnT46j shows 8 cycles savings for 128 byte string. We also perform 2x less load operations.

PiperOrigin-RevId: 842818076
Change-Id: Ib89f25e0bae2c8ba9ed340350408c27afe6fd222
2025-12-10 11:54:12 -08:00
Evan Brown
5b1e199db4 Reorder function parameters so that hash state is the first argument.
Motivation: hash state being first allows for fewer unnecessary moves between registers since (a) this matches the argument order in CombineContiguousImpl and (b) hash state is also the return value (on ARM64, the return value and the first argument use the same register) - [example assembly diff](https://godbolt.org/z/c1h5dMe9K) for related change.
PiperOrigin-RevId: 842309048
Change-Id: I5b1f0fb381728ced2b3fba53fb9adbc0e4a45189
2025-12-09 10:55:04 -08:00
Abseil Team
88c48235c8 Search more aggressively for open slots in absl::internal_stacktrace::BorrowedFixupBuffer
This lets us avoid heap allocations in more situations than before.

PiperOrigin-RevId: 841851984
Change-Id: Ibd16b0b87c250c504c8d1119d9b9eb4031067c28
2025-12-08 11:39:05 -08:00
Chris Kennelly
f17f9070d2 Implement SpinLockHolder in terms of std::lock_guard.
PiperOrigin-RevId: 841813256
Change-Id: Id8a446f889d999720c9d9db527a9f6dfb8b2d6a9
2025-12-08 10:10:27 -08:00
Abseil Team
5614692612 No public description
PiperOrigin-RevId: 840547347
Change-Id: I7507eaeeaf2ad5f1e3da6abc499a8b30b8901222
2025-12-04 21:56:22 -08:00
Chris Kennelly
6baba4dc59 Avoid discarding test matchers.
PiperOrigin-RevId: 838904511
Change-Id: I02f3bf3f2c51e4cdb21aa638a4f265f2ef4e2f25
2025-12-01 13:17:26 -08:00
Abseil Team
b6536933be Import of CCTZ from GitHub.
PiperOrigin-RevId: 838869622
Change-Id: I92047cd4e3ca51afded452316332bded5dc79a3f
2025-12-01 11:46:56 -08:00
Abseil Team
0cc960ece0 Automated rollback of commit 9f40d6d6f3.
PiperOrigin-RevId: 838084272
Change-Id: I8b1b15618e12cc17d85a71b7f5062b66ceaaf04f
2025-11-29 05:02:02 -08:00
Abseil Team
9f40d6d6f3 Enable clang-specific warnings on the clang-cl build
instead of just trying to be MSVC

This also fixes the new warnings that are caught.
These include:
  * Unreachable code after GTEST_SKIP (this is kind of ugly)
  * Some -Wundef warnings
  * A -Wshadow warning in vlog_config.cc

PiperOrigin-RevId: 838046186
Change-Id: Ief48d6db2b8755d2173997d052560880593d5819
2025-11-29 01:22:25 -08:00
Derek Mauro
b20370e0d6 Enable clang-specific warnings on the clang-cl build
instead of just trying to be MSVC

This also fixes the new warnings that are caught.
These include:
  * Unreachable code after GTEST_SKIP (this is kind of ugly)
  * Some -Wundef warnings
  * A -Wshadow warning in vlog_config.cc

PiperOrigin-RevId: 838017208
Change-Id: I39373c0ccc57c8660c22815c51ac5b4180aec53c
2025-11-28 22:41:40 -08:00
Abseil Team
e32d1eb466 Make AnyInvocable remember more information
Add an extra variant to FunctionToCall: `relocate_from_to_and_query_rust`. It is identical to "relocate_from_to" for C++ managers, but instructs Rust managers to perform a special operation that can be detected by the caller.

PiperOrigin-RevId: 837257408
Change-Id: Idc270af2716252612a77a26b1b3cf83778aaa20d
2025-11-26 14:26:31 -08:00
Derek Mauro
18bd00ad42 Add further diagnostics under clang for string_view(nullptr)
Detection isn't perfect, but it is better than nothing:
https://godbolt.org/z/YzeMeb58j

PiperOrigin-RevId: 837204651
Change-Id: Id1027c4c27bd95ad923e4c5d242a28079b16db79
2025-11-26 11:46:47 -08:00
Abseil Team
9d35bf52e7 Import of CCTZ from GitHub.
PiperOrigin-RevId: 837071460
Change-Id: I3eb138b10ef122c1fb6c7e02701ed6c7d1deb34f
2025-11-26 05:03:59 -08:00
Derek Mauro
b9baf19a19 Document the differing trimming behavior of absl::Span::subspan() and std::span::subspan()
`std::span::subspan()` has stricter preconditions than its `absl::`
counterpart. Supplying a `len` that would extend beyond the end of the
span is undefined behavior for `std::span` (unless `len` is the default
`npos` value), whereas `absl::span` simply truncates the result.

PiperOrigin-RevId: 836331418
Change-Id: I0e9a11cb434deca0b88d761e8233a44d5a9273ce
2025-11-24 12:50:53 -08:00
Vitaly Goldshteyn
f33b7c07d7 Special implementation for string hash with sizes in range [33, 64].
AES instructions are used, when available. We load 33 - 64 bytes of the string into 4 128-bit overlapping vectors and use two rounds of AES encrypt and decrypt to mix the bits.

```
name                                    INSTRUCTIONS/op  INSTRUCTIONS/op  vs base
BM_HASHING_Combine_contiguous_Fleet_hot  2.047 ± 0%        1.927 ± 0%  -5.86% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_Fleet_cold 2.229 ± 0%        2.109 ± 0%  -5.38% (p=0.000 n=30)

name                                     CYCLES/op    CYCLES/op   vs base
BM_HASHING_Combine_contiguous_Fleet_hot   520.0m ± 0%   501.0m ± 1%  -3.65% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_Fleet_cold  1.754 ± 1%    1.696 ± 2%   -3.33% (p=0.003 n=30)
BM_HASHING_Combine_contiguous_0_hot       557.5m ± 0%   542.5m ± 0%  -2.69% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_0_cold      1.769 ± 2%    1.742 ± 2%       ~ (p=0.117 n=30)
BM_HASHING_Combine_contiguous_1_hot       389.0m ± 0%   371.0m ± 1%  -4.63% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_1_cold      1.450 ± 1%    1.389 ± 2%   -4.24% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_2_hot       555.0m ± 0%   547.0m ± 0%  -1.44% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_2_cold      1.526 ± 2%    1.504 ± 2%   -1.41% (p=0.024 n=30)
BM_HASHING_Combine_contiguous_3_hot       507.0m ± 0%   470.5m ± 1%  -7.20% (p=0.000 n=30)
BM_HASHING_Combine_contiguous_3_cold      1.187 ± 1%    1.139 ± 1%   -4.05% (p=0.000 n=30)
geomean                                   873.5m        843.5m       -3.43%
```

PiperOrigin-RevId: 836234239
Change-Id: I4a2344d77becefd3d5e788790f913fbe3611e8b0
2025-11-24 08:23:42 -08:00
Derek Mauro
69e7e0a383 Add the deleted string_view(std::nullptr_t) constructor from C++23
This will reject string_view(nullptr) at compile-time.

PiperOrigin-RevId: 835352115
Change-Id: Ic68e55d3eba02e002ed5f1791c40efbb0f0daaf0
2025-11-21 14:07:24 -08:00