<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhradeep Chakraborty on Medium]]></title>
        <description><![CDATA[Stories by Abhradeep Chakraborty on Medium]]></description>
        <link>https://medium.com/@abhra303?source=rss-a8b1cb4436df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*coWzD8ZDKEP4g4T9</url>
            <title>Stories by Abhradeep Chakraborty on Medium</title>
            <link>https://medium.com/@abhra303?source=rss-a8b1cb4436df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:15:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhra303/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GSoC Final Report]]></title>
            <link>https://medium.com/@abhra303/gsoc-final-report-feaaacfae737?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/feaaacfae737</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gsoc-2022]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 06:43:55 GMT</pubDate>
            <atom:updated>2022-09-26T15:51:04.913Z</atom:updated>
            <content:encoded><![CDATA[<p>So, we have reached the final week of GSoC. It has been an amazing journey! Let’s summarize what was done, the current state of the project and what’s next.</p><h4>The Project</h4><p>Whenever you run the command git fetch (or similar), git server first decides which objects it has to send. The git client and daemon compares their branch tips and decides which ones to send. For this, Git traverses from the tips to all the objects connected directly or indirectly to it. This traversal goes till a known tip (i.e. the tip which the client already has) has found. As one could imagine this could be a costly operation. More so in the case of clone where Git has to identify and send _all_ the reachable objects.</p><p>To tackle this problem, reachability bitmaps were introduced. The idea is to store a bitmap for every selected commits in a .bitmap file that helps us identify the set of commits reachable from that selected commit. This bitmap could be referred to whenever a set of reachable objects are needed. To know more about reachability bitmaps please read the following links —<a href="https://github.blog/2015-09-22-counting-objects/"> Counting Objects</a>, <a href="https://github.blog/2021-04-29-scaling-monorepo-maintenance/">Scaling monorepo maintenance</a>.</p><p>My project focuses on improving the performance of these reachability bitmaps. It has two parts (actually four parts but the last two parts are more of research type; so me and my mentors decided to omit them for now). These are -</p><ul><li>Individual bitmaps are stored compressed (with <a href="https://arxiv.org/abs/0901.3751">EWAH</a>), but we have some sense that it can be slow to decompress individual bitmaps (which we have to do in order to read them, but also to do things like negate them, OR and AND them together, etc).<br>One possible project could be to explore using an alternative compression scheme (like the more modern <a href="https://roaringbitmap.org/about/">Roaring+Run</a> technique) to see if we can improve overall bitmap performance by reducing the amount of time it takes to read an individual bitmap.</li><li>Loading a .bitmap file can be slow for large bitmaps. This is because we have to read the file sequentially in order to discover the offset of each bitmap within the file.<br>It should be possible to shave off some time from this step by including a small “table of contents” that indicates which commits have bitmaps, and where to find them in the .bitmap file. In the past <a href="https://lore.kernel.org/git/YNuiM8TR5evSeNsN@nand.local/">some efforts have been made</a> to do this. But we should undertake more performance testing to prove whether this is or isn’t a good idea before submitting a patch series in this area.</li></ul><h4>The Patches</h4><p>I started my work on implementing lookup-table for .bitmap file. The lookup table is added at the end of the .bitmap file. The table has N rows (where N is the number of bitmaps present in that file), each containing three information — (1) Offset position (2) commit position (in pack-index or multi-pack-index) and (3) xor position. The patch links are given below -</p><ul><li><a href="https://lore.kernel.org/git/pull.1266.v6.git.1660496112.gitgitgadget@gmail.com/">[PATCH v6 0/6] [GSoC] bitmap: integrate a lookup table extension to the bitmap format</a></li><li><a href="https://lore.kernel.org/git/67b71be8c85a44b21c3181a9e9532d5dc3f81668.1660496112.git.gitgitgadget@gmail.com/">[PATCH v6 1/6] Documentation/technical: describe bitmap lookup table extension</a></li><li><a href="https://lore.kernel.org/git/92ca58fbeeb0ac74a411fc2e67fcbceccc819883.1660496112.git.gitgitgadget@gmail.com/">[PATCH v6 2/6] bitmap: move `get commit positions` code to `bitmap_writer_finish`</a></li><li><a href="https://lore.kernel.org/git/090becaabe0c47fb5fed4ec5ce7628deeafeded1.1660496112.git.gitgitgadget@gmail.com/">[PATCH v6 3/6] pack-bitmap-write.c: write lookup table extension</a></li><li><a href="https://lore.kernel.org/git/b2b7c5c1703b0e0b64599cef26ead46a4ff46afb.1660496112.git.gitgitgadget@gmail.com/">[PATCH v6 4/6] pack-bitmap-write: learn pack.writeBitmapLookupTable and add tests</a></li><li><a href="http://[PATCH v6 5/6] pack-bitmap: prepare to read lookup table extension">[PATCH v6 5/6] pack-bitmap: prepare to read lookup table extension</a></li><li><a href="https://lore.kernel.org/git/b460516b306e6885cd1c0af1c3379fb953952de2.1660496112.git.gitgitgadget@gmail.com/">[PATCH v6 6/6] bitmap-lookup-table: add performance tests for lookup table</a></li></ul><p>After a lot of discussions and modifications, this series has finally been <a href="https://github.com/git/git/commit/3fe0121479ea340936d11927efa5a45a4e1e39cc">merged </a>into the master branch :)</p><p>My next job was to integrate roaring bitmaps. This is a large project which needs backward compatibility. At first I thought I will build the Roaring library all by myself but mentors insisted that it would be better to use the existing CRoaring library. This library has almost all the facilities/features we want except that it doesn’t support big-endian systems. The license also was an issue. Because it was not compatible with Git’s GPLv2 license.</p><p>I reached out to Daniel Lemire and requested him to make the license Git-compatible. The good news is he agreed 😀😀. Go to the following link to see the discussion thread — <a href="https://public-inbox.org/git/CAPOJW5yJDq046nhq0V-syAg4ttoy++rBtq_RHSXPAKhtDDw6jQ@mail.gmail.com/">https://public-inbox.org/git/CAPOJW5yJDq046nhq0V-syAg4ttoy++rBtq_RHSXPAKhtDDw6jQ@mail.gmail.com/</a></p><p>As I mentioned before that the existing CRoaring library has some short comings, I had to make some changes on top of it so that Git can use it properly. I made a new function for enabling network write (although Derrick wrote in his review that instead of making new functions I should modify the existing functions). After that I made sure that the change is backward compatible i.e. the roaring bitmap integretion do not affect the existing ewah bitmap implementation.</p><p>The patch series is currently sent in the mailing list as RFC. It needs some more work to complete. But it is near to ready. The patch links are given below -</p><ul><li><a href="https://lore.kernel.org/git/pull.1357.git.1663609659.gitgitgadget@gmail.com/#t">[PATCH 0/5] [RFC] introduce Roaring bitmaps to Git</a></li><li><a href="https://lore.kernel.org/git/38ec2360f4fbfe65fa2d9f1e9cfb7d4944d1714f.1663609659.git.gitgitgadget@gmail.com/">[PATCH 2/5] roaring.[ch]: apply Git specific changes to the roaring API</a></li><li><a href="https://lore.kernel.org/git/4364224f9bddc8f1e40875ebc540b28225317176.1663609659.git.gitgitgadget@gmail.com/">[PATCH 3/5] roaring: teach Git to write roaring bitmaps</a></li><li><a href="https://lore.kernel.org/git/683b0c625418278e4775978cb663edd03a113faa.1663609660.git.gitgitgadget@gmail.com/">[PATCH 4/5] roaring: introduce a new config option for roaring bitmaps</a></li><li><a href="https://lore.kernel.org/git/7b49bbf2e28d3ff3dd648c51d2d8741e72b0e786.1663609660.git.gitgitgadget@gmail.com/">[PATCH 5/5] roaring: teach Git to read roaring bitmaps</a></li></ul><p>Here is the link of my Github branch where you can find my current progress — <a href="https://github.com/Abhra303/git/tree/roaring-bitmap-exp">Abhra303/roaring-bitmap-exp</a>. Note that I used chunk-format API for .bitmap version 2 file. It brings uniformity in the structure of bitmap related files.</p><h4>Challenges</h4><p>I didn’t have much experience in developing such projects in C before GSoC. So I faced a lot of challenges. It took time to digest all the code and logics behind the existing bitmap implementation.</p><p>My main challenge was to solve errors! As I mentioned previously, I have never used C in such a huge amount in any of my previous projects. So obviously I didn’t know how to debug and solve unknown runtime errors. But my mentors helped me here tremendously. They taught me how to debug the codebase and I learned about various techniques to solve these errors.</p><p>I can remember one such <a href="https://lore.kernel.org/git/p3r70610-8n52-s8q0-n641-onp4ps01330n@tzk.qr/">error</a> which proved to be hard to solve for me. This was an error generating in bitmap’s test script. It had a mysterious characteristic — the test was not failing in all of the invocations of the test. Sometimes it was passing and sometimes not. I tried to figure out what went wrong. I understood the entire midx codebase and looked for potential flaws. Johannes and Derrick also helped me in this process. But sadly I didn’t succeed. Later Taylor was able to find out <a href="https://lore.kernel.org/git/cover.1660944574.git.me@ttaylorr.com/T/#t">the solution</a>.</p><h4>What did I learn?</h4><p>I had an amazing journey this summer. I learned a lot of new things. The most amazing part of my GSoC journey is that I got the opportunity to learn from the most experienced and knowledgeable persons. I learned how to write efficient C code, how to use various debugging tools. I also learned about bash scripting. Overall it was a very good experience :)</p><h4>What next?</h4><p>My main priority is to finish the remaining tasks for roaring bitmaps. Once that is finished, I would like to take on some other issues. Besides I also have a plan to contribute to Kubernetes and other open source projects.</p><p>Thanks :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feaaacfae737" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC Week 11: enabling writing of roaring bitmaps]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-11-enabling-writing-of-roaring-bitmaps-6b3bbe4e2cd7?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b3bbe4e2cd7</guid>
            <category><![CDATA[gsoc-2022]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Mon, 05 Sep 2022 11:09:53 GMT</pubDate>
            <atom:updated>2022-09-05T11:09:53.571Z</atom:updated>
            <content:encoded><![CDATA[<p>It has been a long time I didn&#39;t publish a blog post. Mostly because I was inactive for the last two weeks (first week was spent on Smart India Hackathon and the second week on my semester exams). Thank god, I got a 2 week GSoC time extension, I can put that time on completing roaring bitmap implementation.</p><p>Though I was busy in those weeks, the work was not completely stuck. Besides that I worked full-time this sunday and finished the “writing roaring bitmaps” part. I will cover these changes in this blog post. If you want to see the code you can visit my Github <a href="https://github.com/Abhra303/git/tree/roaring-bitmap-exp">git repository</a>. So let’s start.</p><h4>Preparatory steps for Roaring bitmaps</h4><p>As you might know I had integrated CRoaring library to Git with some specific changes as needed for Git. Now it is time to use it in our codebase. But before that I realized that we needed some preparatory changes. These are listed below.</p><ul><li><strong>Renaming </strong><strong>struct bitmap functions to </strong><strong>raw_bitmap functions: </strong>Before Roaring, there were only two types of bitmaps in Git codebase — (i) ewah bitmap and (ii) uncompressed raw bitmaps ( struct bitmap ). These raw bitmaps has functions that are named in a general sense. As we are trying to maintain backward compatibility, I want to use general names for bitmap functions which internally take care of different bitmap types (e.g. roaring_or_ewah_bitmap). So in that case the current struct bitmap related function names(e.g. bitmap_new() ) would be ambiguous. So I renamed those functions (e.g. bitmap_new()-&gt; raw_bitmap_new()). I didn’t change struct bitmap itself as I didn’t want to complicate things for now. But I will rename it when all the other important works are done.</li><li><strong>Introduce general functions for all the bitmap types: </strong>At first I thought I would be adding if-else check for every occurence of ewah bitmap or raw bitmap related functions (e.g. if (bitmap_type = EWAH) then writer.commits = ewah_new(); else writer.commits = roaring_bitmap_create();). But that would be repetitive and tidious. So, I created a seperate header file (bitmap.h)for storing generalized functions (e.g. roaring_or_ewah_bitmap_new()). I also created a global enum variable bitmap_type which is used to decide whether we need ewah or roaring bitmaps to produce. You can visit my repo and open bitmap.h file to see the code.</li></ul><h4>Implementing Roaring bitmaps</h4><p>Now that all the preparatory steps are done, we can now focus on using roaring bitmaps. As I said before I worked on enabling writing roaring bitmaps part this week.</p><p>Firstly I changed struct bitmap_writer to struct write_bitmap_context as it seems a better name for implementing chunk format. I also changed the type of type indexes (from struct ewah_bitmap * to void *) so that they could accept both roaring and ewah bitmaps. After that I replaced all ewah or raw bitmap related function calls with their corresponding generalized functions. One thing to mention is that I implemented bitmap_writer_init_bm_type() function which sets bitmap_type to either ewah or roaring. Here is the code:</p><pre>void bitmap_writer_init_bm_type(unsigned version_type)<br>{<br>    if (version_type &amp; BITMAP_SET_ROARING_BITMAP) {<br>        writer.bitmap_type = ROARING;<br>        set_bitmap_type(ROARING);<br>    }<br>    else if (version_type &amp; BITMAP_SET_EWAH_BITMAP) {<br>        writer.bitmap_type = EWAH;<br>        set_bitmap_type(EWAH);<br>    }<br>}</pre><h4>Introduce a configuration value to control bitmap type</h4><p>For now, I am using pack.useroaringbitmap configuration option to enable roaring bitmaps. However it is only for multi-pack-index. I haven’t implemented it for pack-objects yet but will do it. I am also thinking of adding a --roaring-bitmap or similar kind of option flag to enable roaring bitmaps.</p><h4>Next Step</h4><p>I am completely free for the upcoming weeks. So I can spend a good amount time on roaring bitmaps. My next goal is to implement “reading roaring bitmaps”. However I have to write tests before that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b3bbe4e2cd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC week 9: finding the fix of the failing test case]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-9-finding-the-fix-of-the-failing-test-case-30bc623cb4c?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/30bc623cb4c</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Mon, 15 Aug 2022 18:05:44 GMT</pubDate>
            <atom:updated>2022-08-15T18:05:44.649Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers, welcome to my another GSoC blog. This week I spent most of the time on trying to fix a failing test case. Besides that I worked further to implement roaring bitmaps.</p><h4>Update about Roaring bitmaps</h4><p>For some time, I was thinking of using Git’s chunk-format API for the new roaring bitmap version file. One reason is that Taylor want me to give a try at it. It has some advantage over the old .bitmap version. Chunk formatted files are made of several chunks — each chunk belongs to a specific section of the file. The chunk based region in a file starts with a table of content section. This table stores rows of chunk IDs along with their offsets. You can know the size of a chunk by subtracting the offset of the previous chunk from the offset of that chunk.</p><p>Multi-pack-index file also uses the same format to store midx contents. So using that in our.bitmap file will bring uniformity among files.</p><p>So, I decided to do it. The structure is more or less ready. The main thing here is to reformat (or restructure) the existing code so that the effected source files do not look much complicated. Below is the rough code for the write_roaring_bitmap_file() function -</p><pre>void write_roaring_bitmap_file(struct pack_idx_entry **index,<br>                               uint32_t index_nr,<br>                               const char *filename,<br>                               uint16_t options)</pre><pre>{<br>    static uint16_t flags = BITMAP_OPT_FULL_DAG;<br>    struct strbuf tmp_file = STRBUF_INIT;<br>    struct hashfile *f = NULL;<br>    struct chunkfile *cf = NULL;<br>    int fd = odb_mkstemp(&amp;tmp_file, &quot;pack/tmp_bitmap_XXXXXX&quot;);</pre><pre>    f = hashfd(fd, tmp_file.buf);<br>    cf = init_chunkfile(f);</pre><pre>    add_chunk(cf, BITMAP_TYPE_INDEXES,<br>              compute_pt_serialize_type_indexes_size(ctx),<br>              write_bitmap_type_indexes);</pre><pre>    add_chunk(cf, BITMAP_REACHABILITY_BITMAPS,<br>              compute_pt_serialize_commit_bitmap_sec_size(ctx),<br>              write_reachability_roaring_bitmaps);</pre><pre>    add_chunk(cf, BITMAP_HASH_CACHE_SECTION,<br>              compute_hash_cache_size(ctx.hash_cache),<br>              write_hash_cache);</pre><pre>    add_chunk(cf, BITMAP_LOOKUP_TABLE,<br>              compute_bitmap_lookup_table_size(ctx.lookup_table),<br>              write_lookup_table);</pre><pre>    write_bitmap_header();<br>    write_chunkfile(cf, ctx);<br>}</pre><h4>Lookup table failing test case</h4><p>As you can see in my previous blog, Johannes informed me that one particular test case under SHA-256 is failing. One thing to note here that this test do not always fail. Sometimes it passes without any effort or any change in the code. In fact, there were moments when I thought the problem had gone — because it was passing every time I invoke the test script. Later I found that this is not related to my code i.e. it can be reproduced without my changes.</p><p>I reformatted the test code so that the same tests can be run again with some particular configuration enabled. So I wrapped all existing tests in a function and called the function twice — one with no additional configuration set and another with lookup table enabled. I noticed that that test case is always failing on the second call. So initially I thought my changes were not correct. But Johannes told me that it is not the case.</p><p>Johannes also gave me some inputs to start my investigation. Those are really helpful and some of his testing techniques were new to me. So, I learnt a lot from that.</p><p>When I digged deeper I found that the problem starts from setup partial bitmaps test case. Below is the test code -</p><pre>test_expect_success &#39;setup partial bitmaps&#39; &#39;<br>    test_commit packed &amp;&amp;<br>    git repack &amp;&amp;<br>    test_commit loose &amp;&amp;<br>    git multi-pack-index write --bitmap 2&gt;err &amp;&amp;<br>    test_path_is_file $midx &amp;&amp;<br>    test_path_is_file $midx-$(midx_checksum $objdir).bitmap<br>&#39;</pre><p>If I comment out the line git repack &amp;&amp;, all tests pass successfully. I noticed that midx file is not getting updated in that case. So it is more likely that git multi-pack-index write --bitmap 2&gt;err &amp;&amp; is causing this failure.</p><p>I started to look into the bitmap code using some debugging lines. But I didn’t see anything suspicious. As I said before, test sometimes passes successfully. So, I thought that it would be helpful if I can get both the directories (i.e. failing and passing). In that case I could compare the pack files, .bitmap files and midx files and then see if anything wrong happening in the failing directory.</p><p>After comparing the files, I found that multi-pack-index file and its corresponding .bitmap file of these two directories are different. The difference starts from midx’s RIDX chunk. I thought midx code might have a bug which is causing this failure. But later I found the this is due to different pack preferences (caused by mtimes). So the point is midx file difference is not the root cause.</p><p>Derrick suggested that calling oe_map_new_pack() might be the cause of this problem. Because the C-doc comment of that function says that calling this function could be a race.</p><p>As I am not very familiar to midx code, I had to understand the code. After understanding the whole workflow I found that the newer pack files (which are not part of the old midx) are loaded differently than the older pack files (which are part of the old midx). We use write_midx_context structure to put all the important information required to build a new midx as a context. This includes both the newer packs and older packs. For each old pack ctx (an instance of write_midx_context) stores a pointer to that pack (pointed by the_repository-&gt;objects-&gt;packed_git). Whereas for newer packs, ctx doesn’t use the_repository&#39;s pack. Instead it stores another instance of that pack.</p><p>Git works with packs pointed by the_repository-&gt;objects when preparing packing_data for writing a new .bitmap file. Whereas it uses packs pointed by ctx to actually write the .bitmap file. This is the reason for calling oe_map_new_pack() function.</p><p>It might be the root cause but I am not 100% sure. May be I need to investigate further. But one thing I can assure you that we are very near to find out the root cause.</p><p>For now I can’t spend much time on it as I have my exam on 18 Aug. I have to prepare myself for that. I hope that I can write about the fix of the failure in the next blog :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30bc623cb4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC Week 7: improving Performance tests]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-7-improving-performance-tests-ea9bfa180775?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea9bfa180775</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Tue, 02 Aug 2022 13:36:43 GMT</pubDate>
            <atom:updated>2022-08-02T13:52:51.292Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello again readers, this is my week 7 work update. In this week I work further on Git specific CRoaring fixtures. Besides, there were another round of review on my bitmap-lookup-table patch series. So I worked on that also.</p><h4>Roaring bitmap related progress</h4><p>Firstly, I am gonna talk about my roaring bitmap progress. I previously integrated CRoaring into Git using their amalgamation.sh script. It combines all the library code files (and header files) into two files — roaring.c and roaring.h. This is good because all the roaring logics will be compiled into a single unit causing faster performance. But this has a downside too — I have to modify those files whenever I want to build some Git specific functions. This is because all the internal library files (i.e. the functions other than what CRoaring API provides in roaring.h) are present in roaring.c.</p><p>Truly speaking, this is not a problem because CRoaring is under MIT license. But I would have been more happy if I could put those Git specific functions in a separate file called roaring_git.c and then import roaring_git.h everywhere (instead of roaring.h). roaring_git.h would contain all the Git specific functions as well as the built in CRoaring functions. But as I said before, this is not easy to do. I have to move all the roaring internal functions (in order to use them) out from amalgamated roaring.c to another file (may be roaring_internals.c) and then use them in roaring_git.c. I tried this but it was a tedious job and it needs more time. Even I am not sure whether it can be possible or not.</p><p>So, for now I wrote all Git specific functions in roaring.c file. As Taylor told me — we first need to check whether roaring bitmaps really create an impact in performance. With these functions roaring bitmaps can now be stored in network byte order which means it can work in big-endian systems also.</p><h4>Bitmap-lookup-table v5 progress</h4><p>As I said before, there are some reviews for bitmap-lookup-table series. Performance tests that I wrote previously was not accurate. Because the second call to test_bitmap is always working on the previously repacked repo, causing the the performance of the second call much faster than the previous one.</p><p>One solution to this problem would be to setup the repo in the function itself and remove it accordingly. For example, this is the updated test -</p><pre>#!/bin/sh</pre><pre>test_description=&#39;Tests pack performance using bitmaps&#39;<br>. ./perf-lib.sh<br>. &quot;${TEST_DIRECTORY}/perf/lib-bitmap.sh&quot;</pre><pre>test_lookup_pack_bitmap () {</pre><pre>  test_expect_success &quot;setup repo environment&quot; &#39;<br>    rm -fr * .git<br>  &#39;</pre><pre>  # setup a large repo<br>  test_perf_large_repo</pre><pre>  test_expect_success &#39;setup bitmap config&#39; &#39;<br>    git config pack.writebitmaps true<br>  &#39;</pre><pre>  test_expect_success &#39;create tags&#39; &#39;<br>    git tag --message=&quot;tag pointing to HEAD&quot; perf-tag HEAD<br>  &#39;</pre><pre>  test_perf &quot;enable lookup table: $1&quot; &#39;<br>    git config pack.writeBitmapLookupTable &#39;&quot;$1&quot;&#39;<br>  &#39;</pre><pre>  test_pack_bitmap<br>}</pre><pre>test_lookup_pack_bitmap false</pre><pre>test_lookup_pack_bitmap true</pre><pre>test_done</pre><p>But still it seems that the results are not accurate. The results are differing in subsequent test runs.</p><p>So, the next option that came to my mind was creating a new file for every test cases (i.e. lookup table enabled and lookup table disabled). With this, the results are guaranteed to be accurate. Moreover, one can edit/modify a particular file according to their need without adding those cases (because that may not make sense with other configurations) in other files(i.e. let’s say where lookup table is enabled). I am currently work on it.</p><p>While submitting the previous version, I noticed that a test case was failing (see my previous blog to know about that). At that time I thought this was fixed in the lastly submitted patch series (because all CI/CD tests were passing). But later Johannes informed me that that test case under t5326-multi-pack-bitmaps.sh and t5327-multi-pack-bitmaps-rev.sh is failing. Below is the error message -</p><pre>Cloning into bare repository &#39;clone.git&#39;...<br>remote: Enumerating objects: 756, done.<br>remote: Counting objects: 100% (754/754), done.<br>remote: Compressing objects: 100% (281/281), done.<br>remote: Total 756 (delta 245), reused 740 (delta 234), pack-reused 2<br>Receiving objects: 100% (756/756), 77.50 KiB | 8.61 MiB/s, done.<br>fatal: REF_DELTA at offset 221 already resolved (duplicate base 4d332072f161629ffe4652ecd3ce377ef88447bec73f05ab0f3515f98bd061cf?)<br>fatal: fetch-pack: invalid index-pack output<br>error: last command exited with $?=128<br>not ok 319 - clone from bitmapped repository<br>#<br>#                       rm -fr clone.git &amp;&amp;<br>#                       git clone --no-local --bare . clone.git &amp;&amp;<br>#                       git rev-parse HEAD &gt;expect &amp;&amp;<br>#                       git --git-dir=clone.git rev-parse HEAD &gt;actual &amp;&amp;<br>#                       test_cmp expect actual<br>#</pre><p>Now it is quite mysterious for me. Because it is only failing when GIT_TEST_DEFAULT_HASH=sha256. It is passing in all other cases. I looked into it further and found that this is not related to lookup-table implementation code at all. Rather the test script itself is somehow causing this problem.</p><p>I was not able to work much in the last 3–4 days as I was busy in hostel room shifting. So, I didn’t get enough time to investigate it.</p><p>I hope that I will figure out the problem soon and hopefully able to submit my next version (hopefully the final version) in the next day or two.</p><p>Thanks :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea9bfa180775" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC Week 6: using CRoaring library]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-6-using-croaring-library-be309cfa89f5?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/be309cfa89f5</guid>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Mon, 25 Jul 2022 14:25:29 GMT</pubDate>
            <atom:updated>2022-07-25T14:25:29.156Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my week 6 update for GSoC. You may notice I didn’t post my week 5 update. So, in this post, I will cover all my updates during this time.</p><p>In the last week, My <a href="https://lore.kernel.org/git/pull.1266.v4.git.1658325913.gitgitgadget@gmail.com/">lookup-table-extension patch series</a> got some reviews from Taylor and Martin. These are mainly some small improvements.</p><p>I submitted a patch version after that. But as you can see in <a href="https://github.com/Abhra303/git/runs/7430382082?check_suite_focus=true">Github Actions CI/CD</a> test, some tests under linux-256 were failing. So, <a href="https://lore.kernel.org/git/pull.1266.v5.git.1658342304.gitgitgadget@gmail.com/">here</a> is my latest version which addressed all the suggestions.</p><h4><strong>CRoaring in Git?</strong></h4><p>As you already know that one of my GSoC projects is about integrating roaring bitmaps in Git, I started to work on it. I first started to look into <a href="https://github.com/RoaringBitmap/CRoaring">CRoaring</a> — a builtin C library to implement Roaring bitmaps. Though this library has all the things I need to implement roaring bitmaps, I noticed few shortcomings also. These are -</p><ol><li>It doesn’t serialize bitmaps in network byte order.</li><li>We need to use the hashwrite() function for writing bitmaps in the file.</li><li>It supports only uint32_t (not uint64_t) integers for storing in<br>bitmaps. Right now, we don’t need uint64_t integers and it seems that our current EWAH implementation also support upto 2³² objects for a bitmap. But I am thinking that the number of objects might increase as time passes and what if the number of objects exceed the limit of uint32_t?</li></ol><p>For these reasons, I was not able to decide whether I should use CRoaring or not. So, I reached out to my mentors. Taylor said that these might not be a problem given that CRoaring have a compatible license.</p><p>There was another problem of using CRoaring. It didn’t have a Git Compatible license. I posted it to the mailing list (as suggested by mentors). After a lot of discussions, it was decided that we should first reach out to the authors of CRoaring and request them to relicense it else we will re-implement it. I reached them and they agreed to relicense it under MIT (which is compatible with Git).</p><h4>Git specific changes of CRoaring</h4><p>Though we are now free to use CRoaring, we can’t use it without any Git specific changes. For example, CRoaring library do <a href="https://groups.google.com/g/roaring-bitmaps/c/CzLmIRnYlps">not support</a> Big endian systems. So, I need to make some changes here to fix it.</p><p>I am thinking of using network byte order to store the bitmap on disk (rather than CRoaring’s little endian format). Because our existing .bitmap format header and extensions use network byte order. It makes no sense if we continue to store header and extensions in network byte format and bitmaps in little endian format.</p><p>I have already implemented the roaring_portable_network_serialize and roaring_portable_network_deserialize. The serialization format remains the same but it is stored in network byte order. Below is the code snippet -</p><pre>int roaring_portable_network_serialize(struct roaring_bitmap_t *rb, int (*write_fn) (void *, const void *, size_t), void *data)</pre><pre>{<br>    struct roaring_array_t *ra = rb-&gt;high_low_containers;<br>    uint32_t initial_offset;<br>    uint32_t cookie;<br>    if (ra_has_run_container(ra)) {<br>        uint8_t *bitmap_of_run_containers = NULL;<br>        size_t bitmap_run_container_size = (ra-&gt;size + 7) / 8;<br>        cookie = SERIAL_COOKIE | (ra-&gt;size - 1) &lt;&lt; 16);<br>        if (write_fn(data, htonl(cookie), 4) != 4)<br>            return -1;<br>        initial_offset = sizeof(cookie);<br>        CALLOC_ARRAY(bitmap_of_run_containers, bitmap_run_container_size);</pre><pre>        for (uint32_t i = 0; i &lt; ra-&gt;size; i++) {<br>            if (get_container_type(ra-&gt;containers[i], ra-&gt;typecodes[i]) == RUN_CONTAINER_TYPE)<br>                bitmap_of_run_containers[i / 8] |= (1 &lt;&lt; (i % 8));<br>        }</pre><pre>        for (size_t i = 0; i &lt; bitmap_run_container_size; i++) {<br>            if (write_fn(data, bitmap_of_run_containers[i], 1) != 1) {<br>                free(bitmap_of_run_containers);<br>                return -1;</pre><pre>             }<br>        }</pre><pre>        free(bitmap_of_run_containers);<br>        initial_offset += bitmap_run_container_size;<br>    } else {<br>      cookie = SERIAL_COOKIE_NO_RUNCONTAINER | (ra-&gt;size - 1) &lt;&lt; 16;<br>      if (write_fn(data, htonl(cookie), 4) != 4)<br>          return -1;<br>      initial_offset = sizeof(cookie);<br>    }</pre><pre>    /* description table */<br>    for (uint32_t i = 0; i &lt; ra-&gt;size; i++) {<br>        uint16_t card;<br>        if (write_fn(data, htons(ra-&gt;keys[i]), sizeof(ra-&gt;keys[i])) != sizeof(ra-&gt;keys[i]))<br>            return -1;<br>        card = (uint16_t)(container_get_cardinality(ra-&gt;containers[i], ra-&gt;typecodes[i]) - 1);<br>        if (write_fn(data, htons(card), 2) != 2)<br>            return -1;<br>    }<br>    initial_offset += 4 * ra-&gt;size;</pre><pre>    if ((!hasrun) || (ra-&gt;size &gt;= NO_OFFSET_THRESHOLD)) {<br>        initial_offset += 4 * ra-&gt;size;<br>        // writing the containers offsets<br>        for (int32_t k = 0; k &lt; ra-&gt;size; k++) {</pre><pre>            if (write_fn(data, htonl(initial_offset), sizeof(initial_offset) != sizeof(initial_offset))<br>                return -1;<br>        initial_offset += container_size_in_bytes(ra-&gt;containers[k], ra-&gt;typecodes[k]);<br>        }<br>    }</pre><pre>    for (int32_t k = 0; k &lt; ra-&gt;size; ++k)<br>        container_network_write(ra-&gt;containers[k], ra-&gt;typecodes[k], data, write_fn);<br>}</pre><h4>Next step</h4><p>My next goal is to use CRoaring functions in Git’s codebase. I will submit the patch series soon. Thanks :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be309cfa89f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC week 4: diving into roaring bitmaps]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-4-diving-into-roaring-bitmaps-f028f931d873?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/f028f931d873</guid>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Mon, 11 Jul 2022 13:52:19 GMT</pubDate>
            <atom:updated>2022-07-11T13:52:19.608Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last week, I submitted my latest patch series for lookup-table-extension. There were no major reviews since then. I think the patch series will get some reviews this week.</p><p>One thing I realised after receiving <a href="https://lore.kernel.org/git/pull.1266.v2.git.1656249017.gitgitgadget@gmail.com/T/#mff69f1f6c7526752a97c093bbf6ac655289c0d87">Philip’s comment</a> is Git does not have its own document file to explain reachability bitmaps. If you want to know about the background of reachability bitmaps along with its workings, you may have to go to the following Github blog links — <a href="https://github.blog/2015-09-22-counting-objects/">Counting objects</a> and <a href="https://github.blog/2021-04-29-scaling-monorepo-maintenance/">scaling monorepo maintenance</a> (Bitmaps were introduced by Github devs). So, I am thinking of submitting a patch to explain the workings of bitmaps. I don’t want to write this explanation in technical/bitmap-format.txt as it is only about bitmap format. Better would be to make a new file named technical/reachability-bitmaps.txt and then write these details in that file.</p><p>This week I spent my time on diving more into <a href="https://github.com/RoaringBitmap/CRoaring">Croaring</a>. I tried to understand how they work internally, the available functions they offer, their serializing format etc. I think it is important to know about these things before starting my work.</p><p>The <a href="https://github.com/RoaringBitmap/RoaringFormatSpec/">serialisation format</a> (for one bitmap) seems fine to me but still I want to know Kaartic and Taylor’s opinions. Another thing I noticed here is that each roaring bitmaps are designed to store sets of 32-bit (unsigned) integers. Thus a Roaring bitmap can contain up to 4294967296 integers. I am not sure if this is sufficient for us.</p><p>That’s all for this week. My next step is to make the new bitmap format version 2(with roaring bitmaps) and modify rest of the code so that those code can accept the new bitmap format version.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f028f931d873" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC Week 3: working on further improvements]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-3-working-on-further-improvements-13a27db64cd5?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/13a27db64cd5</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Mon, 04 Jul 2022 19:19:17 GMT</pubDate>
            <atom:updated>2022-07-04T19:19:17.019Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous week, I submitted second version of my patchset and as you might know that that version contain some major changes like redesigning the lookup table format, switching to iterative approach for parsing xor bitmaps etc (See my <a href="https://medium.com/@abhra303/gsoc-week-2-redesign-the-table-format-829dae755a5">previous blog</a> for details).</p><p>In this week, I mostly worked on improving the patchset further. Taylor and Derrick gave some suggestions on the second version. These are listed below:</p><h4>Getting reviews for the second version</h4><ul><li><strong>Improve the documentation and fix typos:</strong><br>Documentation that I wrote for the lookup table was difficult to parse and it didn’t give any information about the sorting order of the triplets in the lookup table. Besides this, Some of the commits didn’t have Signed-off-by trailer at the end of the message body. There were also some typos in the log messages.</li><li><strong>Add comments:<br></strong>That version did not have much comments to explain some parts of the code. It might be better to include some comments.</li><li><strong>Disable the </strong><strong>pack.writeBitmapLookupTable configuration by default:<br></strong>pack.writeBitmapLookupTable was by default true in the second version. Derrick suggested to make it false for now.</li><li><strong>Fix indentations:</strong><br>There were some indentation issues in the performance test files and in the pack-bitmap.c, pack-bitmap-write.c files.</li><li><strong>Make a </strong><strong>bitmap_lookup_table_triplet struct:</strong><br>If you observe the lazy_bitmap_for_commit() function (in my v2 <a href="https://lore.kernel.org/git/4fbfcff8a208798146cd561b0185e094a116cf0e.1656249017.git.gitgitgadget@gmail.com/">patch</a>), you’ll see that this function uses triplet_get_offset() and triplet_get_xor_pos(). These functions are used to get the offset and xor_row position (respectively) for a particular triplet. Taylor suggested that instead of using these functions, we could make a struct type named bitmap_lookup_table_triplet and use it to get the commit_pos, offset and xor_row. Below is the definition -</li></ul><pre>struct bitmap_lookup_table_triplet {<br>    uint32_t commit_pos;<br>    uint64_t offset;<br>    uint32_t xor_row;<br>};</pre><ul><li><strong>Subtract the </strong><strong>table_size from </strong><strong>index_end irrespective of the value of </strong><strong>GIT_TEST_READ_COMMIT_TABLE:</strong><br>Till the v2 patchset, lookup table size was subtracted from index_end only if the bitmap file has lookup table and GIT_TEST_READ_COMMIT_TABLE is either unset or set to 1. Taylor pointed out that we should subtract the table size if the bitmap has lookup table (i.e. this operation shouldn’t depend on GIT_TEST_READ_COMMIT_TABLE). Below is the suggested code -</li></ul><pre>if (flags &amp; BITMAP_OPT_LOOKUP_TABLE) {<br>    ...<br>    if (git_env_bool(&quot;GIT_TEST_READ_COMMIT_TABLE&quot;, 1))<br>        index-&gt;table_lookup = (void *)(index_end - table_size);<br>    index_end -= table_size;<br>}</pre><h4>Implementing the suggestions</h4><p>My primary goal was to address all of these comments in my next version. So, I first worked on fixing the docs, log messages and then moved to implementing the suggested changes. I changed the type of offsets array (in pack-bitmap-write.c file; array to store the offsets of the bitmaps) from uint64_t * to off_t * (as suggested by Taylor).</p><p>After implementing all the suggested changes, I started working on the idea that I mentioned as my next step in my previous blog. By the way, Derrick suggested the same thing in his <a href="https://lore.kernel.org/git/cebad3da-5779-5908-15d5-63d4c590c20b@github.com/">comment</a>. The idea is to stop the xor stack filling loop (in the lazy_bitmap_for_commit() function) if the current xor bitmap is already stored and assign xor_bitmap to it. As this bitmap is already stored/parsed, we don’t need to iterate further as we know all the other bitmaps that are needed to parse this bitmap has already been stored.</p><p>Here is the condition to break the loop -</p><pre>khiter_t hash_pos;<br>...<br>while (xor_row != 0xffffffff) {<br>    ...<br>    hash_pos = kh_get_oid_map(bitmap_git-&gt;bitmaps, xor_oid);<br>    if (hash_pos &lt; kh_end(bitmap_git-&gt;bitmaps) &amp;&amp;<br>        (xor_bitmap = kh_value(bitmap_git-&gt;bitmaps, hash_pos)))<br>        break; /* bitmap is already parsed */<br>    ...<br>}</pre><p>Another thing to mention that this stack is dynamically allocated array. The v2 patchset allocates a bitmap_git-&gt;entry_count size of array which is unnecessary because we know that size of xor_chains is generally far less than bitmap_git-&gt;entry_count. So, Taylor and Derrick suggested to allocate a smaller array and then grow if necessary.</p><p>Now it was time to test things. I reformatted the test code ( t5310-pack-bitmaps.sh and t5326-multi-pack-bitmaps.sh) to support repeating tests with bitmap extension. I wrote some test cases to verify that all are going well.</p><p>Here is the third version of the patch series — <a href="https://lore.kernel.org/git/pull.1266.v3.git.1656924376.gitgitgadget@gmail.com/">https://lore.kernel.org/git/pull.1266.v3.git.1656924376.gitgitgadget@gmail.com/</a></p><h4>Next Step</h4><p>I got to know from Taylor that Github is closed for this week (so he’ll be taking a break). So I think Derrick and Taylor will not give any feedback during this time.</p><p>My next job is to research and work on implementing backward compatible Roaring-run bitmaps. Though this would be a rough work for now. My main goal is to first run performance tests and check whether it is worthwhile to submit to the mailing list.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13a27db64cd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC Week 2: redesign the table format]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-2-redesign-the-table-format-829dae755a5?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/829dae755a5</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Mon, 27 Jun 2022 12:15:09 GMT</pubDate>
            <atom:updated>2022-06-27T12:15:09.579Z</atom:updated>
            <content:encoded><![CDATA[<p>If you saw my previous blog <a href="https://medium.com/@abhra303/gsoc-week-1-lets-get-started-fad78ec34dcf">GSoC Week 1: Let’s get started</a>, you know that I am working on integrating a lookup table extension to Git’s bitmap file. It would remove the overhead of loading each and every bitmap by parsing only the necessary bitmaps.</p><p>I submitted my initial version of patch series on last Monday (IST). After that, a series of review came. Some of these reviews suggested major changes which I am listing down below. But before that, let us recap the table format first -</p><p>The initial table format contain a list of commit oids (for each bitmap entry), a list of &lt;offset, xor_pos&gt; pairs (for each bitmap entry). The i’th &lt;offset, xor_pos&gt; pair denotes the bitmap position and xor-commit position (respectively) of the i’th commit id in the list. By saying xor-commit position, I mean the position of the commit oid (in the commit id list) with whose bitmap the current commit’s bitmap need to xor.</p><p><strong>Fact:</strong> I know if you’re a non Git developer, you probably are not getting what I just have said ;). Don’t worry, I will surely make detailed articles on Git internals later so that you can also take part in the contribution of Git! For now, read the <a href="https://git-scm.com/book/en/v2">ProGit book</a>.</p><h4><strong>Major changes suggested in the review comments</strong></h4><ul><li><strong>Use commit positions instead of commit oids in the table:</strong><br>Commit ids are of 8 bytes and are used here to know which bitmap belongs to which commit. So, the table size becomes Nr_entries * (8+ 4+ 4) bytes. We can save some spaces if we can store the midx or pack-index position (4 byte) of the commit instead of storing the commit ids. This would save Nr_entries * 4 bytes.<br>At first, I thought this would add extra cost — We first have to get the index position of given commit, match that with the list of commit positions in the table and then get the offset of that commit. But Taylor said, this would be negligible and I should try it.</li><li><strong>Use 8 byte offset positions instead of 4 byte:</strong><br>The initial version uses 4 byte offsets which might not be sufficient for holding the bitmap positions. So, Derrick ( GSoC mentor for another Git project named More Sparse Index Integrations) and Taylor suggested to make it a 8 byte unsigned integer instead.</li><li><strong>Use iterative approach for parsing xor bitmaps:</strong><br>There were two functions stored_bitmap_for_commit() and lazy_bitmap_for_commit() which were being used recursively to find the xor bitmaps. Derrick suggested to use a stack instead. The logic is someting like this — For every xor_pos, push the commit positions to the stack and finally pop them one by one. For each popped positions use the previous bitmap as xor_bitmap and compute the current bitmap.</li><li><strong>Use </strong><strong>&lt;commit-pos, offset, xor_pos&gt; triplets:</strong><br>In the initial version, the table first has a list of commit oids and then the list of &lt;offset, xor_pos&gt; pairs. Taylor suggested to redesign the table such that all the related information come together forming a triplet. E.g. instead of having two separate lists (one for commit ids, and another for &lt;offset, xor_pos&gt; pairs), the table now contains a single list of commit-pos, offset, xor_pos&gt; triplets. The i’th triplet contains the information of the i’th bitmap.</li></ul><p>Besides this, there were some other reviews also but those are relatively small. So I didn&#39;t include them here.</p><h4>Implementing the suggestions</h4><p>My first job was to redesign the table. I started implementing the “<strong>writing table to the bitmap</strong>” part. I didn’t face any problem regarding it since most of the implementations are same as the initial version. The tricky part here was to get the commit positions given the commit ids. As I am relatively new in the community, I didn’t know what functions are available for it. But after some investigation, I suddenly remembered that bitmaps already store the commit positions. So I could store those positions into an array and pass it to the write_lookup_table() function! Thus I got what I wanted!</p><p>Then I moved to the read part. It was the most time consuming task for this week. I had to rewrite the patch itself. During this time I realized that the previous version had some bugs in it. E.g. the store_bitmap() function throws a Duplicate entry in bitmap index error whenever it sees an already stored bitmap is trying to be stored again. This error is obvious if all the bitmaps are getting parsed one by one. But in our case, we are trying to parse only the necessary bitmaps. So in this process this may happen that a bitmap has already been parsed and another bitmap has a xor relation with it. Whenever we get to this bitmap from the bitmap that has a xor relation with it (using iterative approach we discussed previously), store_bitmap is throwing the above error and is returning NULL. Below is my fix:</p><pre>/* A 0 return code means the insertion succeeded with no changes,<br> * because the SHA1 already existed on the map. If lookup table<br> * is NULL, this is bad, there shouldn&#39;t be duplicated commits<br> * in the index.<br> * If table_lookup exists, that means the desired bitmap is already<br> * loaded. Either this bitmap has been stored directly or another<br> * bitmap has a direct or indirect xor relation with it. */</pre><pre>if (ret == 0) {<br>  if (!index-&gt;table_lookup) {<br>   error(&quot;Duplicate entry in bitmap index: %s&quot;, oid_to_hex(oid));<br>   return NULL;<br>  }<br>  return kh_value(index-&gt;bitmaps, hash_pos);<br>}</pre><p>I also converted the previously implemented recursive search into a iterative parsing. The process was not smooth — I faced many errors here. Some of them were fixed quickly, some of them took two or three days to fix. But at the end, all was finally fixed and was ready for another round of review. Here is the latest <a href="https://lore.kernel.org/git/pull.1266.git.1655728395.gitgitgadget@gmail.com/T/#mca393f0ff1a09d3facc2ea2f8f879704abf9b33b">patch series</a>.</p><p>I think this format is way simpler and more structured than the previous one. Huge shoutout to Taylor for suggesting this format!</p><h4>Next step</h4><p>While writing the blog, I realised that I could optimise the parsing process further. The idea is — when we are filling the xor commit positions into the stack , if somehow we can know that the bitmap belonged to the current commit position has already been stored, we don’t need to iterate further for xor positions. Because we know that those bitmaps has been stored already. This way, we can stop unnecessary iterations.</p><p>So my next step is to implement the above idea and to resubmit it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=829dae755a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC Week 1 : Let’s get started]]></title>
            <link>https://medium.com/@abhra303/gsoc-week-1-lets-get-started-fad78ec34dcf?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/fad78ec34dcf</guid>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Sun, 19 Jun 2022 14:28:20 GMT</pubDate>
            <atom:updated>2022-06-20T08:38:18.552Z</atom:updated>
            <content:encoded><![CDATA[<h3>GSoC Week 1 : Let’s get started</h3><p>Hello readers, it’s about a week now the GSoC coding period has started. So, here is the first weekly update about my progress. From this onwards, I will post GSoC blogs every week.</p><p>But before that, let me give a summary of my project so that non git developers can also catch the logic of the project.</p><h4>Git Reachability bitmaps</h4><p>Whenever you run the command git fetch(or similar), git server first decides which objects it have to send. If you don’t know what is a git object, please refer to <a href="https://git-scm.com/book/en/v2/Git-Internals-Git-Objects">git objects</a>. These objects are connected to each other forming a <a href="https://en.wikipedia.org/wiki/Directed_acyclic_graph">directed acyclic graph</a>. Each node of this graph is an object.</p><p>The git client and deamon compares their branch tips and decides which ones to send. As git only know about the branch tips, there is no way for git to know about the desired objects beforehand. So, it has to traverse down from the tips to all the objects connected directly or indirectly to it. This traversal goes till a known tip (i.e. the tip which the client already has) has found.</p><p>In case of git clone , all the objects has to be fetched (assuming no partial-clone or shallow-clone). So, the git deamon has to traverse all the objects connected directly or indirectly to the branch tips till the last object. The traversal is necessary in order to restrict any non-reachable objects from sending to the client.</p><p>For small repositories, this might not be a great deal. But things become crazy, when the repository is quite huge (e.g. linux kernel or git itself).</p><p>To tackle the problem, reachability bitmaps were introduced. The idea is to store a bitmap for every selected commits in a .bitmap file and then refer to it whenever a revision is needed. Reachability bitmaps are arrays that store 1 and 0s. Each index of this array denotes a particular object. So, if a bitmap for a particular commit has the value 1 in the i’th index, it means the object denoted by the i’th index can be reachable from the commit. <a href="https://github.blog/2015-09-22-counting-objects/">Counting objects </a>has more info if want to know more.</p><p>My project is to improve the performance of the reachability bitmaps. See the <a href="https://summerofcode.withgoogle.com/programs/2022/projects/UPtA6qdf">GSoC project</a> to know more.</p><h4>Community Bonding period</h4><p>Community bonding period was really good. I asked a lot of doubts to the mentors during the community bonding period. Thanks to the mentors — they helped me tremendously to clear all the doubts. During this time, we realized that the current <a href="https://github.com/git/git/blob/master/Documentation/technical/bitmap-format.txt">Documentation/technical/bitmap-format.txt</a> has a missing information — it does not say about the trailing checksum at the end of the .bitmap file.</p><p>The file had some other issues also. It was not passing to the asciidoc html generator and the formatting was not suitable for generating a good formatted html page.</p><p>So, I wrote a <a href="https://lore.kernel.org/git/pull.1246.v4.git.1655355834.gitgitgadget@gmail.com/">patch series</a> fixing all the three issues. These patches are integrated into next and hopefully be merged into master soon.</p><h4>My first task: adding a “lookup table extension” in the bitmap format</h4><p>During the bonding period, my mentor suggested that instead of working on ewah -&gt; roaring bitmap conversion first, I should start with integrating a “lookup table extension” as this task is simpler and smaller compared to other tasks. So, I started working on it. The idea is to have a table at the end of .bitmap file which will contain the offsets (and xor-offsets) of the bitmaps of selected commits. Whenever git try to get the bitmap of a particular commit, instead of loading each bitmaps one by one and then find the desired bitmaps from them, git will parse only the desired bitmap by using the offset and xor-offset of the table. This will reduce the overhead of loading each and every bitmap.</p><p>The proposed table contains the following things:</p><ul><li>N object ids where N is the number of selected commits.</li><li>A list of &lt;`offset`,`xor-offset`&gt; pair (4-byte each; network byte order). The i’th pair denotes the offset and xor-offset(respectively) of the the bitmap denoted by the i’th object id in the previous list.</li><li>A 4-byte integer(network byte order)to denote the flags (currently no such flags).</li></ul><p>As the implementation was already done by Taylor (one of my mentors), all I had to do was fixing some of the implementation code and adding tests. The tests include both performance tests and integration tests.</p><p>This week was a little slow for me. It was mainly for two reasons —</p><ol><li>I was facing some problems to setup the environment for performance testing. For some reason, some objects was missing from git checkout. This resulted the failure of all the bitmap performance tests (as bitmaps need full closure). Taylor helped me to solve the issue. I also downloaded a local copy of linux kernel for testing purpose.</li><li>I was thinking if we can optimize it further.</li></ol><p>The patch series is nearly ready for review. I will submit it by today or tomorrow.</p><h4>Difficulties</h4><p>I didn’t get the particular case refered by the <a href="https://github.com/Abhra303/git/blob/f5f725a3fe2ac0c93088c48ac520303a3df2c83d/pack-bitmap.c#L704">NEEDSWORK comment</a> (written by Taylor). I want to work on that before submitting it to the mailing list.</p><h4>Next step</h4><p>The next step is to submit the patch series to the mailing list and make changes according to the review comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fad78ec34dcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a security best practices policy for Datree]]></title>
            <link>https://medium.com/@abhra303/writing-a-security-best-practices-policy-for-datree-a564eec97d51?source=rss-a8b1cb4436df------2</link>
            <guid isPermaLink="false">https://medium.com/p/a564eec97d51</guid>
            <category><![CDATA[security-best-practices]]></category>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[datree]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Abhradeep Chakraborty]]></dc:creator>
            <pubDate>Tue, 18 Jan 2022 15:27:12 GMT</pubDate>
            <atom:updated>2022-01-18T15:27:12.188Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently contributed to <a href="https://datree.io/?utm_source=blog&amp;utm_medium=influencer&amp;utm_campaign=chakraborty">Datree</a> regarding the security best practices one should follow while managing Kubernetes manifest files and clusters. In this article, I will share why I chose security to work on and my experience while contributing to Datree. It will also help you to understand security best practices. Enjoy :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GUTkDel9jIZ4jIIhdFYsmw.png" /><figcaption>Datree — image taken from <a href="https://github.com/datreeio/datree">here</a></figcaption></figure><h4>Why I chose Security Best Practices to work on?</h4><p>A security breach in any kind of software is a headache for maintainers as well as users. Having security breaches in K8s clusters is one of the biggest threats to any organization. You may manage to make your cluster cost efficient, highly scalable, production ready, etc., but if your cluster is not secure, you’ll could be in deep trouble. A black-hat hacker could easily attack your cluster, modify your hard-earned data and who knows what else they can do to your cluster?</p><p>That’s why I always give top priority to security. Once you make your cluster secure, you can do whatever you like — make your cluster fast, reliable, cost-efficient, etc.</p><p>As you all might know, <a href="https://datree.io/?utm_source=blog&amp;utm_medium=influencer&amp;utm_campaign=chakraborty">Datree</a> is a tool that prevents misconfigurations and manages policies for K8s manifest files. So, I thought it would be great if Datree had a security related policy so that K8s admins can focus on managing clusters instead of thinking about security.</p><h4>K8s security best practices</h4><p>Now this is the most interesting part. I used to have very limited knowledge on Kubernetes. So at first, I struggled to find the security recommendations. But after researching a lot, I was able to write a security policy for Datree. Here it’s worth mentioning that Datree’s documentation for writing custom policy was also very helpful. If you want to have a look at that — go <a href="https://hub.datree.io/custom-rules">here</a>.</p><p>This topic is quite popular and there are many blogs, videos and stack-overflow discussions on security best practices for Kubernetes. But most of the discussions/articles have recommendations related to command-line and cluster objects (and few related to K8s manifest files). For example, enabling RBAC (or Role Based Access Control) is a security recommendation. But writing a rule that ensures every cluster has RBAC enabled is very hard, because you can’t get any idea about whether RBAC is enabled in your cluster just by seeing K8s manifest files. So, it was challenging for me to determine the recommendations for manifest files.</p><p>I read many blogs, articles and discussions from various professional bloggers, cloud providers and Kubernetes itself. I sorted recommendations for manifest files from there. For example, from this oracle <a href="https://docs.oracle.com/en-us/iaas/Content/Security/Reference/oke_security.htm">blog</a> I learned why it is important to “Use Image Digests Instead of Tags”. Another blog gave me some other use cases like “Ensure all capabilities are dropped”, “Ensure seccompProfile is set”, “Ensure imagePullPolicy set to Always”, etc. I discovered that PodSecurityPolicy is now deprecated so I decided to create a rule to ensure deprecated PodSecurityPolicy is not used in the manifest file.</p><p>I also watched many YouTube videos by CNCF, Google Cloud, etc. Most of the videos suggested these 3 things — “Ensure read only root file system is true”, “Ensure containers run with non root access” and “Ensure no new privileges are set”.</p><p>Lastly, I want to mention CIS Kubernetes Benchmark. CIS is an organization that studies software security and provides recommendations to ensure security. CIS Kubernetes benchmark publishes documents of K8s security related best practices. Those documents inspired additional ideas.</p><h4>Conclusion</h4><p>After a lot of research, I was finally able to make a policy for K8s security best practices. You can see the policy <a href="https://github.com/datreeio/datree/tree/main/examples/security-policy">here</a>.</p><p>The world is changing and so are hackers. They are always trying to find new ways to attack your cluster. So, you have to keep updating your K8s configurations and make sure your cluster configurations meet the current security standard.</p><p>That’s why it is important to use tools like Datree so your manifest files and your cluster are always up to date with current recommendations.</p><p>Hope this helps you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a564eec97d51" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>