Skip to content

Commit f107fc8

Browse files
grammer fix module language
1 parent fbfb88c commit f107fc8

27 files changed

+408
-413
lines changed

distributed/clock.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- Cant distinguish concurrent event
1313

1414
### Vector Clock
15-
- Just array of lamport
15+
- Just an array of Lamport
1616
- CRDT
1717
- Causally Related
1818
- One must be less and others equal or less
@@ -21,7 +21,7 @@
2121

2222
### Interval Tree Clock
2323
- Version Vectors or Interval Tree Clocks
24-
- All unique identifier coming together modifying
24+
- All unique identifiers coming together modifying
2525
- We need to track causality.
2626
- In a nutshell, given two events modifying a given piece of data and originating from different nodes in the system, we want to know if one of those events could have influenced the other one, or in other words if one of those events `happened before` the other one.
2727

distributed/distributed systems.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Distributed Systems
22

3-
A distributed system is basically a network of autonomous systems/servers connected using a middleware which can share resources, capabilities, files and so on.
3+
A distributed system is a network of autonomous systems/servers connected using a middleware that can share resources, capabilities, files, and so on.
44

55

66
Distributed System Categories
@@ -12,10 +12,10 @@ Distributed System Categories
1212
6. Distributed Ledgers
1313

1414

15-
### Concensus
15+
### Consensus
1616
- State machine replication based on log
1717
- State Machine Replication Principle:
18-
- Physical logging means logging the contents of each row that is changed.
18+
- Physical logging means logging the contents of each row that is changed.
1919
- Logical logging means logging not the changed rows but the SQL commands that lead to the row changes
2020

2121
- Symmetric
@@ -26,7 +26,7 @@ Distributed System Categories
2626
- Raft
2727

2828
- Distributed Data Stores
29-
- The concensus part can be separated as a service with ZooKeeper
29+
- The consensus part can be separated as a service with ZooKeeper
3030
- Consistency Model
3131
- ACID
3232
- eg. HBase, Couchbase, Redis, Zookeeper.
@@ -42,7 +42,7 @@ Distributed System Categories
4242

4343
- Distributed Application
4444
- Bittorent
45-
- Trackerless torrent: Protocol that did not rely on centralized trackers for gathering metadata and finding peers, but instead uses new algorithms.
45+
- Trackerless torrent: Protocol that does not rely on centralized trackers for gathering metadata and finding peers, but instead uses new algorithms.
4646
- One such instance is Kademlia `Mainline DHT`, a distributed hash table (DHT) that allows you to find peers through other peers.
4747
- In effect, each user performs a tracker’s duties.
4848

@@ -54,12 +54,12 @@ Distributed System Categories
5454

5555
- Preserves symmetry and avoids having a centralized registry for storing membership and node liveness information.
5656

57-
- Data replication is at the heart of making data durable and available in the presence of hardware failures such as machine crashes, disk failures, network partitions and clock skews.
57+
- Data replication is at the heart of making data durable and available in the presence of hardware failures such as machine crashes, disk failures, network partitions, and clock skews.
5858

5959
- Popular implementations include those from `etcd` and `consul`.
6060
- Next-generation distributed databases such as YugaByte DB, CockroachDB and TiDB use Raft for both leader election and data replication
6161

62-
- The final value has to determined non-deterministically using heuristics such as Last-Writer-Wins (LWW) and Conflict Free Replicated Data Types (CRDT).
62+
- The final value has to be determined non-deterministically using heuristics such as Last-Writer-Wins (LWW) and Conflict Free Replicated Data Types (CRDT).
6363

