Skip to content

Commit

Permalink
Site updated: 2023-10-08 23:35:38
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 8, 2023
1 parent 0dafbcb commit 19c1d1c
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 136 deletions.
11 changes: 8 additions & 3 deletions 2020/06/29/basic-paxos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<meta property="og:description" content="basic paxos目的:basic paxos 目的是为了让多个副本最多只有一个值. paxos make simple有一篇论文,描述了basic paxos 的证明和推导过程,描述了prepare 过程的原理 p1 每个acceptor必须有接收第一个它收到的proposal p2 当一个proposal的value 被chosen , 那么所有后续proposal 的值等于valu">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-06-29T08:25:24.000Z">
<meta property="article:modified_time" content="2023-07-29T13:01:59.551Z">
<meta property="article:modified_time" content="2023-10-05T21:37:32.379Z">
<meta property="article:author" content="dinosaur">
<meta property="article:tag" content="paxos">
<meta name="twitter:card" content="summary">
Expand Down Expand Up @@ -225,7 +225,7 @@ <h1 class="post-title" itemprop="name headline">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-07-29 21:01:59" itemprop="dateModified" datetime="2023-07-29T21:01:59+08:00">2023-07-29</time>
<time title="修改时间:2023-10-06 05:37:32" itemprop="dateModified" datetime="2023-10-06T05:37:32+08:00">2023-10-06</time>
</span>


Expand All @@ -247,6 +247,11 @@ <h2 id="paxos-make-simple"><a href="#paxos-make-simple" class="headerlink" title
<p>p2b 当一个proposal的value被chosen , 那么后续所有proposer issue 的proposal number 对应的值等于value</p>
<p>p2c 对应数字n 和值v , 当acceptor 有一个最大集合S ,这个集合满足其中一个条件: 1 没有accetor 一个大于n的值 2 issue 的v 等于这个最大集合S中proposal number 最大的值</p>
<p>到p2c 的时候就是prepare的规则和条件了</p>
<h2 id="每个guarantee的原因"><a href="#每个guarantee的原因" class="headerlink" title="每个guarantee的原因"></a>每个guarantee的原因</h2><p>P1: 为了保证只有一个proposal也能chose a value<br>P2: 为了保证多个被chosen的proposal 都有同样的值(We can allow multiple proposals to be chosen, but we must guarantee<br>that all chosen proposals have the same value)<br>P2a: 为了满足p2 , 我们给出当被chosen的时候,所有acceptor都具有被chosen的<code>value</code><br>P2b:为了满足p2a,我们给出,当被chosen的时候,所有issue的值都有被chseon的<code>value</code><br>P2c: </p>
<ul>
<li>大前提<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">assume that some proposal with number m and value</span><br><span class="line">v is chosen and show that any proposal issued with number n &gt; m also</span><br><span class="line">has value v</span><br></pre></td></tr></table></figure></li>
<li>小前提<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">assumption that every proposal issued with a number in m . . (n − 1) has</span><br><span class="line">value v , where i . . j denotes the set of numbers from i through j</span><br></pre></td></tr></table></figure></li>
</ul>
<p>相关阅读:</p>
<ul>
<li><a target="_blank" rel="noopener" href="http://www.cs.cornell.edu/courses/cs2800/2016sp/lectures/lec39-sound-complete.html">http://www.cs.cornell.edu/courses/cs2800/2016sp/lectures/lec39-sound-complete.html</a></li>
Expand Down Expand Up @@ -336,7 +341,7 @@ <h2 id="paxos-make-simple"><a href="#paxos-make-simple" class="headerlink" title

