Просмотр исходного кода

Restoring authorship annotation for <ayles@yandex-team.ru>. Commit 1 of 2.

ayles 3 лет назад
Родитель
Сommit
d55028e9d9

+ 3 - 3
build/ymake.core.conf

@@ -1433,9 +1433,9 @@ when ($COMMON_LINK_SETTINGS == "yes") {
                 PEERDIR+=library/cpp/malloc/hu
             }
             "TCMALLOC_256K" ? {
-                PEERDIR+=library/cpp/malloc/tcmalloc
+                PEERDIR+=library/cpp/malloc/tcmalloc 
                 PEERDIR+=contrib/libs/tcmalloc
-            }
+            } 
             "TCMALLOC_SMALL_BUT_SLOW" ? {
                 PEERDIR+=library/cpp/malloc/tcmalloc
                 PEERDIR+=contrib/libs/tcmalloc/small_but_slow
@@ -5270,7 +5270,7 @@ macro ADD_PERL_MODULE(Dir, Module) {
 ###   - BM - The balloc for market (agri@ commits from july 2018 till November 2018 saved)
 ###   - C - Like B, but can be disabled for each thread to LF or SYSTEM one (B can be disabled only to SYSTEM)
 ###   - MIM -  Microsoft's mimalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/mimalloc)
-###   - TCMALLOC -  Google TCMalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/tcmalloc)
+###   - TCMALLOC -  Google TCMalloc (actual version) (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/tcmalloc) 
 ###   - GOOGLE -  Google TCMalloc (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/galloc)
 ###   - LOCKLESS - Allocator based upon lockless queues (https://a.yandex-team.ru/arc/trunk/arcadia/library/malloc/lockless)
 ###   - SYSTEM - Use target system allocator

+ 74 - 74
contrib/libs/tcmalloc/CONTRIBUTING.md

@@ -1,74 +1,74 @@
-# How to Contribute to TCMalloc
-
-We'd love to accept your patches and contributions to this project. There are
-just a few small guidelines you need to follow.
-
-NOTE: If you are new to GitHub, please start by reading [Pull Request
-howto](https://help.github.com/articles/about-pull-requests/)
-
-## Contributor License Agreement
-
-Contributions to this project must be accompanied by a Contributor License
-Agreement. You (or your employer) retain the copyright to your contribution;
-this simply gives us permission to use and redistribute your contributions as
-part of the project. Head over to <https://cla.developers.google.com/> to see
-your current agreements on file or to sign a new one.
-
-You generally only need to submit a CLA once, so if you've already submitted one
-(even if it was for a different project), you probably don't need to do it
-again.
-
-## Guidelines for Pull Requests
-
-*  All submissions, including submissions by project members, require review.
-   We use GitHub pull requests for this purpose. Consult
-   [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
-   information on using pull requests.
-
-*  If you are a Googler, it is preferable to first create an internal CL and
-   have it reviewed and submitted. The code propagation process will deliver
-   the change to GitHub.
-
-*  Create **small PRs** that are narrowly focused on **addressing a single concern**.
-   When PRs try to fix several things at a time, if only one fix is considered
-   acceptable, nothing gets merged and both author's & review's time is wasted.
-   Create more PRs to address different concerns and everyone will be happy.
-
-*  Provide a good **PR description** as a record of **what** change is being
-   made and **why** it was made. Link to a GitHub issue if it exists.
-
-*  Don't fix code style and formatting unless you are already changing that line
-   to address an issue. Formatting of modified lines may be done using
-   `git clang-format`. PRs with irrelevant changes won't be merged. If you do
-   want to fix formatting or style, do that in a separate PR.
-
-*  Unless your PR is trivial, you should expect there will be reviewer comments
-   that you'll need to address before merging. We expect you to be reasonably
-   responsive to those comments, otherwise the PR will be closed after 2-3 weeks
-   of inactivity.
-
-*  Maintain **clean commit history** and use **meaningful commit messages**.
-   PRs with messy commit history are difficult to review and won't be merged.
-   Use `rebase -i upstream/master` to curate your commit history and/or to
-   bring in latest changes from master (but avoid rebasing in the middle of a
-   code review).
-
-*  Keep your PR up to date with upstream/master (if there are merge conflicts,
-   we can't really merge your change).
-
-*  **All tests need to be passing** before your change can be merged. We
-   recommend you **run tests locally** (see below)
-
-*  Exceptions to the rules can be made if there's a compelling reason for doing
-   so. That is - the rules are here to serve us, not the other way around, and
-   the rules need to be serving their intended purpose to be valuable.
-
-## TCMalloc Committers
-
-The current members of the TCMalloc engineering team are the only committers at
-present.
-
-## Community Guidelines
-
-This project follows
-[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
+# How to Contribute to TCMalloc 
+ 
+We'd love to accept your patches and contributions to this project. There are 
+just a few small guidelines you need to follow. 
+ 
+NOTE: If you are new to GitHub, please start by reading [Pull Request 
+howto](https://help.github.com/articles/about-pull-requests/) 
+ 
+## Contributor License Agreement 
+ 
+Contributions to this project must be accompanied by a Contributor License 
+Agreement. You (or your employer) retain the copyright to your contribution; 
+this simply gives us permission to use and redistribute your contributions as 
+part of the project. Head over to <https://cla.developers.google.com/> to see 
+your current agreements on file or to sign a new one. 
+ 
+You generally only need to submit a CLA once, so if you've already submitted one 
+(even if it was for a different project), you probably don't need to do it 
+again. 
+ 
+## Guidelines for Pull Requests 
+ 
+*  All submissions, including submissions by project members, require review. 
+   We use GitHub pull requests for this purpose. Consult 
+   [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 
+   information on using pull requests. 
+ 
+*  If you are a Googler, it is preferable to first create an internal CL and 
+   have it reviewed and submitted. The code propagation process will deliver 
+   the change to GitHub. 
+ 
+*  Create **small PRs** that are narrowly focused on **addressing a single concern**. 
+   When PRs try to fix several things at a time, if only one fix is considered 
+   acceptable, nothing gets merged and both author's & review's time is wasted. 
+   Create more PRs to address different concerns and everyone will be happy. 
+ 
+*  Provide a good **PR description** as a record of **what** change is being 
+   made and **why** it was made. Link to a GitHub issue if it exists. 
+ 
+*  Don't fix code style and formatting unless you are already changing that line 
+   to address an issue. Formatting of modified lines may be done using 
+   `git clang-format`. PRs with irrelevant changes won't be merged. If you do 
+   want to fix formatting or style, do that in a separate PR. 
+ 
+*  Unless your PR is trivial, you should expect there will be reviewer comments 
+   that you'll need to address before merging. We expect you to be reasonably 
+   responsive to those comments, otherwise the PR will be closed after 2-3 weeks 
+   of inactivity. 
+ 
+*  Maintain **clean commit history** and use **meaningful commit messages**. 
+   PRs with messy commit history are difficult to review and won't be merged. 
+   Use `rebase -i upstream/master` to curate your commit history and/or to 
+   bring in latest changes from master (but avoid rebasing in the middle of a 
+   code review). 
+ 
+*  Keep your PR up to date with upstream/master (if there are merge conflicts, 
+   we can't really merge your change). 
+ 
+*  **All tests need to be passing** before your change can be merged. We 
+   recommend you **run tests locally** (see below) 
+ 
+*  Exceptions to the rules can be made if there's a compelling reason for doing 
+   so. That is - the rules are here to serve us, not the other way around, and 
+   the rules need to be serving their intended purpose to be valuable. 
+ 
+## TCMalloc Committers 
+ 
+The current members of the TCMalloc engineering team are the only committers at 
+present. 
+ 
+## Community Guidelines 
+ 
+This project follows 
+[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/). 

+ 202 - 202
contrib/libs/tcmalloc/LICENSE

@@ -1,202 +1,202 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        https://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       https://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
+ 
+                                 Apache License 
+                           Version 2.0, January 2004 
+                        https://www.apache.org/licenses/ 
+ 
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 
+ 
+   1. Definitions. 
+ 
+      "License" shall mean the terms and conditions for use, reproduction, 
+      and distribution as defined by Sections 1 through 9 of this document. 
+ 
+      "Licensor" shall mean the copyright owner or entity authorized by 
+      the copyright owner that is granting the License. 
+ 
+      "Legal Entity" shall mean the union of the acting entity and all 
+      other entities that control, are controlled by, or are under common 
+      control with that entity. For the purposes of this definition, 
+      "control" means (i) the power, direct or indirect, to cause the 
+      direction or management of such entity, whether by contract or 
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the 
+      outstanding shares, or (iii) beneficial ownership of such entity. 
+ 
+      "You" (or "Your") shall mean an individual or Legal Entity 
+      exercising permissions granted by this License. 
+ 
+      "Source" form shall mean the preferred form for making modifications, 
+      including but not limited to software source code, documentation 
+      source, and configuration files. 
+ 
+      "Object" form shall mean any form resulting from mechanical 
+      transformation or translation of a Source form, including but 
+      not limited to compiled object code, generated documentation, 
+      and conversions to other media types. 
+ 
+      "Work" shall mean the work of authorship, whether in Source or 
+      Object form, made available under the License, as indicated by a 
+      copyright notice that is included in or attached to the work 
+      (an example is provided in the Appendix below). 
+ 
+      "Derivative Works" shall mean any work, whether in Source or Object 
+      form, that is based on (or derived from) the Work and for which the 
+      editorial revisions, annotations, elaborations, or other modifications 
+      represent, as a whole, an original work of authorship. For the purposes 
+      of this License, Derivative Works shall not include works that remain 
+      separable from, or merely link (or bind by name) to the interfaces of, 
+      the Work and Derivative Works thereof. 
+ 
+      "Contribution" shall mean any work of authorship, including 
+      the original version of the Work and any modifications or additions 
+      to that Work or Derivative Works thereof, that is intentionally 
+      submitted to Licensor for inclusion in the Work by the copyright owner 
+      or by an individual or Legal Entity authorized to submit on behalf of 
+      the copyright owner. For the purposes of this definition, "submitted" 
+      means any form of electronic, verbal, or written communication sent 
+      to the Licensor or its representatives, including but not limited to 
+      communication on electronic mailing lists, source code control systems, 
+      and issue tracking systems that are managed by, or on behalf of, the 
+      Licensor for the purpose of discussing and improving the Work, but 
+      excluding communication that is conspicuously marked or otherwise 
+      designated in writing by the copyright owner as "Not a Contribution." 
+ 
+      "Contributor" shall mean Licensor and any individual or Legal Entity 
+      on behalf of whom a Contribution has been received by Licensor and 
+      subsequently incorporated within the Work. 
+ 
+   2. Grant of Copyright License. Subject to the terms and conditions of 
+      this License, each Contributor hereby grants to You a perpetual, 
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable 
+      copyright license to reproduce, prepare Derivative Works of, 
+      publicly display, publicly perform, sublicense, and distribute the 
+      Work and such Derivative Works in Source or Object form. 
+ 
+   3. Grant of Patent License. Subject to the terms and conditions of 
+      this License, each Contributor hereby grants to You a perpetual, 
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable 
+      (except as stated in this section) patent license to make, have made, 
+      use, offer to sell, sell, import, and otherwise transfer the Work, 
+      where such license applies only to those patent claims licensable 
+      by such Contributor that are necessarily infringed by their 
+      Contribution(s) alone or by combination of their Contribution(s) 
+      with the Work to which such Contribution(s) was submitted. If You 
+      institute patent litigation against any entity (including a 
+      cross-claim or counterclaim in a lawsuit) alleging that the Work 
+      or a Contribution incorporated within the Work constitutes direct 
+      or contributory patent infringement, then any patent licenses 
+      granted to You under this License for that Work shall terminate 
+      as of the date such litigation is filed. 
+ 
+   4. Redistribution. You may reproduce and distribute copies of the 
+      Work or Derivative Works thereof in any medium, with or without 
+      modifications, and in Source or Object form, provided that You 
+      meet the following conditions: 
+ 
+      (a) You must give any other recipients of the Work or 
+          Derivative Works a copy of this License; and 
+ 
+      (b) You must cause any modified files to carry prominent notices 
+          stating that You changed the files; and 
+ 
+      (c) You must retain, in the Source form of any Derivative Works 
+          that You distribute, all copyright, patent, trademark, and 
+          attribution notices from the Source form of the Work, 
+          excluding those notices that do not pertain to any part of 
+          the Derivative Works; and 
+ 
+      (d) If the Work includes a "NOTICE" text file as part of its 
+          distribution, then any Derivative Works that You distribute must 
+          include a readable copy of the attribution notices contained 
+          within such NOTICE file, excluding those notices that do not 
+          pertain to any part of the Derivative Works, in at least one 
+          of the following places: within a NOTICE text file distributed 
+          as part of the Derivative Works; within the Source form or 
+          documentation, if provided along with the Derivative Works; or, 
+          within a display generated by the Derivative Works, if and 
+          wherever such third-party notices normally appear. The contents 
+          of the NOTICE file are for informational purposes only and 
+          do not modify the License. You may add Your own attribution 
+          notices within Derivative Works that You distribute, alongside 
+          or as an addendum to the NOTICE text from the Work, provided 
+          that such additional attribution notices cannot be construed 
+          as modifying the License. 
+ 
+      You may add Your own copyright statement to Your modifications and 
+      may provide additional or different license terms and conditions 
+      for use, reproduction, or distribution of Your modifications, or 
+      for any such Derivative Works as a whole, provided Your use, 
+      reproduction, and distribution of the Work otherwise complies with 
+      the conditions stated in this License. 
+ 
+   5. Submission of Contributions. Unless You explicitly state otherwise, 
+      any Contribution intentionally submitted for inclusion in the Work 
+      by You to the Licensor shall be under the terms and conditions of 
+      this License, without any additional terms or conditions. 
+      Notwithstanding the above, nothing herein shall supersede or modify 
+      the terms of any separate license agreement you may have executed 
+      with Licensor regarding such Contributions. 
+ 
+   6. Trademarks. This License does not grant permission to use the trade 
+      names, trademarks, service marks, or product names of the Licensor, 
+      except as required for reasonable and customary use in describing the 
+      origin of the Work and reproducing the content of the NOTICE file. 
+ 
+   7. Disclaimer of Warranty. Unless required by applicable law or 
+      agreed to in writing, Licensor provides the Work (and each 
+      Contributor provides its Contributions) on an "AS IS" BASIS, 
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
+      implied, including, without limitation, any warranties or conditions 
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 
+      PARTICULAR PURPOSE. You are solely responsible for determining the 
+      appropriateness of using or redistributing the Work and assume any 
+      risks associated with Your exercise of permissions under this License. 
+ 
+   8. Limitation of Liability. In no event and under no legal theory, 
+      whether in tort (including negligence), contract, or otherwise, 
+      unless required by applicable law (such as deliberate and grossly 
+      negligent acts) or agreed to in writing, shall any Contributor be 
+      liable to You for damages, including any direct, indirect, special, 
+      incidental, or consequential damages of any character arising as a 
+      result of this License or out of the use or inability to use the 
+      Work (including but not limited to damages for loss of goodwill, 
+      work stoppage, computer failure or malfunction, or any and all 
+      other commercial damages or losses), even if such Contributor 
+      has been advised of the possibility of such damages. 
+ 
+   9. Accepting Warranty or Additional Liability. While redistributing 
+      the Work or Derivative Works thereof, You may choose to offer, 
+      and charge a fee for, acceptance of support, warranty, indemnity, 
+      or other liability obligations and/or rights consistent with this 
+      License. However, in accepting such obligations, You may act only 
+      on Your own behalf and on Your sole responsibility, not on behalf 
+      of any other Contributor, and only if You agree to indemnify, 
+      defend, and hold each Contributor harmless for any liability 
+      incurred by, or claims asserted against, such Contributor by reason 
+      of your accepting any such warranty or additional liability. 
+ 
+   END OF TERMS AND CONDITIONS 
+ 
+   APPENDIX: How to apply the Apache License to your work. 
+ 
+      To apply the Apache License to your work, attach the following 
+      boilerplate notice, with the fields enclosed by brackets "[]" 
+      replaced with your own identifying information. (Don't include 
+      the brackets!)  The text should be enclosed in the appropriate 
+      comment syntax for the file format. We also recommend that a 
+      file or class name and description of purpose be included on the 
+      same "printed page" as the copyright notice for easier 
+      identification within third-party archives. 
+ 
+   Copyright [yyyy] [name of copyright owner] 
+ 
+   Licensed under the Apache License, Version 2.0 (the "License"); 
+   you may not use this file except in compliance with the License. 
+   You may obtain a copy of the License at 
+ 
+       https://www.apache.org/licenses/LICENSE-2.0 
+ 
+   Unless required by applicable law or agreed to in writing, software 
+   distributed under the License is distributed on an "AS IS" BASIS, 
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+   See the License for the specific language governing permissions and 
+   limitations under the License. 

+ 44 - 44
contrib/libs/tcmalloc/README.md

@@ -1,44 +1,44 @@
-# TCMalloc
-
-This repository contains the TCMalloc C++ code.
-
-TCMalloc is Google's customized implementation of C's `malloc()` and C++'s
-`operator new` used for memory allocation within our C and C++ code. TCMalloc is
-a fast, multi-threaded malloc implementation.
-
-## Building TCMalloc
-
-[Bazel](https://bazel.build) is the official build system for TCMalloc.
-
-The [TCMalloc Platforms Guide](docs/platforms.md) contains information on
-platform support for TCMalloc.
-
-## Documentation
-
-All users of TCMalloc should consult the following documentation resources:
-
-* The [TCMalloc Quickstart](docs/quickstart.md) covers downloading, installing,
-  building, and testing TCMalloc, including incorporating within your codebase.
-* The [TCMalloc Overview](docs/overview.md) covers the basic architecture of
-  TCMalloc, and how that may affect configuration choices.
-* The [TCMalloc Reference](docs/reference.md) covers the C and C++ TCMalloc API
-  endpoints.
-
-More advanced usages of TCMalloc may find the following documentation useful:
-
-* The [TCMalloc Tuning Guide](docs/tuning.md) covers the configuration choices
-  in more depth, and also illustrates other ways to customize TCMalloc.  This
-  also covers important operating system-level properties for improving TCMalloc
-  performance.
-* The [TCMalloc Design Doc](docs/design.md) covers how TCMalloc works
-  underneath the hood, and why certain design choices were made. Most developers
-  will not need this level of implementation detail.
-* The [TCMalloc Compatibility Guide](docs/compatibility.md) which documents our
-  expectations for how our APIs are used.
-
-## License
-
-The TCMalloc library is licensed under the terms of the Apache
-license. See LICENSE for more information.
-
-Disclaimer: This is not an officially supported Google product.
+# TCMalloc 
+ 
+This repository contains the TCMalloc C++ code. 
+ 
+TCMalloc is Google's customized implementation of C's `malloc()` and C++'s 
+`operator new` used for memory allocation within our C and C++ code. TCMalloc is 
+a fast, multi-threaded malloc implementation. 
+ 
+## Building TCMalloc 
+ 
+[Bazel](https://bazel.build) is the official build system for TCMalloc. 
+ 
+The [TCMalloc Platforms Guide](docs/platforms.md) contains information on 
+platform support for TCMalloc. 
+ 
+## Documentation 
+ 
+All users of TCMalloc should consult the following documentation resources: 
+ 
+* The [TCMalloc Quickstart](docs/quickstart.md) covers downloading, installing, 
+  building, and testing TCMalloc, including incorporating within your codebase. 
+* The [TCMalloc Overview](docs/overview.md) covers the basic architecture of 
+  TCMalloc, and how that may affect configuration choices. 
+* The [TCMalloc Reference](docs/reference.md) covers the C and C++ TCMalloc API 
+  endpoints. 
+ 
+More advanced usages of TCMalloc may find the following documentation useful: 
+ 
+* The [TCMalloc Tuning Guide](docs/tuning.md) covers the configuration choices 
+  in more depth, and also illustrates other ways to customize TCMalloc.  This 
+  also covers important operating system-level properties for improving TCMalloc 
+  performance. 
+* The [TCMalloc Design Doc](docs/design.md) covers how TCMalloc works 
+  underneath the hood, and why certain design choices were made. Most developers 
+  will not need this level of implementation detail. 
+* The [TCMalloc Compatibility Guide](docs/compatibility.md) which documents our 
+  expectations for how our APIs are used. 
+ 
+## License 
+ 
+The TCMalloc library is licensed under the terms of the Apache 
+license. See LICENSE for more information. 
+ 
+Disclaimer: This is not an officially supported Google product. 

+ 45 - 45
contrib/libs/tcmalloc/tcmalloc/arena.cc

@@ -1,27 +1,27 @@
-// Copyright 2019 The TCMalloc Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "tcmalloc/arena.h"
-
-#include "tcmalloc/internal/logging.h"
+// Copyright 2019 The TCMalloc Authors 
+// 
+// Licensed under the Apache License, Version 2.0 (the "License"); 
+// you may not use this file except in compliance with the License. 
+// You may obtain a copy of the License at 
+// 
+//     https://www.apache.org/licenses/LICENSE-2.0 
+// 
+// Unless required by applicable law or agreed to in writing, software 
+// distributed under the License is distributed on an "AS IS" BASIS, 
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+// See the License for the specific language governing permissions and 
+// limitations under the License. 
+ 
+#include "tcmalloc/arena.h" 
+ 
+#include "tcmalloc/internal/logging.h" 
 #include "tcmalloc/static_vars.h"
-#include "tcmalloc/system-alloc.h"
-
+#include "tcmalloc/system-alloc.h" 
+ 
 GOOGLE_MALLOC_SECTION_BEGIN
-namespace tcmalloc {
+namespace tcmalloc { 
 namespace tcmalloc_internal {
-
+ 
 void* Arena::Alloc(size_t bytes, int alignment) {
   ASSERT(alignment > 0);
   {  // First we need to move up to the correct alignment.
@@ -33,13 +33,13 @@ void* Arena::Alloc(size_t bytes, int alignment) {
     free_avail_ -= alignment_bytes;
     bytes_allocated_ += alignment_bytes;
   }
-  char* result;
-  if (free_avail_ < bytes) {
-    size_t ask = bytes > kAllocIncrement ? bytes : kAllocIncrement;
-    size_t actual_size;
-    // TODO(b/171081864): Arena allocations should be made relatively
-    // infrequently.  Consider tagging this memory with sampled objects which
-    // are also infrequently allocated.
+  char* result; 
+  if (free_avail_ < bytes) { 
+    size_t ask = bytes > kAllocIncrement ? bytes : kAllocIncrement; 
+    size_t actual_size; 
+    // TODO(b/171081864): Arena allocations should be made relatively 
+    // infrequently.  Consider tagging this memory with sampled objects which 
+    // are also infrequently allocated. 
     //
     // In the meantime it is important that we use the current NUMA partition
     // rather than always using a particular one because it's possible that any
@@ -54,25 +54,25 @@ void* Arena::Alloc(size_t bytes, int alignment) {
     }
     free_area_ =
         reinterpret_cast<char*>(SystemAlloc(ask, &actual_size, kPageSize, tag));
-    if (ABSL_PREDICT_FALSE(free_area_ == nullptr)) {
-      Crash(kCrash, __FILE__, __LINE__,
-            "FATAL ERROR: Out of memory trying to allocate internal tcmalloc "
+    if (ABSL_PREDICT_FALSE(free_area_ == nullptr)) { 
+      Crash(kCrash, __FILE__, __LINE__, 
+            "FATAL ERROR: Out of memory trying to allocate internal tcmalloc " 
             "data (bytes, object-size); is something preventing mmap from "
             "succeeding (sandbox, VSS limitations)?",
-            kAllocIncrement, bytes);
-    }
-    SystemBack(free_area_, actual_size);
-    free_avail_ = actual_size;
-  }
-
+            kAllocIncrement, bytes); 
+    } 
+    SystemBack(free_area_, actual_size); 
+    free_avail_ = actual_size; 
+  } 
+ 
   ASSERT(reinterpret_cast<uintptr_t>(free_area_) % alignment == 0);
-  result = free_area_;
-  free_area_ += bytes;
-  free_avail_ -= bytes;
-  bytes_allocated_ += bytes;
-  return reinterpret_cast<void*>(result);
-}
-
+  result = free_area_; 
+  free_area_ += bytes; 
+  free_avail_ -= bytes; 
+  bytes_allocated_ += bytes; 
+  return reinterpret_cast<void*>(result); 
+} 
+ 
 }  // namespace tcmalloc_internal
-}  // namespace tcmalloc
+}  // namespace tcmalloc 
 GOOGLE_MALLOC_SECTION_END

+ 60 - 60
contrib/libs/tcmalloc/tcmalloc/arena.h

@@ -1,68 +1,68 @@
-// Copyright 2019 The TCMalloc Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef TCMALLOC_ARENA_H_
-#define TCMALLOC_ARENA_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
+// Copyright 2019 The TCMalloc Authors 
+// 
+// Licensed under the Apache License, Version 2.0 (the "License"); 
+// you may not use this file except in compliance with the License. 
+// You may obtain a copy of the License at 
+// 
+//     https://www.apache.org/licenses/LICENSE-2.0 
+// 
+// Unless required by applicable law or agreed to in writing, software 
+// distributed under the License is distributed on an "AS IS" BASIS, 
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+// See the License for the specific language governing permissions and 
+// limitations under the License. 
+ 
+#ifndef TCMALLOC_ARENA_H_ 
+#define TCMALLOC_ARENA_H_ 
+ 
+#include <stddef.h> 
+#include <stdint.h> 
+ 
 #include "absl/base/attributes.h"
-#include "absl/base/thread_annotations.h"
-#include "tcmalloc/common.h"
-
+#include "absl/base/thread_annotations.h" 
+#include "tcmalloc/common.h" 
+ 
 GOOGLE_MALLOC_SECTION_BEGIN
-namespace tcmalloc {
+namespace tcmalloc { 
 namespace tcmalloc_internal {
-
-// Arena allocation; designed for use by tcmalloc internal data structures like
-// spans, profiles, etc.  Always expands.
-class Arena {
- public:
-  constexpr Arena()
-      : free_area_(nullptr), free_avail_(0), bytes_allocated_(0) {}
-
-  // Return a properly aligned byte array of length "bytes".  Crashes if
-  // allocation fails.  Requires pageheap_lock is held.
+ 
+// Arena allocation; designed for use by tcmalloc internal data structures like 
+// spans, profiles, etc.  Always expands. 
+class Arena { 
+ public: 
+  constexpr Arena() 
+      : free_area_(nullptr), free_avail_(0), bytes_allocated_(0) {} 
+ 
+  // Return a properly aligned byte array of length "bytes".  Crashes if 
+  // allocation fails.  Requires pageheap_lock is held. 
   ABSL_ATTRIBUTE_RETURNS_NONNULL void* Alloc(size_t bytes,
                                              int alignment = kAlignment)
       ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock);
-
-  // Returns the total number of bytes allocated from this arena.  Requires
-  // pageheap_lock is held.
-  uint64_t bytes_allocated() const
-      ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock) {
-    return bytes_allocated_;
-  }
-
- private:
-  // How much to allocate from system at a time
-  static constexpr int kAllocIncrement = 128 << 10;
-
-  // Free area from which to carve new objects
-  char* free_area_ ABSL_GUARDED_BY(pageheap_lock);
-  size_t free_avail_ ABSL_GUARDED_BY(pageheap_lock);
-
-  // Total number of bytes allocated from this arena
-  uint64_t bytes_allocated_ ABSL_GUARDED_BY(pageheap_lock);
-
-  Arena(const Arena&) = delete;
-  Arena& operator=(const Arena&) = delete;
-};
-
+ 
+  // Returns the total number of bytes allocated from this arena.  Requires 
+  // pageheap_lock is held. 
+  uint64_t bytes_allocated() const 
+      ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock) { 
+    return bytes_allocated_; 
+  } 
+ 
+ private: 
+  // How much to allocate from system at a time 
+  static constexpr int kAllocIncrement = 128 << 10; 
+ 
+  // Free area from which to carve new objects 
+  char* free_area_ ABSL_GUARDED_BY(pageheap_lock); 
+  size_t free_avail_ ABSL_GUARDED_BY(pageheap_lock); 
+ 
+  // Total number of bytes allocated from this arena 
+  uint64_t bytes_allocated_ ABSL_GUARDED_BY(pageheap_lock); 
+ 
+  Arena(const Arena&) = delete; 
+  Arena& operator=(const Arena&) = delete; 
+}; 
+ 
 }  // namespace tcmalloc_internal
-}  // namespace tcmalloc
+}  // namespace tcmalloc 
 GOOGLE_MALLOC_SECTION_END
-
-#endif  // TCMALLOC_ARENA_H_
+ 
+#endif  // TCMALLOC_ARENA_H_ 

+ 106 - 106
contrib/libs/tcmalloc/tcmalloc/background.cc

@@ -1,89 +1,89 @@
-// Copyright 2019 The TCMalloc Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <errno.h>
-
-#include "absl/base/internal/sysinfo.h"
-#include "absl/time/clock.h"
-#include "absl/time/time.h"
+// Copyright 2019 The TCMalloc Authors 
+// 
+// Licensed under the Apache License, Version 2.0 (the "License"); 
+// you may not use this file except in compliance with the License. 
+// You may obtain a copy of the License at 
+// 
+//     https://www.apache.org/licenses/LICENSE-2.0 
+// 
+// Unless required by applicable law or agreed to in writing, software 
+// distributed under the License is distributed on an "AS IS" BASIS, 
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+// See the License for the specific language governing permissions and 
+// limitations under the License. 
+ 
+#include <errno.h> 
+ 
+#include "absl/base/internal/sysinfo.h" 
+#include "absl/time/clock.h" 
+#include "absl/time/time.h" 
 #include "tcmalloc/cpu_cache.h"
-#include "tcmalloc/internal/logging.h"
-#include "tcmalloc/internal/percpu.h"
-#include "tcmalloc/internal_malloc_extension.h"
-#include "tcmalloc/malloc_extension.h"
-#include "tcmalloc/parameters.h"
+#include "tcmalloc/internal/logging.h" 
+#include "tcmalloc/internal/percpu.h" 
+#include "tcmalloc/internal_malloc_extension.h" 
+#include "tcmalloc/malloc_extension.h" 
+#include "tcmalloc/parameters.h" 
 #include "tcmalloc/static_vars.h"
-
+ 
 GOOGLE_MALLOC_SECTION_BEGIN
-namespace tcmalloc {
+namespace tcmalloc { 
 namespace tcmalloc_internal {
-namespace {
-
-// Called by MallocExtension_Internal_ProcessBackgroundActions.
-//
-// We use a simple heuristic here:
-// We keep track of the set of CPUs that we are allowed to run on.  Whenever a
-// CPU is removed from this list, the next call to this routine will detect the
-// disappearance and call ReleaseCpuMemory on it.
-//
-// Note that this heuristic _explicitly_ does not reclaim from isolated cores
-// that this process may have set up specific affinities for -- as this thread
-// will never have been allowed to run there.
-cpu_set_t prev_allowed_cpus;
-void ReleasePerCpuMemoryToOS() {
-  cpu_set_t allowed_cpus;
-
-  // Only attempt reclaim when per-CPU caches are in use.  While
-  // ReleaseCpuMemory() itself is usually a no-op otherwise, we are experiencing
-  // failures in non-permissive sandboxes due to calls made to
-  // sched_getaffinity() below.  It is expected that a runtime environment
-  // supporting per-CPU allocations supports sched_getaffinity().
-  // See b/27247854.
-  if (!MallocExtension::PerCpuCachesActive()) {
-    return;
-  }
-
-  if (subtle::percpu::UsingFlatVirtualCpus()) {
-    // Our (real) CPU mask does not provide useful information about the state
-    // of our virtual CPU set.
-    return;
-  }
-
-  // This can only fail due to a sandbox or similar intercepting the syscall.
-  if (sched_getaffinity(0, sizeof(allowed_cpus), &allowed_cpus)) {
-    // We log periodically as start-up errors are frequently ignored and this is
-    // something we do want clients to fix if they are experiencing it.
-    Log(kLog, __FILE__, __LINE__,
-        "Unexpected sched_getaffinity() failure; errno ", errno);
-    return;
-  }
-
-  // Note:  This is technically not correct in the presence of hotplug (it is
-  // not guaranteed that NumCPUs() is an upper bound on CPU-number).  It is
-  // currently safe for Google systems.
-  const int num_cpus = absl::base_internal::NumCPUs();
-  for (int cpu = 0; cpu < num_cpus; cpu++) {
-    if (CPU_ISSET(cpu, &prev_allowed_cpus) && !CPU_ISSET(cpu, &allowed_cpus)) {
-      // This is a CPU present in the old mask, but not the new.  Reclaim.
-      MallocExtension::ReleaseCpuMemory(cpu);
-    }
-  }
-
-  // Update cached runnable CPUs for next iteration.
-  memcpy(&prev_allowed_cpus, &allowed_cpus, sizeof(cpu_set_t));
-}
-
+namespace { 
+ 
+// Called by MallocExtension_Internal_ProcessBackgroundActions. 
+// 
+// We use a simple heuristic here: 
+// We keep track of the set of CPUs that we are allowed to run on.  Whenever a 
+// CPU is removed from this list, the next call to this routine will detect the 
+// disappearance and call ReleaseCpuMemory on it. 
+// 
+// Note that this heuristic _explicitly_ does not reclaim from isolated cores 
+// that this process may have set up specific affinities for -- as this thread 
+// will never have been allowed to run there. 
+cpu_set_t prev_allowed_cpus; 
+void ReleasePerCpuMemoryToOS() { 
+  cpu_set_t allowed_cpus; 
+ 
+  // Only attempt reclaim when per-CPU caches are in use.  While 
+  // ReleaseCpuMemory() itself is usually a no-op otherwise, we are experiencing 
+  // failures in non-permissive sandboxes due to calls made to 
+  // sched_getaffinity() below.  It is expected that a runtime environment 
+  // supporting per-CPU allocations supports sched_getaffinity(). 
+  // See b/27247854. 
+  if (!MallocExtension::PerCpuCachesActive()) { 
+    return; 
+  } 
+ 
+  if (subtle::percpu::UsingFlatVirtualCpus()) { 
+    // Our (real) CPU mask does not provide useful information about the state 
+    // of our virtual CPU set. 
+    return; 
+  } 
+ 
+  // This can only fail due to a sandbox or similar intercepting the syscall. 
+  if (sched_getaffinity(0, sizeof(allowed_cpus), &allowed_cpus)) { 
+    // We log periodically as start-up errors are frequently ignored and this is 
+    // something we do want clients to fix if they are experiencing it. 
+    Log(kLog, __FILE__, __LINE__, 
+        "Unexpected sched_getaffinity() failure; errno ", errno); 
+    return; 
+  } 
+ 
+  // Note:  This is technically not correct in the presence of hotplug (it is 
+  // not guaranteed that NumCPUs() is an upper bound on CPU-number).  It is 
+  // currently safe for Google systems. 
+  const int num_cpus = absl::base_internal::NumCPUs(); 
+  for (int cpu = 0; cpu < num_cpus; cpu++) { 
+    if (CPU_ISSET(cpu, &prev_allowed_cpus) && !CPU_ISSET(cpu, &allowed_cpus)) { 
+      // This is a CPU present in the old mask, but not the new.  Reclaim. 
+      MallocExtension::ReleaseCpuMemory(cpu); 
+    } 
+  } 
+ 
+  // Update cached runnable CPUs for next iteration. 
+  memcpy(&prev_allowed_cpus, &allowed_cpus, sizeof(cpu_set_t)); 
+} 
+ 
 void ShuffleCpuCaches() {
   if (!MallocExtension::PerCpuCachesActive()) {
     return;
@@ -109,20 +109,20 @@ void ReclaimIdleCpuCaches() {
   Static::cpu_cache().TryReclaimingCaches();
 }
 
-}  // namespace
+}  // namespace 
 }  // namespace tcmalloc_internal
-}  // namespace tcmalloc
+}  // namespace tcmalloc 
 GOOGLE_MALLOC_SECTION_END
-
-// Release memory to the system at a constant rate.
-void MallocExtension_Internal_ProcessBackgroundActions() {
-  tcmalloc::MallocExtension::MarkThreadIdle();
-
-  // Initialize storage for ReleasePerCpuMemoryToOS().
+ 
+// Release memory to the system at a constant rate. 
+void MallocExtension_Internal_ProcessBackgroundActions() { 
+  tcmalloc::MallocExtension::MarkThreadIdle(); 
+ 
+  // Initialize storage for ReleasePerCpuMemoryToOS(). 
   CPU_ZERO(&tcmalloc::tcmalloc_internal::prev_allowed_cpus);
-
-  absl::Time prev_time = absl::Now();
-  constexpr absl::Duration kSleepTime = absl::Seconds(1);
+ 
+  absl::Time prev_time = absl::Now(); 
+  constexpr absl::Duration kSleepTime = absl::Seconds(1); 
 
   // Reclaim inactive per-cpu caches once per kCpuCacheReclaimPeriod.
   //
@@ -138,19 +138,19 @@ void MallocExtension_Internal_ProcessBackgroundActions() {
   constexpr absl::Duration kCpuCacheShufflePeriod = absl::Seconds(5);
   absl::Time last_shuffle = absl::Now();
 
-  while (true) {
-    absl::Time now = absl::Now();
-    const ssize_t bytes_to_release =
+  while (true) { 
+    absl::Time now = absl::Now(); 
+    const ssize_t bytes_to_release = 
         static_cast<size_t>(tcmalloc::tcmalloc_internal::Parameters::
                                 background_release_rate()) *
-        absl::ToDoubleSeconds(now - prev_time);
-    if (bytes_to_release > 0) {  // may be negative if time goes backwards
-      tcmalloc::MallocExtension::ReleaseMemoryToSystem(bytes_to_release);
-    }
-
+        absl::ToDoubleSeconds(now - prev_time); 
+    if (bytes_to_release > 0) {  // may be negative if time goes backwards 
+      tcmalloc::MallocExtension::ReleaseMemoryToSystem(bytes_to_release); 
+    } 
+ 
     const bool reclaim_idle_per_cpu_caches =
         tcmalloc::tcmalloc_internal::Parameters::reclaim_idle_per_cpu_caches();
-
+ 
     // If enabled, we use heuristics to determine if the per-cpu caches are
     // inactive. If disabled, we use a more conservative approach, that uses
     // allowed cpu masks, to reclaim cpu caches.
@@ -176,7 +176,7 @@ void MallocExtension_Internal_ProcessBackgroundActions() {
     }
 
     tcmalloc::tcmalloc_internal::Static().sharded_transfer_cache().Plunder();
-    prev_time = now;
-    absl::SleepFor(kSleepTime);
-  }
-}
+    prev_time = now; 
+    absl::SleepFor(kSleepTime); 
+  } 
+} 

+ 133 - 133
contrib/libs/tcmalloc/tcmalloc/central_freelist.cc

@@ -1,109 +1,109 @@
-// Copyright 2019 The TCMalloc Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "tcmalloc/central_freelist.h"
-
-#include <stdint.h>
-
-#include "tcmalloc/internal/linked_list.h"
-#include "tcmalloc/internal/logging.h"
-#include "tcmalloc/internal/optimization.h"
-#include "tcmalloc/page_heap.h"
-#include "tcmalloc/pagemap.h"
-#include "tcmalloc/pages.h"
-#include "tcmalloc/static_vars.h"
-
+// Copyright 2019 The TCMalloc Authors 
+// 
+// Licensed under the Apache License, Version 2.0 (the "License"); 
+// you may not use this file except in compliance with the License. 
+// You may obtain a copy of the License at 
+// 
+//     https://www.apache.org/licenses/LICENSE-2.0 
+// 
+// Unless required by applicable law or agreed to in writing, software 
+// distributed under the License is distributed on an "AS IS" BASIS, 
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+// See the License for the specific language governing permissions and 
+// limitations under the License. 
+ 
+#include "tcmalloc/central_freelist.h" 
+ 
+#include <stdint.h> 
+ 
+#include "tcmalloc/internal/linked_list.h" 
+#include "tcmalloc/internal/logging.h" 
+#include "tcmalloc/internal/optimization.h" 
+#include "tcmalloc/page_heap.h" 
+#include "tcmalloc/pagemap.h" 
+#include "tcmalloc/pages.h" 
+#include "tcmalloc/static_vars.h" 
+ 
 GOOGLE_MALLOC_SECTION_BEGIN
-namespace tcmalloc {
+namespace tcmalloc { 
 namespace tcmalloc_internal {
-
-static MemoryTag MemoryTagFromSizeClass(size_t cl) {
+ 
+static MemoryTag MemoryTagFromSizeClass(size_t cl) { 
   if (!Static::numa_topology().numa_aware()) {
     return MemoryTag::kNormal;
   }
   return NumaNormalTag(cl / kNumBaseClasses);
-}
-
-// Like a constructor and hence we disable thread safety analysis.
-void CentralFreeList::Init(size_t cl) ABSL_NO_THREAD_SAFETY_ANALYSIS {
-  size_class_ = cl;
-  object_size_ = Static::sizemap().class_to_size(cl);
-  pages_per_span_ = Length(Static::sizemap().class_to_pages(cl));
-  objects_per_span_ =
-      pages_per_span_.in_bytes() / (object_size_ ? object_size_ : 1);
-}
-
-static Span* MapObjectToSpan(void* object) {
-  const PageId p = PageIdContaining(object);
-  Span* span = Static::pagemap().GetExistingDescriptor(p);
-  return span;
-}
-
+} 
+ 
+// Like a constructor and hence we disable thread safety analysis. 
+void CentralFreeList::Init(size_t cl) ABSL_NO_THREAD_SAFETY_ANALYSIS { 
+  size_class_ = cl; 
+  object_size_ = Static::sizemap().class_to_size(cl); 
+  pages_per_span_ = Length(Static::sizemap().class_to_pages(cl)); 
+  objects_per_span_ = 
+      pages_per_span_.in_bytes() / (object_size_ ? object_size_ : 1); 
+} 
+ 
+static Span* MapObjectToSpan(void* object) { 
+  const PageId p = PageIdContaining(object); 
+  Span* span = Static::pagemap().GetExistingDescriptor(p); 
+  return span; 
+} 
+ 
 Span* CentralFreeList::ReleaseToSpans(void* object, Span* span,
                                       size_t object_size) {
   if (ABSL_PREDICT_FALSE(span->FreelistEmpty(object_size))) {
-    nonempty_.prepend(span);
-  }
-
+    nonempty_.prepend(span); 
+  } 
+ 
   if (ABSL_PREDICT_TRUE(span->FreelistPush(object, object_size))) {
-    return nullptr;
-  }
-  span->RemoveFromList();  // from nonempty_
-  return span;
-}
-
+    return nullptr; 
+  } 
+  span->RemoveFromList();  // from nonempty_ 
+  return span; 
+} 
+ 
 void CentralFreeList::InsertRange(absl::Span<void*> batch) {
   CHECK_CONDITION(!batch.empty() && batch.size() <= kMaxObjectsToMove);
-  Span* spans[kMaxObjectsToMove];
-  // Safe to store free spans into freed up space in span array.
-  Span** free_spans = spans;
-  int free_count = 0;
-
-  // Prefetch Span objects to reduce cache misses.
+  Span* spans[kMaxObjectsToMove]; 
+  // Safe to store free spans into freed up space in span array. 
+  Span** free_spans = spans; 
+  int free_count = 0; 
+ 
+  // Prefetch Span objects to reduce cache misses. 
   for (int i = 0; i < batch.size(); ++i) {
-    Span* span = MapObjectToSpan(batch[i]);
-    ASSERT(span != nullptr);
-    span->Prefetch();
-    spans[i] = span;
-  }
-
-  // First, release all individual objects into spans under our mutex
-  // and collect spans that become completely free.
-  {
+    Span* span = MapObjectToSpan(batch[i]); 
+    ASSERT(span != nullptr); 
+    span->Prefetch(); 
+    spans[i] = span; 
+  } 
+ 
+  // First, release all individual objects into spans under our mutex 
+  // and collect spans that become completely free. 
+  { 
     // Use local copy of variable to ensure that it is not reloaded.
     size_t object_size = object_size_;
-    absl::base_internal::SpinLockHolder h(&lock_);
+    absl::base_internal::SpinLockHolder h(&lock_); 
     for (int i = 0; i < batch.size(); ++i) {
       Span* span = ReleaseToSpans(batch[i], spans[i], object_size);
       if (ABSL_PREDICT_FALSE(span)) {
-        free_spans[free_count] = span;
-        free_count++;
-      }
-    }
+        free_spans[free_count] = span; 
+        free_count++; 
+      } 
+    } 
 
-    RecordMultiSpansDeallocated(free_count);
+    RecordMultiSpansDeallocated(free_count); 
     UpdateObjectCounts(batch.size());
-  }
-
-  // Then, release all free spans into page heap under its mutex.
+  } 
+ 
+  // Then, release all free spans into page heap under its mutex. 
   if (ABSL_PREDICT_FALSE(free_count)) {
     // Unregister size class doesn't require holding any locks.
-    for (int i = 0; i < free_count; ++i) {
-      Span* const free_span = free_spans[i];
-      ASSERT(IsNormalMemory(free_span->start_address())
-      );
-      Static::pagemap().UnregisterSizeClass(free_span);
+    for (int i = 0; i < free_count; ++i) { 
+      Span* const free_span = free_spans[i]; 
+      ASSERT(IsNormalMemory(free_span->start_address()) 
+      ); 
+      Static::pagemap().UnregisterSizeClass(free_span); 
 
       // Before taking pageheap_lock, prefetch the PageTrackers these spans are
       // on.
@@ -130,18 +130,18 @@ void CentralFreeList::InsertRange(absl::Span<void*> batch) {
     absl::base_internal::SpinLockHolder h(&pageheap_lock);
     for (int i = 0; i < free_count; ++i) {
       Span* const free_span = free_spans[i];
-      ASSERT(tag == GetMemoryTag(free_span->start_address()));
-      Static::page_allocator().Delete(free_span, tag);
-    }
-  }
-}
-
-int CentralFreeList::RemoveRange(void** batch, int N) {
-  ASSUME(N > 0);
+      ASSERT(tag == GetMemoryTag(free_span->start_address())); 
+      Static::page_allocator().Delete(free_span, tag); 
+    } 
+  } 
+} 
+ 
+int CentralFreeList::RemoveRange(void** batch, int N) { 
+  ASSUME(N > 0); 
   // Use local copy of variable to ensure that it is not reloaded.
   size_t object_size = object_size_;
   int result = 0;
-  absl::base_internal::SpinLockHolder h(&lock_);
+  absl::base_internal::SpinLockHolder h(&lock_); 
   if (ABSL_PREDICT_FALSE(nonempty_.empty())) {
     result = Populate(batch, N);
   } else {
@@ -155,64 +155,64 @@ int CentralFreeList::RemoveRange(void** batch, int N) {
       }
       result += here;
     } while (result < N && !nonempty_.empty());
-  }
-  UpdateObjectCounts(-result);
-  return result;
-}
-
-// Fetch memory from the system and add to the central cache freelist.
+  } 
+  UpdateObjectCounts(-result); 
+  return result; 
+} 
+ 
+// Fetch memory from the system and add to the central cache freelist. 
 int CentralFreeList::Populate(void** batch,
                               int N) ABSL_NO_THREAD_SAFETY_ANALYSIS {
-  // Release central list lock while operating on pageheap
+  // Release central list lock while operating on pageheap 
   // Note, this could result in multiple calls to populate each allocating
   // a new span and the pushing those partially full spans onto nonempty.
-  lock_.Unlock();
-
-  const MemoryTag tag = MemoryTagFromSizeClass(size_class_);
-  Span* span = Static::page_allocator().New(pages_per_span_, tag);
+  lock_.Unlock(); 
+ 
+  const MemoryTag tag = MemoryTagFromSizeClass(size_class_); 
+  Span* span = Static::page_allocator().New(pages_per_span_, tag); 
   if (ABSL_PREDICT_FALSE(span == nullptr)) {
-    Log(kLog, __FILE__, __LINE__, "tcmalloc: allocation failed",
-        pages_per_span_.in_bytes());
-    lock_.Lock();
+    Log(kLog, __FILE__, __LINE__, "tcmalloc: allocation failed", 
+        pages_per_span_.in_bytes()); 
+    lock_.Lock(); 
     return 0;
-  }
+  } 
   ASSERT(tag == GetMemoryTag(span->start_address()));
-  ASSERT(span->num_pages() == pages_per_span_);
-
-  Static::pagemap().RegisterSizeClass(span, size_class_);
+  ASSERT(span->num_pages() == pages_per_span_); 
+ 
+  Static::pagemap().RegisterSizeClass(span, size_class_); 
   size_t objects_per_span = objects_per_span_;
   int result = span->BuildFreelist(object_size_, objects_per_span, batch, N);
   ASSERT(result > 0);
   // This is a cheaper check than using FreelistEmpty().
   bool span_empty = result == objects_per_span;
-
-  lock_.Lock();
+ 
+  lock_.Lock(); 
   if (!span_empty) {
     nonempty_.prepend(span);
   }
-  RecordSpanAllocated();
+  RecordSpanAllocated(); 
   return result;
-}
-
+} 
+ 
 size_t CentralFreeList::OverheadBytes() const {
   if (ABSL_PREDICT_FALSE(object_size_ == 0)) {
-    return 0;
-  }
-  const size_t overhead_per_span = pages_per_span_.in_bytes() % object_size_;
-  return num_spans() * overhead_per_span;
-}
-
-SpanStats CentralFreeList::GetSpanStats() const {
-  SpanStats stats;
+    return 0; 
+  } 
+  const size_t overhead_per_span = pages_per_span_.in_bytes() % object_size_; 
+  return num_spans() * overhead_per_span; 
+} 
+ 
+SpanStats CentralFreeList::GetSpanStats() const { 
+  SpanStats stats; 
   if (ABSL_PREDICT_FALSE(objects_per_span_ == 0)) {
-    return stats;
-  }
-  stats.num_spans_requested = static_cast<size_t>(num_spans_requested_.value());
-  stats.num_spans_returned = static_cast<size_t>(num_spans_returned_.value());
-  stats.obj_capacity = stats.num_live_spans() * objects_per_span_;
-  return stats;
-}
-
+    return stats; 
+  } 
+  stats.num_spans_requested = static_cast<size_t>(num_spans_requested_.value()); 
+  stats.num_spans_returned = static_cast<size_t>(num_spans_returned_.value()); 
+  stats.obj_capacity = stats.num_live_spans() * objects_per_span_; 
+  return stats; 
+} 
+ 
 }  // namespace tcmalloc_internal