6464
- Distributed systems are kept weakly consistent for performance
6565
- Input Speculation
@@ -71,12 +71,12 @@ Distributed System Categories
7171
- But another possible approach is optimistic replication, where all concurrent updates are allowed to go through, with inconsistencies possibly created, and the results are merged or "resolved" later.
7272
- In this approach, consistency between the replicas is eventually re-established via "merges" of differing replicas.
7373
- Operation based
74-
- State based
74+
- State-based
7575
- However, there are practical differences.
76-
- State-based CRDTs are often simpler to design and to implement; their only requirement from the communication substrate is some kind of gossip protocol.
76+
- State-based CRDTs are often simpler to design and implement; their only requirement from the communication substrate is some kind of gossip protocol.
7777
- Their drawback is that the entire state of every CRDT must be transmitted eventually to every other replica, which may be costly.
7878
- In contrast, operation-based CRDTs transmit only the update operations, which are typically small.
79-
- However, operation-based CRDTs require guarantees from the communication middleware;that the operations are not dropped or duplicated when transmitted to the other replicas, and that they are delivered in causal order.
79+
- However, operation-based CRDTs require guarantees from the communication middleware; that the operations are not dropped or duplicated when transmitted to the other replicas, and that they are delivered in causal order.
8080

8181

8282
### Network Time Protocol
@@ -86,7 +86,7 @@ Distributed System Categories
8686
- It is very useful in situations like bank transactions. Assume the following situation without the presence of NTP. - Suppose you carry out a transaction, where your computer reads the time at 2:30 PM while the server records it at 2:28 PM.
8787
- The server can crash very badly if it’s out of sync.
8888

89-
- Google's spanner database uses GPS syncronized atomic clock
89+
- Google's Spanner database uses GPS-synchronized atomic clock
9090

9191
- Netdate - update instantly ( A unix package)
9292

@@ -103,13 +103,13 @@ As category 1 Stratum is not publicly available, we can get from 2
103103
- Drift > clock frequency different > sync
104104
- Jitter > difference between time provider & time consumer since the last time polling
105105
- conf - server pool.ntp.org
106-
- ntpdate to update in reasonable window
106+
- update to update in a reasonable window
107107

108108
### Gossip Protocol
109-
- A, B has some state. A sends it's state with version / timestamp.
110-
- B checks updated, update it's and send back the one A lacks.
111-
- A updates and sends acknowledgement
112-
- Kubernates depends on etcd
109+
- A and B have some states. A sends its state with version/timestamp.
110+
- B checks updated, update it, and send back the one A lacks.
111+
- A updates and sends an acknowledgment
112+
- Kubernetes depends on etcd
113113
- Kafka, elastic search on zookeeper
114114
- Three requirements for P2P
115115
- Group Membership
@@ -125,10 +125,10 @@ As category 1 Stratum is not publicly available, we can get from 2
125125
- Status
126126
- Heartbeat state
127127
- Endpoint state
128-
- Collection of above two
128+
- Collection of the above two
129129
- Seed node added only at cluster setup
130130
- Timeout value dynamically calculated
131-
- Akka has cluster singleton
131+
- Akka has a cluster of singleton
132132
- Consul extension lifeguard
133133