<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
<div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#basic-paxos"><span class="nav-number">1.</span> <span class="nav-text">basic paxos</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#paxos-make-simple"><span class="nav-number">2.</span> <span class="nav-text">paxos make simple</span></a></li></ol></div>
<div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#basic-paxos"><span class="nav-number">1.</span> <span class="nav-text">basic paxos</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#paxos-make-simple"><span class="nav-number">2.</span> <span class="nav-text">paxos make simple</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%AF%8F%E4%B8%AAguarantee%E7%9A%84%E5%8E%9F%E5%9B%A0"><span class="nav-number">3.</span> <span class="nav-text">每个guarantee的原因</span></a></li></ol></div>
</div>
<!--/noindex-->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<meta property="og:description" content="Garbage-First Garbage CollectionGarbage-First简称g1算法,是java目前可选的一个gc算法。 目标: 在一定的软实时性条件下,保证整体的吞吐 算法构成: 堆等大小: 整个内存堆被划分为相同大小的块。 The Garbage-First collector achieves these goals via sev-eral techniques. T">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-01-30T00:18:21.000Z">
<meta property="article:modified_time" content="2023-10-05T14:22:29.244Z">
<meta property="article:modified_time" content="2023-10-05T21:19:20.493Z">
<meta property="article:author" content="dinosaur">
<meta property="article:tag" content="java">
<meta name="twitter:card" content="summary">
Expand Down Expand Up @@ -225,7 +225,7 @@ <h1 class="post-title" itemprop="name headline">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-05 22:22:29" itemprop="dateModified" datetime="2023-10-05T22:22:29+08:00">2023-10-05</time>
<time title="修改时间:2023-10-06 05:19:20" itemprop="dateModified" datetime="2023-10-06T05:19:20+08:00">2023-10-06</time>
</span>