-}  // namespace tcmalloc
+}  // namespace tcmalloc 
 GOOGLE_MALLOC_SECTION_END

+ 118 - 118
contrib/libs/tcmalloc/tcmalloc/central_freelist.h

@@ -1,75 +1,75 @@
-// Copyright 2019 The TCMalloc Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef TCMALLOC_CENTRAL_FREELIST_H_
-#define TCMALLOC_CENTRAL_FREELIST_H_
-
-#include <stddef.h>
-
-#include <cstddef>
-
-#include "absl/base/attributes.h"
-#include "absl/base/const_init.h"
-#include "absl/base/internal/spinlock.h"
-#include "absl/base/macros.h"
-#include "absl/base/thread_annotations.h"
-#include "tcmalloc/internal/atomic_stats_counter.h"
-#include "tcmalloc/span.h"
-#include "tcmalloc/span_stats.h"
-
+// Copyright 2019 The TCMalloc Authors 
+// 
+// Licensed under the Apache License, Version 2.0 (the "License"); 
+// you may not use this file except in compliance with the License. 
+// You may obtain a copy of the License at 
+// 
+//     https://www.apache.org/licenses/LICENSE-2.0 
+// 
+// Unless required by applicable law or agreed to in writing, software 
+// distributed under the License is distributed on an "AS IS" BASIS, 
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+// See the License for the specific language governing permissions and 
+// limitations under the License. 
+ 
+#ifndef TCMALLOC_CENTRAL_FREELIST_H_ 
+#define TCMALLOC_CENTRAL_FREELIST_H_ 
+ 
+#include <stddef.h> 
+ 
+#include <cstddef> 
+ 
+#include "absl/base/attributes.h" 
+#include "absl/base/const_init.h" 
+#include "absl/base/internal/spinlock.h" 
+#include "absl/base/macros.h" 
+#include "absl/base/thread_annotations.h" 
+#include "tcmalloc/internal/atomic_stats_counter.h" 
+#include "tcmalloc/span.h" 
+#include "tcmalloc/span_stats.h" 
+ 
 GOOGLE_MALLOC_SECTION_BEGIN