134134
### References
@@ -138,7 +138,7 @@ As category 1 Stratum is not publicly available, we can get from 2
138138
- [Implementing chubby a distributed lock](https://medium.com/princeton-systems-course/implementing-chubby-a-distributed-lock-service-8cf3c026c672)
139139
- [HashiCorp Memberlist](https://github.com/hashicorp/memberlist)
140140
- [Rapid](https://github.com/lalithsuresh/rapid)
141-
- Gossip with concensus
141+
- Gossip with consensus
142142
- Kafka moving away from zookeeper which used for membership, failure detection
143143
- [Gossip Protocol](https://www.youtube.com/watch?v=MPfAekq4f5I&ab_channel=DistributedSystemsConference)
144144
- [Gossip Protocol Attibutes](https://www.youtube.com/watch?v=FuP1Fvrv6ZQ&ab_channel=PlanetCassandra )

distributed/libp2p.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- p2p network composed of four elements
66
- Each node identified by `public key`
7-
- Hash of small data structure containing RSA, ed25519, ecp256k1 etc
7+
- Hash of small data structure containing RSA, ed25519, ecp256k1, etc
88
- `Peer Discovery` system, joining
99
- Discover nodes on local network, DNS, DNS-SD
1010
- Bootstrap node
@@ -16,18 +16,18 @@
1616
- negotiate encryption protocol
1717
- on top of encryption multiplexing protocol
1818
- [yamux](https://github.com/hashicorp/yamux)
19-
- each high level request opens up substream
19+
- each high-level request opens up a substream
2020

21-
- IPFS Content addressing
21+
- IPFS Content Addressing
2222
- Find, Fetch, Authenticate
2323
- libp2p Process Addressing
2424
- Find, Connect, Authenticate
2525
- Multi Address
2626
- A Multiaddr is a self-describing network address and protocol stack that is used to establish connections to peers.
2727

2828
```
29-
/ip4/80.123.90.4/tcp/5432
30-
/ip6/[::1]/udp/10560/quic
29+
/ip4/80.123.90.4/TCP/5432
30+
/ip6/[::1]/UDP/10560/quick
3131
/unix//path/to/socket
3232
```
3333

distributed/messaging.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
### Kafka
55
- Dumb broker, Smart consumer Model
6-
- Kafka does not attempt to track which messages were read by each consumer and only retain unread messages.
6+
- Kafka does not attempt to track which messages were read by each consumer and only retains unread messages.
77
- Rather, Kafka retains all messages for a set amount of time, and consumers are responsible for tracking their location in each log.
88
- Kafka uses Zookeeper to do leadership election of Kafka Broker and Topic Partition pairs.
99
- Topics are the logical categorization of messages in Kafka model.
@@ -14,7 +14,7 @@
1414
- The Kafka Producer API is used to produce streams of data records.
1515
- The Kafka Consumer API is used to consume a stream of records from Kafka.
1616
- A Broker is a Kafka server that runs in a Kafka Cluster. Kafka Brokers form a cluster.
17-
- Best effort delivery across process, tcp, udp, just once
17+
- Best effort delivery across process, TCP, UDP, just once
1818
- No ordering
1919

2020
### RabbitMQ
@@ -25,10 +25,10 @@
2525
### ZooKeeper
2626
- Zookeeper as a general purpose distributed process coordination system
2727
- `Zookeeper` is a system for distributed cluster management. It is a distributed key-value store.
28-
- It is highly-optimized for reads but writes are slower.
28+
- It is highly optimized for reads but writes are slower.
2929
- It consists of an odd number of znodes known as an ensemble.
30-
- zookeeper as the backbone for maintaining cluster state and leader election. Handles the `concensus` part.
31-
- Zookeeper solves these problems using its magical tree structure file system called znodes, somewhat similar to the Unix file system.
30+
- zookeeper as the backbone for maintaining cluster state and leader election. Handles the `consensus` part.
31+
- Zookeeper solves these problems using its magical tree structure file system called nodes, somewhat similar to the Unix file system.
3232
- These znodes are analogous to folders and files in a Unix file system with some additional magical abilities.
3333
- Zookeeper provides primitive operations to manipulate these znodes, through which we will solve our distributed system problems.
3434

@@ -42,4 +42,4 @@
4242
- [Zookeeper Doc](https://zookeeper.apache.org/doc/r3.5.7/zookeeperOver.html)
4343
- [Distributed System Design with Zookeeper](https://medium.com/@bikas.katwal10zookeeper-introduction-designing-a-distributed-system-using-zookeeper-and-java-7f1b108e236)
4444
- [Distributed Coordination](https://medium.com/hootsuite-engineering/distributed-coordination-with-zookeeper-247a62c900f1)
45-
- [Why zookeeper needs odd number of nodes](https://medium.com/@bikas.katwal10/why-zookeeper-needs-an-odd-number-of-nodes-bb8d6020e9e9)
45+
- [Why zookeeper needs an odd number of nodes](https://medium.com/@bikas.katwal10/why-zookeeper-needs-an-odd-number-of-nodes-bb8d6020e9e9)

distributed/raft.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ The six fundamental operations of Raft are:
2020
- Configuration Changes
2121
- Adding or removing servers
2222

23-
2423
Each server in the cluster can be in one of three states:
2524
- Follower state
2625
- Leader state
@@ -32,7 +31,7 @@ Each server maintains its current term and has only two RPCs and three persisten
3231

3332
![Raft](./screen/raft.png)
3433

35-
The leader must regularly send empty heartbeats to all followers in the form of empty append entries. The election timeout is the span of time for choosing a leader, and safety is the liveliness of the leader election. A random timeout is eventually selected to complete the election.
34+
The leader must regularly send empty heartbeats to all followers in the form of empty append entries. The election timeout is the period for choosing a leader, and safety is the liveliness of the leader election. A random timeout is eventually selected to complete the election.
3635

3736
### Logs
3837
The committed log is persisted on disk on a majority of the servers. The leader never overwrites the log but appends to it. All future leaders must have all committed logs. The leader will not respond until the command has been logged, committed, and executed by the leader's state machine. Linearizability is guaranteed with a unique key. Configuration changes must go through two phases.
@@ -61,4 +60,4 @@ A term is a duration for which a specific server acts as the leader. A new elect
6160
- [Implementing raft](https://eli.thegreenplace.net/2020/implementing-raft-part-0-introduction)
6261
- [Raft lecture](https://www.youtube.com/watch?v=YbZ3zDzDnrw&feature=youtu.be)
6362
- [Raft Concensus](https://blog.container-solutions.com/raft-explained-part-1-the-consenus-problem)
64-
- [Raft Paper](https://raft.github.io/raft.pdf)
63+
- [Raft Paper](https://raft.github.io/raft.pdf)

distributed/testground.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
- Gossipsub
55
- Peer scoring
66
- Adaptive gossip dissemination
7-
- Oppurtunistic grafting
7+
- Opportunistic grafting
88
- Peer quotas
99
- Graylisting

language/c++/cast.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
```c++
88

9-
// Used to explicitly find out if casted
9+
// Used to explicitly find out if cast
1010
a = f;
1111
a = static_cast<int>(f);
1212

@@ -16,28 +16,28 @@ class Int {
1616
int x;
1717
public:
1818
Int(int x=0) {
19-
cout << "conversion constructor" << endl;
20-
}
19+
cout << "conversion constructor" << endl;
20+
}
2121
operator string ( ) {
22-
cout << "conversion operator" << endl;
22+
cout << "conversion operator" << endl;
2323
return to_string(x);
24-
}
24+
}
2525
}
2626

2727
int main() {
28-
Int obj(3);
28+
Int obj(3);
2929

30-
// Compile time casting
31-
string str = obj;
32-
obj = 20;
30+
// Compile time casting
31+
string str = obj;
32+
obj = 20;
3333
}
3434

3535

3636
// Prevents char to int type cast at compile time
37-
// In every case provides better security than c style (void *) cast
37+
// In every case provides better security than c-style (void *) cast
3838

3939
// For compatible type conversion, such as float to int.
40-
// For conversion operator and conversion constructors.
40+
// For conversion operators and conversion constructors.
4141
// To avoid unrelated pointer conversion.
4242
// Avoids derived to private base pointer conversion.
4343
// Use for all up-cast but never use for confused down-cast because there are no runtime checks performed
@@ -48,12 +48,12 @@ int main() {
4848
4949
- Const Cast
5050
- To remove const, volatile
51-
- When a third party library is taking a `non-const` param and not changing it
51+
- When a third-party library is taking a `non-const` param and not changing it
5252
5353
- Dynamic Cast
54-
- In order to use it, must have `virtual function` in base class.
54+
- To use it, must have `virtual function` in the base class.
5555
- Work only on polymorphic base class (at least one virtual function in base class) because it uses this information in runtime to decide about wrong down-cast
5656
- It is used for up-cast (D to B) and down-cast (B to D), but it is mainly used for correct downcast
57-
- Using this cast has run time overhead, because it checks object types at run time using `RTTI` (Run Time Type Information)
58-
- If we are sure that we will never cast to wrong object then we should always avoid this cast and use `static_cast`
57+
- Using this cast has run time overhead because it checks object types at run time using `RTTI` (Run Time Type Information)
58+
- If we are sure that we will never cast to the wrong object then we should always avoid this cast and use `static_cast`
5959
- Cast from parent to correct leaf is successful

language/concept/concepts.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Concepts
2-
- Other language has compile time and run-time prevention of threading and memory corruption issue, while they abstract away my access to machine. But, C family language provides access with little in the way of safeguard.
3-
- C++ has local dialects that prevent understanding codebase, where rust has strict guideline
2+
- Another language has compile-time and run-time prevention of threading and memory corruption issues, while they abstract away my access to the machine. However, the C family language provides access with little in the way of safeguarding.
3+
- C++ has local dialects that prevent understanding codebase, whereas Rust has a strict guideline
44

55
- Memory barriers
6-
- Can be used to prevent compilers to reorder operations, instructions for instructionn level parallelism
6+
- Can be used to prevent compilers from reordering operations, instructions for instruction-level parallelism
77

88
- [Precompiled Headers](https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html)
99

1010
- [Spinlock](https://github.com/CoffeeBeforeArch/spinlocks)
1111
- Other locks waiting to get to sleep
12-
- Spin lock polls in loop for atomic bool to be available
13-
- Naive approach very high l1-dcache-load-misses
12+
- Spinlock polls in the loop for atomic bool to be available
13+
- Naive approach with very high l1-cache-load-misses
1414
- Four main categories of cache misses
1515
- Compulsory misses
1616
- Cold start
@@ -19,21 +19,21 @@
1919
- Conflict misses
2020
- Same set different portion modify
2121
- Coherence misses
22-
- Same variable in cache line to get multiple access must invalidate all others
22+
- The same variable in the cache line to get multiple access must invalidate all others
2323
- Spin locks mainly get this miss
24-
- Branching. cache line miss improved significantly by read only copy with l1 cache miss due to coherence
25-
- After read permission burst in lock acquire, which solved by active back off
26-
- Passive backoff with built in wait for efficient power consumption
24+
- Branching. cache line miss improved significantly by read-only copy with l1 cache miss due to coherence
25+
- After reading permission burst in lock acquire, which was solved by active back off
26+
- Passive backoff with built-in wait for efficient power consumption
2727
- Random backoff, Exponential backoff
28-
- Exponential backoff makes starving even worse. To prevent starving, ticket based lock.
28+
- Exponential backoff makes starving even worse. To prevent starvation, ticket-based lock.
2929
- Optimize write
30-
- `volatile` keyword used to prevent a variable to read each time from cache, as valiue can be changed from any where else
30+
- The `volatile` keyword is used to prevent a variable from reading each time from the cache, as the valiue can be changed from anywhere else
3131

3232
- [Deep Copy vs Shallow Copy](https://stackoverflow.com/questions/24253344/is-it-possible-to-make-a-type-only-movable-and-not-copyable?rq=1)
3333

3434
-[SOLID](https://youtu.be/Ntraj80qN2k)
3535

3636
- misc
37-
- Friend function to access private variables, or class
37+
- Friend function to access private variables or class
3838
- Used for testing
39-
- In order to introduce a function in lots of object as super function that can access all variables, mutating a object from child to work as parent
39+
- To introduce a function in lots of objects as super function that can access all variables, mutating an object from child to work as a parent

0 commit comments

Comments
 (0)