Expand Down Expand Up @@ -258,6 +258,9 @@ <h2 id="源码分析"><a href="#源码分析" class="headerlink" title="源码
<p>堆栈:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">Thread 23 &quot;GC Thread#4&quot; hit Breakpoint 1, G1ParScanThreadState::do_copy_to_survivor_space (this=0x7fff7c000d90, region_attr=..., old=0x716809d28, old_mark=...) at /home/dai/jdk/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp:443</span><br><span class="line">443 assert(region_attr.is_in_cset(),</span><br><span class="line">(gdb) bt</span><br><span class="line">#0 G1ParScanThreadState::do_copy_to_survivor_space (this=0x7fff7c000d90, region_attr=..., old=0x716809d28, old_mark=...) at /home/dai/jdk/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp:443</span><br><span class="line">#1 0x00007ffff64ab3f6 in G1ParScanThreadState::copy_to_survivor_space (this=0x7fff7c000d90, region_attr=..., old=0x716809d28, old_mark=...)</span><br><span class="line"> at /home/dai/jdk/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp:555</span><br><span class="line">#2 0x00007ffff64de15e in G1ParCopyClosure&lt;(G1Barrier)0, false&gt;::do_oop_work&lt;oopDesc*&gt; (this=0x7fff7c001478, p=0x7ffff02e1cc8) at /home/dai/jdk/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp:240</span><br><span class="line">#3 0x00007ffff64dcbc3 in G1ParCopyClosure&lt;(G1Barrier)0, false&gt;::do_oop (this=0x7fff7c001478, p=0x7ffff02e1cc8) at /home/dai/jdk/src/hotspot/share/gc/g1/g1OopClosures.hpp:167</span><br><span class="line">#4 0x00007ffff6546dd8 in chunk_oops_do (f=0x7fff7c001478, chunk=0x7ffff02e1cb0, chunk_top=0x7ffff02e1cd0 &quot;\350\034\200\026\a&quot;) at /home/dai/jdk/src/hotspot/share/runtime/handles.cpp:100</span><br><span class="line">#5 0x00007ffff6546e23 in HandleArea::oops_do (this=0x7ffff02e1c30, f=0x7fff7c001478) at /home/dai/jdk/src/hotspot/share/runtime/handles.cpp:108</span><br><span class="line">#6 0x00007ffff6d85dd4 in Thread::oops_do_no_frames (this=0x7ffff02e1160, f=0x7fff7c001478, cf=0x7fff7c001520) at /home/dai/jdk/src/hotspot/share/runtime/thread.cpp:550</span><br><span class="line">#7 0x00007ffff6d8a513 in JavaThread::oops_do_no_frames (this=0x7ffff02e1160, f=0x7fff7c001478, cf=0x7fff7c001520) at /home/dai/jdk/src/hotspot/share/runtime/thread.cpp:1968</span><br><span class="line">#8 0x00007ffff6d85e28 in Thread::oops_do (this=0x7ffff02e1160, f=0x7fff7c001478, cf=0x7fff7c001520) at /home/dai/jdk/src/hotspot/share/runtime/thread.cpp:580</span><br><span class="line">#9 0x00007ffff6d91359 in ParallelOopsDoThreadClosure::do_thread (this=0x7fff87dfaa00, t=0x7ffff02e1160) at /home/dai/jdk/src/hotspot/share/runtime/thread.cpp:3620</span><br><span class="line">#10 0x00007ffff6d8c40b in Threads::possibly_parallel_threads_do (is_par=true, tc=0x7fff87dfaa00) at /home/dai/jdk/src/hotspot/share/runtime/thread.cpp:2545</span><br><span class="line">#11 0x00007ffff6d8eac8 in Threads::possibly_parallel_oops_do (is_par=true, f=0x7fff7c001478, cf=0x7fff7c001520) at /home/dai/jdk/src/hotspot/share/runtime/thread.cpp:3626</span><br><span class="line">#12 0x00007ffff64dea53 in G1RootProcessor::process_java_roots (this=0x7fffc9723df0, closures=0x7fff7c001470, phase_times=0x7fffb8001380, worker_id=1)</span><br><span class="line"> at /home/dai/jdk/src/hotspot/share/gc/g1/g1RootProcessor.cpp:183</span><br><span class="line">#13 0x00007ffff64de78e in G1RootProcessor::evacuate_roots (this=0x7fffc9723df0, pss=0x7fff7c000d90, worker_id=1) at /home/dai/jdk/src/hotspot/share/gc/g1/g1RootProcessor.cpp:60</span><br><span class="line">#14 0x00007ffff64f06b8 in G1EvacuateRegionsTask::scan_roots (this=0x7fffc9723f50, pss=0x7fff7c000d90, worker_id=1) at /home/dai/jdk/src/hotspot/share/gc/g1/g1YoungCollector.cpp:706</span><br><span class="line">#15 0x00007ffff64f0632 in G1EvacuateRegionsBaseTask::work (this=0x7fffc9723f50, worker_id=1) at /home/dai/jdk/src/hotspot/share/gc/g1/g1YoungCollector.cpp:693</span><br><span class="line">#16 0x00007ffff6e8bb7c in WorkerTaskDispatcher::worker_run_task (this=0x7ffff00a4c88) at /home/dai/jdk/src/hotspot/share/gc/shared/workerThread.cpp:67</span><br><span class="line">#17 0x00007ffff6e8c074 in WorkerThread::run (this=0x7fffb800df30) at /home/dai/jdk/src/hotspot/share/gc/shared/workerThread.cpp:159</span><br><span class="line">#18 0x00007ffff6d8557f in Thread::call_run (this=0x7fffb800df30) at /home/dai/jdk/src/hotspot/share/runtime/thread.cpp:358</span><br><span class="line">#19 0x00007ffff6acc1e7 in thread_native_entry (thread=0x7fffb800df30) at /home/dai/jdk/src/hotspot/os/linux/os_linux.cpp:705</span><br><span class="line">#20 0x00007ffff7c94ac3 in start_thread (arg=&lt;optimized out&gt;) at ./nptl/pthread_create.c:442</span><br><span class="line">#21 0x00007ffff7d26a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>内存复制:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) &#123;</span><br><span class="line">#ifdef AMD64</span><br><span class="line"> switch (count) &#123;</span><br><span class="line"> case 8: to[7] = from[7];</span><br><span class="line"> case 7: to[6] = from[6];</span><br><span class="line"> case 6: to[5] = from[5];</span><br><span class="line"> case 5: to[4] = from[4];</span><br><span class="line"> case 4: to[3] = from[3];</span><br><span class="line"> case 3: to[2] = from[2];</span><br><span class="line"> case 2: to[1] = from[1];</span><br><span class="line"> case 1: to[0] = from[0];</span><br><span class="line"> case 0: break;</span><br><span class="line"> default:</span><br><span class="line"> (void)memcpy(to, from, count * HeapWordSize);</span><br><span class="line"> break;</span><br><span class="line"> &#125;</span><br><span class="line">#else</span><br><span class="line"> // Includes a zero-count check.</span><br><span class="line"> intx temp;</span><br><span class="line"> __asm__ volatile(&quot; testl %6,%6 ;&quot;</span><br><span class="line"> &quot; jz 3f ;&quot;</span><br><span class="line"> &quot; cmpl $32,%6 ;&quot;</span><br><span class="line"> &quot; ja 2f ;&quot;</span><br><span class="line"> &quot; subl %4,%1 ;&quot;</span><br><span class="line"> &quot;1: movl (%4),%3 ;&quot;</span><br><span class="line"> &quot; movl %7,(%5,%4,1);&quot;</span><br><span class="line"> &quot; addl $4,%0 ;&quot;</span><br><span class="line"> &quot; subl $1,%2 ;&quot;</span><br><span class="line"> &quot; jnz 1b ;&quot;</span><br><span class="line"> &quot; jmp 3f ;&quot;</span><br><span class="line"> &quot;2: rep; smovl ;&quot;</span><br><span class="line"> &quot;3: nop &quot;</span><br><span class="line"> : &quot;=S&quot; (from), &quot;=D&quot; (to), &quot;=c&quot; (count), &quot;=r&quot; (temp)</span><br><span class="line"> : &quot;0&quot; (from), &quot;1&quot; (to), &quot;2&quot; (count), &quot;3&quot; (temp)</span><br><span class="line"> : &quot;memory&quot;, &quot;cc&quot;);</span><br><span class="line">#endif // AMD64</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="相关阅读"><a href="#相关阅读" class="headerlink" title="相关阅读"></a>相关阅读</h2><ul>
<li><a target="_blank" rel="noopener" href="https://nicksxs.me/2019/12/07/JVM-G1-Part-1/">https://nicksxs.me/2019/12/07/JVM-G1-Part-1/</a></li>
</ul>
Expand Down
7 changes: 5 additions & 2 deletions 2023/08/04/java-nio/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<meta property="og:description" content="背景了解java的nio,因为在看到lucene的MappedByteBuffer , 所以想了解一下nio的内容nio 主要包括三个内容: Buffer Selector Channel BufferByteBuffer MappedByteBuffer HeapByteBuffer DirectByteBuffer 例子简单的例子: 123456789101112@Testpublic">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-08-04T14:04:41.000Z">
<meta property="article:modified_time" content="2023-08-27T13:52:07.519Z">
<meta property="article:modified_time" content="2023-10-08T15:34:37.343Z">
<meta property="article:author" content="dinosaur">
<meta property="article:tag" content="java">
<meta property="article:tag" content="nio">
Expand Down Expand Up @@ -226,7 +226,7 @@ <h1 class="post-title" itemprop="name headline">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-08-27 21:52:07" itemprop="dateModified" datetime="2023-08-27T21:52:07+08:00">2023-08-27</time>
<time title="修改时间:2023-10-08 23:34:37" itemprop="dateModified" datetime="2023-10-08T23:34:37+08:00">2023-10-08</time>
</span>


