xref: /aosp_15_r20/external/cronet/base/README.md (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker# What is this
2*6777b538SAndroid Build Coastguard WorkerContains a written down set of principles and other information on //base.
3*6777b538SAndroid Build Coastguard WorkerPlease add to it!
4*6777b538SAndroid Build Coastguard Worker
5*6777b538SAndroid Build Coastguard Worker## About //base:
6*6777b538SAndroid Build Coastguard Worker
7*6777b538SAndroid Build Coastguard WorkerChromium is a very mature project. Most things that are generally useful are
8*6777b538SAndroid Build Coastguard Workeralready here and things not here aren't generally useful.
9*6777b538SAndroid Build Coastguard Worker
10*6777b538SAndroid Build Coastguard WorkerThe bar for adding stuff to base is that it must have demonstrated wide
11*6777b538SAndroid Build Coastguard Workerapplicability. Prefer to add things closer to where they're used (i.e. "not
12*6777b538SAndroid Build Coastguard Workerbase"), and pull into base only when needed. In a project our size,
13*6777b538SAndroid Build Coastguard Workersometimes even duplication is OK and inevitable.
14*6777b538SAndroid Build Coastguard Worker
15*6777b538SAndroid Build Coastguard WorkerAdding a new logging macro `DPVELOG_NE` is not more clear than just
16*6777b538SAndroid Build Coastguard Workerwriting the stuff you want to log in a regular logging statement, even
17*6777b538SAndroid Build Coastguard Workerif it makes your calling code longer. Just add it to your own code.
18*6777b538SAndroid Build Coastguard Worker
19*6777b538SAndroid Build Coastguard WorkerIf the code in question does not need to be used inside base, but will have
20*6777b538SAndroid Build Coastguard Workermultiple consumers across the codebase, consider placing it in a new directory
21*6777b538SAndroid Build Coastguard Workerunder components/ instead.
22*6777b538SAndroid Build Coastguard Worker
23*6777b538SAndroid Build Coastguard Workerbase is written for the Chromium project and is not intended to be used
24*6777b538SAndroid Build Coastguard Workeroutside it.  Using base outside of src.git is explicitly not supported,
25*6777b538SAndroid Build Coastguard Workerand base makes no guarantees about API (or even ABI) stability (like all
26*6777b538SAndroid Build Coastguard Workerother code in Chromium).  New code that depends on base/ must be in
27*6777b538SAndroid Build Coastguard Workersrc.git. Code that's not in src.git but pulled in through DEPS (for
28*6777b538SAndroid Build Coastguard Workerexample, v8) cannot use base.
29*6777b538SAndroid Build Coastguard Worker
30*6777b538SAndroid Build Coastguard Worker## Qualifications for being in //base OWNERS
31*6777b538SAndroid Build Coastguard Worker  * interest and ability to learn low level/high detail/complex c++ stuff
32*6777b538SAndroid Build Coastguard Worker  * inclination to always ask why and understand everything (including external
33*6777b538SAndroid Build Coastguard Worker    interactions like win32) rather than just hoping the author did it right
34*6777b538SAndroid Build Coastguard Worker  * mentorship/experience
35*6777b538SAndroid Build Coastguard Worker  * demonstrated good judgement (esp with regards to public APIs) over a length
36*6777b538SAndroid Build Coastguard Worker    of time
37*6777b538SAndroid Build Coastguard Worker
38*6777b538SAndroid Build Coastguard WorkerOwners are added when a contributor has shown the above qualifications and
39*6777b538SAndroid Build Coastguard Workerwhen they express interest. There isn't an upper bound on the number of OWNERS.
40*6777b538SAndroid Build Coastguard Worker
41*6777b538SAndroid Build Coastguard Worker## Design and naming
42*6777b538SAndroid Build Coastguard Worker  * Be sure to use the base namespace.
43*6777b538SAndroid Build Coastguard Worker  * STL-like constructs should adhere as closely to STL as possible. Functions
44*6777b538SAndroid Build Coastguard Worker    and behaviors not present in STL should only be added when they are related
45*6777b538SAndroid Build Coastguard Worker    to the specific data structure implemented by the container.
46*6777b538SAndroid Build Coastguard Worker  * For STL-like constructs our policy is that they should use STL-like naming
47*6777b538SAndroid Build Coastguard Worker    even when it may conflict with the style guide. So functions and class names
48*6777b538SAndroid Build Coastguard Worker    should be lower case with underscores. Non-STL-like classes and functions
49*6777b538SAndroid Build Coastguard Worker    should use Google naming.
50*6777b538SAndroid Build Coastguard Worker
51*6777b538SAndroid Build Coastguard Worker## Performance testing
52*6777b538SAndroid Build Coastguard Worker
53*6777b538SAndroid Build Coastguard WorkerSince the primitives provided by //base are used very widely, it is important to
54*6777b538SAndroid Build Coastguard Workerensure they scale to the necessary workloads and perform well under all
55*6777b538SAndroid Build Coastguard Workersupported platforms. The `base_perftests` target is a suite of
56*6777b538SAndroid Build Coastguard Workersynthetic microbenchmarks that measure performance in various scenarios:
57*6777b538SAndroid Build Coastguard Worker
58*6777b538SAndroid Build Coastguard Worker  * BasicPostTaskPerfTest: Exercises MessageLoopTaskRunner's multi-threaded
59*6777b538SAndroid Build Coastguard Worker    queue in isolation.
60*6777b538SAndroid Build Coastguard Worker  * ConditionVariablePerfTest: Measures thread switching cost of condition
61*6777b538SAndroid Build Coastguard Worker    variables.
62*6777b538SAndroid Build Coastguard Worker  * IntegratedPostTaskPerfTest: Exercises the full MessageLoop/RunLoop
63*6777b538SAndroid Build Coastguard Worker    machinery.
64*6777b538SAndroid Build Coastguard Worker  * JSONPerfTest: Tests JSONWriter and JSONReader performance.
65*6777b538SAndroid Build Coastguard Worker  * MessageLoopPerfTest: Measures the speed of task posting in various
66*6777b538SAndroid Build Coastguard Worker    configurations.
67*6777b538SAndroid Build Coastguard Worker  * ObserverListPerfTest: Exercises adding, removing and signalling observers.
68*6777b538SAndroid Build Coastguard Worker  * PartitionLockPerfTest: Tests the implementation of Lock used in
69*6777b538SAndroid Build Coastguard Worker    PartitionAlloc
70*6777b538SAndroid Build Coastguard Worker  * PthreadEventPerfTest: Establishes the baseline thread switching cost using
71*6777b538SAndroid Build Coastguard Worker    pthreads.
72*6777b538SAndroid Build Coastguard Worker  * RandUtilPerfTest: Measures the time it takes to generate random numbers.
73*6777b538SAndroid Build Coastguard Worker  * ScheduleWorkTest: Measures the overhead of MessagePump::ScheduleWork.
74*6777b538SAndroid Build Coastguard Worker  * SequenceManagerPerfTest: Benchmarks SequenceManager scheduling with various
75*6777b538SAndroid Build Coastguard Worker    underlying task runners.
76*6777b538SAndroid Build Coastguard Worker  * TaskObserverPerfTest: Measures the incremental cost of adding task
77*6777b538SAndroid Build Coastguard Worker    observers.
78*6777b538SAndroid Build Coastguard Worker  * TaskPerfTest: Checks the cost of posting tasks between threads.
79*6777b538SAndroid Build Coastguard Worker  * ThreadLocalStoragePerfTest: Exercises different mechanisms for accessing
80*6777b538SAndroid Build Coastguard Worker    data associated with the current thread (C++ `thread_local`, the
81*6777b538SAndroid Build Coastguard Worker    implementation in //base, the POSIX/WinAPI directly)
82*6777b538SAndroid Build Coastguard Worker  * WaitableEvent{Thread,}PerfTest: Measures waitable events in single and
83*6777b538SAndroid Build Coastguard Worker    multithreaded scenarios.
84*6777b538SAndroid Build Coastguard Worker
85*6777b538SAndroid Build Coastguard WorkerRegressions in these benchmarks can generally by caused by 1) operating system
86*6777b538SAndroid Build Coastguard Workerchanges, 2) compiler version or flag changes or 3) changes in //base code
87*6777b538SAndroid Build Coastguard Workeritself.
88