HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
atomashpolskiy
bt
Java2016–2021
atomashpolskiy / bt

bt

BitTorrent library and client with DHT, magnet links, encryption and more

3Distinct people
18Mentions
1Explicit recommenders
2.5KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

BitTorrent library and client with DHT, magnet links, encryption and more

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

I'm the author and the only maintainer of Bt, Java 8 BitTorrent library: https://github.com/atomashpolskiy/bt. As of today, it has received 1136 stars. I've started it quite…

atomashpolskiy used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 8:03:49 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year18 dated mentions

Observed mentions: 2016-08-11 15:05:58 UTC to 2021-08-02 12:40:33 UTC.

02468102016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 2 mentions; 2 submissions, 0 comments20162017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 10 mentions; 6 submissions, 4 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2021

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC220
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC1064
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC211
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC101
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC110
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC202

What Hacker News says

1 sources
I'm not particularly proud of any code that I've wrote (looking back, all of it sucks in one way or another), so I'd rather share a piece of code, that I've written most recently (and maybe receive some constructive criticism, hehe). The piece of code that I'm speaking of is a variation of Bip Buffer, which itself is a special kind of ring buffer. Ring buffers, also called circular queues, are commonly used for producer-consumer scenarios. The main difference between a typical ring buffer and a Bip Buffer is that the former operates on distinct elements whereas the latter operates on contiguous data (e.g. binary streams). -- In short, Bip Buffer is backed by an array, which it splits into two regions: A and B. At first, there's only a single region A, and all incoming data is appended to it. Simultaneously, the data is consumed (stripped
Read the rest
off) from the beginning of the array, probably by some other process. Region's boundaries are updated as the data comes in and goes out (in FIFO fashion), so the region kind of floats from "left" to "right", akin to a sliding window, but shrinking and growing in lockstep. As the array gets more than half full (region A's right boundary crosses the halfway point of the array), it's a good time to start thinking about wrapping around. Since now, on each change to region A's boundaries the Bip Buffer compares free space on both sides of the region. As soon as there's more space to the left than to the right, a second region B is created there (on the left, i.e. in the beginning of the array). Now the newly arriving data is appended to B, but the old data is still consumed from A. This continues until one of two things happen: 1) B's right boundary hits A's left boundary. In this case no more data can be added to the buffer, so the producer has to wait until the consumer catches up. 2) All of A's data is consumed. Now there's only a single non-empty region left, namely B, so we may as well start calling it A and start over. -- This aside, my use case is a bit more complicated than just reading a continuous stream of data. I have a messaging system, where nodes exchange large quantities of data with each other. All communication goes through a single TCP connection, and this includes both service messages (like, requests for blocks of data and announcements about having finished downloading certain blocks of data) and the actual data. What I as a well-behaved peer want to be able to do is: (a) Be able to process actual data asynchronously, as there are multiple incoming streams, disk I/O, checksum verification, etc., and all of these contend with each other and generally take some time. (b) Process service messages as soon as possible (e.g. in case some peer, that happens to be sending me data, in the midst of the process sends me a request for some other data). In technical terms, I want to minimize latency of my peer's requests. A simple way to accomplish this would be to copy blocks of data into memory and enqueue them for delayed, asynchronous processing. This works pretty well for small amounts of data (tens of MB's per second), but has some limitations: - Some runtimes incur overhead for each allocated object. E.g. in JVM each object is prepended with several bytes of metadata; references to the object are accounted for for purposes of garbage collection; if asynchronous processing of the object is taking too long, it may be promoted (copied) to a different, long-lived part of the memory (and, depending on the load, "long" may actually mean 50 ms more than usual). - Copying takes time. Obviously, one copy from main memory to disk is absolutely necessary. NIC buffer can be mapped to main memory via DMA, if the OS supports it, or else it's one more copy. Why add yet another copy to application process's memory? -- So my idea is to tweak the Bip Buffer in such a way, that it can hold the data, that's going be processed asynchronously, while at the same time continuing to process next messages in the stream. Basically, it remembers, which areas of the buffer are "reserved" for delayed processing (and thus must not be overwritten), and goes on operating as usual and reading subsequent data, until it wraps around and hits the reserved data, and only then it stops. And if the data arrival rate is not too high, then chances are, the reserved data will already be processed and disposed of by the time the buffer wraps around. Link to code: https://github.com/atomashpolskiy/bt/blob/d0f10b7a306c7595ef... Please keep in mind, that it's a POC and was programmed in a single day, so there might be (must be?) some edge cases, that I did not think about, and the code style is a bit rushed (was too busy drawing pictures of this craziness and debugging :)
In Ask HN: What piece of code you wrote are you most pride of?

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.