-namespace tcmalloc {
+namespace tcmalloc { 
 namespace tcmalloc_internal {
-
-// Data kept per size-class in central cache.
-class CentralFreeList {
- public:
-  constexpr CentralFreeList()
-      : lock_(absl::kConstInit, absl::base_internal::SCHEDULE_KERNEL_ONLY),
-        size_class_(0),
-        object_size_(0),
-        objects_per_span_(0),
-        pages_per_span_(0),
-        nonempty_() {}
-
-  CentralFreeList(const CentralFreeList&) = delete;
-  CentralFreeList& operator=(const CentralFreeList&) = delete;
-
-  void Init(size_t cl) ABSL_LOCKS_EXCLUDED(lock_);
-
-  // These methods all do internal locking.
-
+ 
+// Data kept per size-class in central cache. 
+class CentralFreeList { 
+ public: 
+  constexpr CentralFreeList() 
+      : lock_(absl::kConstInit, absl::base_internal::SCHEDULE_KERNEL_ONLY), 
+        size_class_(0), 
+        object_size_(0), 
+        objects_per_span_(0), 
+        pages_per_span_(0), 
+        nonempty_() {} 
+ 
+  CentralFreeList(const CentralFreeList&) = delete; 
+  CentralFreeList& operator=(const CentralFreeList&) = delete; 
+ 
+  void Init(size_t cl) ABSL_LOCKS_EXCLUDED(lock_); 
+ 
+  // These methods all do internal locking. 
+ 
   // Insert batch into the central freelist.
   // REQUIRES: batch.size() > 0 && batch.size() <= kMaxObjectsToMove.
   void InsertRange(absl::Span<void*> batch) ABSL_LOCKS_EXCLUDED(lock_);
-
-  // Fill a prefix of batch[0..N-1] with up to N elements removed from central
-  // freelist.  Return the number of elements removed.
-  ABSL_MUST_USE_RESULT int RemoveRange(void** batch, int N)
-      ABSL_LOCKS_EXCLUDED(lock_);
-
-  // Returns the number of free objects in cache.
+ 
+  // Fill a prefix of batch[0..N-1] with up to N elements removed from central 
+  // freelist.  Return the number of elements removed. 
+  ABSL_MUST_USE_RESULT int RemoveRange(void** batch, int N) 
+      ABSL_LOCKS_EXCLUDED(lock_); 
+ 
+  // Returns the number of free objects in cache. 
   size_t length() const { return static_cast<size_t>(counter_.value()); }
-
-  // Returns the memory overhead (internal fragmentation) attributable
-  // to the freelist.  This is memory lost when the size of elements
-  // in a freelist doesn't exactly divide the page-size (an 8192-byte
-  // page full of 5-byte objects would have 2 bytes memory overhead).
+ 
+  // Returns the memory overhead (internal fragmentation) attributable 
+  // to the freelist.  This is memory lost when the size of elements 
+  // in a freelist doesn't exactly divide the page-size (an 8192-byte 
+  // page full of 5-byte objects would have 2 bytes memory overhead). 
   size_t OverheadBytes() const;
-
-  SpanStats GetSpanStats() const;
-
+ 
+  SpanStats GetSpanStats() const; 
+ 
   void AcquireInternalLocks() {
     lock_.Lock();
   }
@@ -78,65 +78,65 @@ class CentralFreeList {
     lock_.Unlock();
   }
 
- private:
-  // Release an object to spans.
-  // Returns object's span if it become completely free.
+ private: 
+  // Release an object to spans. 
+  // Returns object's span if it become completely free. 
   Span* ReleaseToSpans(void* object, Span* span, size_t object_size)
-      ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_);
-
-  // Populate cache by fetching from the page heap.
-  // May temporarily release lock_.
+      ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_); 
+ 
+  // Populate cache by fetching from the page heap. 
+  // May temporarily release lock_. 
   // Fill a prefix of batch[0..N-1] with up to N elements removed from central
   // freelist. Returns the number of elements removed.
   int Populate(void** batch, int N) ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_);
-
-  // This lock protects all the mutable data members.
-  absl::base_internal::SpinLock lock_;
-
-  size_t size_class_;  // My size class (immutable after Init())
-  size_t object_size_;
-  size_t objects_per_span_;
-  Length pages_per_span_;
-
-  size_t num_spans() const {
-    size_t requested = num_spans_requested_.value();
-    size_t returned = num_spans_returned_.value();
-    if (requested < returned) return 0;
-    return (requested - returned);
-  }
-
-  void RecordSpanAllocated() ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_) {
-    counter_.LossyAdd(objects_per_span_);
-    num_spans_requested_.LossyAdd(1);
-  }
-
-  void RecordMultiSpansDeallocated(size_t num_spans_returned)
-      ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_) {
-    counter_.LossyAdd(-num_spans_returned * objects_per_span_);
-    num_spans_returned_.LossyAdd(num_spans_returned);
-  }
-
-  void UpdateObjectCounts(int num) ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_) {
-    counter_.LossyAdd(num);
-  }
-
-  // The followings are kept as a StatsCounter so that they can read without
-  // acquiring a lock. Updates to these variables are guarded by lock_
-  // so writes are performed using LossyAdd for speed, the lock still
-  // guarantees accuracy.
-
-  // Num free objects in cache entry
+ 
+  // This lock protects all the mutable data members. 
+  absl::base_internal::SpinLock lock_; 
+ 
+  size_t size_class_;  // My size class (immutable after Init()) 
+  size_t object_size_; 
+  size_t objects_per_span_; 
+  Length pages_per_span_; 
+ 
+  size_t num_spans() const { 
+    size_t requested = num_spans_requested_.value(); 
+    size_t returned = num_spans_returned_.value(); 
+    if (requested < returned) return 0; 
+    return (requested - returned); 
+  } 
+ 
+  void RecordSpanAllocated() ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_) { 
+    counter_.LossyAdd(objects_per_span_); 
+    num_spans_requested_.LossyAdd(1); 
+  } 
+ 
+  void RecordMultiSpansDeallocated(size_t num_spans_returned) 
+      ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_) { 
+    counter_.LossyAdd(-num_spans_returned * objects_per_span_); 
+    num_spans_returned_.LossyAdd(num_spans_returned); 
+  } 
+ 
+  void UpdateObjectCounts(int num) ABSL_EXCLUSIVE_LOCKS_REQUIRED(lock_) { 
+    counter_.LossyAdd(num); 
+  } 
+ 
+  // The followings are kept as a StatsCounter so that they can read without 
+  // acquiring a lock. Updates to these variables are guarded by lock_ 
+  // so writes are performed using LossyAdd for speed, the lock still 
+  // guarantees accuracy. 
+ 
+  // Num free objects in cache entry 
   StatsCounter counter_;