Expand Down Expand Up @@ -255,6 +255,9 @@ <h2 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">@Test</span><br><span class="line">public void fileChannel()</span><br><span class="line"> throws IOException &#123;</span><br><span class="line"> try (FileChannel fc = FileChannel.open(Paths.get(&quot;ccc.cc&quot;),StandardOpenOption.WRITE , StandardOpenOption.READ ,StandardOpenOption.CREATE) ) &#123;</span><br><span class="line"> MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, 1);</span><br><span class="line"> byte b = 97;</span><br><span class="line"> bb.put(0 ,b );</span><br><span class="line"> fc.write(bb);</span><br><span class="line"> var charset = Charset.defaultCharset();</span><br><span class="line"> System.out.println( &quot;res&quot; + charset.decode(bb).toString());</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<p>最后写在这里</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">void put(T x) &#123;</span><br><span class="line"> GuardUnsafeAccess guard(_thread);</span><br><span class="line"> *addr() = normalize_for_write(x);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<h2 id="相关阅读"><a href="#相关阅读" class="headerlink" title="相关阅读"></a>相关阅读</h2><ul>
<li><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_44027353/article/details/121305408">https://blog.csdn.net/qq_44027353/article/details/121305408</a></li>
Expand Down
Loading

0 comments on commit 19c1d1c

Please sign in to comment.