-
+ 
   StatsCounter num_spans_requested_;
   StatsCounter num_spans_returned_;
-
-  // Dummy header for non-empty spans
-  SpanList nonempty_ ABSL_GUARDED_BY(lock_);
-};
-
+ 
+  // Dummy header for non-empty spans 
+  SpanList nonempty_ ABSL_GUARDED_BY(lock_); 
+}; 
+ 
 }  // namespace tcmalloc_internal
-}  // namespace tcmalloc
+}  // namespace tcmalloc 
 GOOGLE_MALLOC_SECTION_END
-
-#endif  // TCMALLOC_CENTRAL_FREELIST_H_
+ 
+#endif  // TCMALLOC_CENTRAL_FREELIST_H_ 

+ 112 - 112
contrib/libs/tcmalloc/tcmalloc/central_freelist_test.cc

@@ -1,121 +1,121 @@
-// Copyright 2019 The TCMalloc Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "tcmalloc/central_freelist.h"
-
-#include <algorithm>
-
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-#include "absl/random/random.h"
-#include "tcmalloc/common.h"
-#include "tcmalloc/static_vars.h"
-
-namespace tcmalloc {
+// Copyright 2019 The TCMalloc Authors 
+// 
+// Licensed under the Apache License, Version 2.0 (the "License"); 
+// you may not use this file except in compliance with the License. 
+// You may obtain a copy of the License at 
+// 
+//     https://www.apache.org/licenses/LICENSE-2.0 
+// 
+// Unless required by applicable law or agreed to in writing, software 
+// distributed under the License is distributed on an "AS IS" BASIS, 
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+// See the License for the specific language governing permissions and 
+// limitations under the License. 
+ 
+#include "tcmalloc/central_freelist.h" 
+ 
+#include <algorithm> 
+ 
+#include "gmock/gmock.h" 
+#include "gtest/gtest.h" 
+#include "absl/random/random.h" 
+#include "tcmalloc/common.h" 
+#include "tcmalloc/static_vars.h" 
+ 
+namespace tcmalloc { 
 namespace tcmalloc_internal {
-namespace {
-
-// TODO(b/162552708) Mock out the page heap to interact with CFL instead
-class CFLTest : public testing::TestWithParam<size_t> {
- protected:
-  size_t cl_;
-  size_t batch_size_;
-  size_t objects_per_span_;
-  CentralFreeList cfl_;
-
- private:
-  void SetUp() override {
-    cl_ = GetParam();
-    size_t object_size = Static::sizemap().class_to_size(cl_);
-    if (object_size == 0) {
-      GTEST_SKIP() << "Skipping empty size class.";
-    }
-
-    auto pages_per_span = Length(Static::sizemap().class_to_pages(cl_));
-    batch_size_ = Static::sizemap().num_objects_to_move(cl_);
-    objects_per_span_ = pages_per_span.in_bytes() / object_size;
-    cfl_.Init(cl_);
-  }
-
-  void TearDown() override { EXPECT_EQ(cfl_.length(), 0); }
-};
-
-TEST_P(CFLTest, SingleBatch) {
-  void* batch[kMaxObjectsToMove];
+namespace { 
+ 
+// TODO(b/162552708) Mock out the page heap to interact with CFL instead 
+class CFLTest : public testing::TestWithParam<size_t> { 
+ protected: 
+  size_t cl_; 
+  size_t batch_size_; 
+  size_t objects_per_span_; 
+  CentralFreeList cfl_; 
+ 
+ private: 
+  void SetUp() override { 
+    cl_ = GetParam(); 
+    size_t object_size = Static::sizemap().class_to_size(cl_); 
+    if (object_size == 0) { 
+      GTEST_SKIP() << "Skipping empty size class."; 
+    } 
+ 
+    auto pages_per_span = Length(Static::sizemap().class_to_pages(cl_)); 
+    batch_size_ = Static::sizemap().num_objects_to_move(cl_); 
+    objects_per_span_ = pages_per_span.in_bytes() / object_size; 
+    cfl_.Init(cl_); 
+  } 
+ 
+  void TearDown() override { EXPECT_EQ(cfl_.length(), 0); } 
+}; 
+ 
+TEST_P(CFLTest, SingleBatch) { 
+  void* batch[kMaxObjectsToMove]; 
   uint64_t got = cfl_.RemoveRange(batch, batch_size_);
   ASSERT_GT(got, 0);
   cfl_.InsertRange({batch, got});
-  SpanStats stats = cfl_.GetSpanStats();
-  EXPECT_EQ(stats.num_spans_requested, 1);
-  EXPECT_EQ(stats.num_spans_returned, 1);
-  EXPECT_EQ(stats.obj_capacity, 0);
-}
-
-TEST_P(CFLTest, MultipleSpans) {
-  std::vector<void*> all_objects;
-
-  const size_t num_spans = 10;
-
-  // Request num_spans spans
-  void* batch[kMaxObjectsToMove];
-  const int num_objects_to_fetch = num_spans * objects_per_span_;
-  int total_fetched = 0;
-  while (total_fetched < num_objects_to_fetch) {
+  SpanStats stats = cfl_.GetSpanStats(); 
+  EXPECT_EQ(stats.num_spans_requested, 1); 
+  EXPECT_EQ(stats.num_spans_returned, 1); 
+  EXPECT_EQ(stats.obj_capacity, 0); 
+} 
+ 
+TEST_P(CFLTest, MultipleSpans) { 
+  std::vector<void*> all_objects; 
+ 
+  const size_t num_spans = 10; 
+ 
+  // Request num_spans spans 
+  void* batch[kMaxObjectsToMove]; 
+  const int num_objects_to_fetch = num_spans * objects_per_span_; 
+  int total_fetched = 0; 
+  while (total_fetched < num_objects_to_fetch) { 
     size_t n = num_objects_to_fetch - total_fetched;
     int got = cfl_.RemoveRange(batch, std::min(n, batch_size_));
-    for (int i = 0; i < got; ++i) {
-      all_objects.push_back(batch[i]);
-    }
-    total_fetched += got;
-  }
-
-  SpanStats stats = cfl_.GetSpanStats();
-  EXPECT_EQ(stats.num_spans_requested, num_spans);
-  EXPECT_EQ(stats.num_spans_returned, 0);
-
-  EXPECT_EQ(all_objects.size(), num_objects_to_fetch);
-
-  // Shuffle
-  absl::BitGen rng;
-  std::shuffle(all_objects.begin(), all_objects.end(), rng);
-
-  // Return all
-  int total_returned = 0;
-  bool checked_half = false;
-  while (total_returned < num_objects_to_fetch) {
+    for (int i = 0; i < got; ++i) { 
+      all_objects.push_back(batch[i]); 
+    } 
+    total_fetched += got; 
+  } 
+ 
+  SpanStats stats = cfl_.GetSpanStats(); 
+  EXPECT_EQ(stats.num_spans_requested, num_spans); 
+  EXPECT_EQ(stats.num_spans_returned, 0); 
+ 
+  EXPECT_EQ(all_objects.size(), num_objects_to_fetch); 
+ 
+  // Shuffle 
+  absl::BitGen rng; 
+  std::shuffle(all_objects.begin(), all_objects.end(), rng); 
+ 
+  // Return all 
+  int total_returned = 0; 
+  bool checked_half = false; 
+  while (total_returned < num_objects_to_fetch) { 
     uint64_t size_to_pop =
-        std::min(all_objects.size() - total_returned, batch_size_);
-    for (int i = 0; i < size_to_pop; ++i) {
-      batch[i] = all_objects[i + total_returned];
-    }
-    total_returned += size_to_pop;
+        std::min(all_objects.size() - total_returned, batch_size_); 
+    for (int i = 0; i < size_to_pop; ++i) { 
+      batch[i] = all_objects[i + total_returned]; 
+    } 
+    total_returned += size_to_pop; 
     cfl_.InsertRange({batch, size_to_pop});
-    // sanity check
-    if (!checked_half && total_returned >= (num_objects_to_fetch / 2)) {
-      stats = cfl_.GetSpanStats();
-      EXPECT_GT(stats.num_spans_requested, stats.num_spans_returned);
-      EXPECT_NE(stats.obj_capacity, 0);
-      checked_half = true;
-    }
-  }
-
-  stats = cfl_.GetSpanStats();
-  EXPECT_EQ(stats.num_spans_requested, stats.num_spans_returned);
-  EXPECT_EQ(stats.obj_capacity, 0);
-}
-
-INSTANTIATE_TEST_SUITE_P(All, CFLTest, testing::Range(size_t(1), kNumClasses));
-}  // namespace
+    // sanity check 
+    if (!checked_half && total_returned >= (num_objects_to_fetch / 2)) { 
+      stats = cfl_.GetSpanStats(); 
+      EXPECT_GT(stats.num_spans_requested, stats.num_spans_returned); 
+      EXPECT_NE(stats.obj_capacity, 0); 
+      checked_half = true; 
+    } 
+  } 
+ 
+  stats = cfl_.GetSpanStats(); 
+  EXPECT_EQ(stats.num_spans_requested, stats.num_spans_returned); 
+  EXPECT_EQ(stats.obj_capacity, 0); 
+} 
+ 
+INSTANTIATE_TEST_SUITE_P(All, CFLTest, testing::Range(size_t(1), kNumClasses)); 
+}  // namespace 
 }  // namespace tcmalloc_internal
-}  // namespace tcmalloc
+}  // namespace tcmalloc 

Некоторые файлы не были показаны из-за большого количества измененных файлов