HNHacker News
TopNewBestAskShowJobs

polyfractal

2,877 karma · joined May 17, 2011

Molecular and cellular neurobiologist turned software developer.

https://polyfractal.com

[ my public key: https://keybase.io/polyfractal; my proof: https://keybase.io/polyfractal/sigs/AvkaCfWRV93NjdW1RyX0-nQHgsP30ZvmbNkUdIbxidU ]

submissionscomments
polyfractal··on Rust on RTL8710 running FreeRTOS
Will do, thanks for the link! Didn't realize the Pine64 folks had a forum setup.

Fair warning, my hardware skills are shoddy at best, but I may be able to help with the Rust side :)

polyfractal··on Rust on RTL8710 running FreeRTOS
Ah, neat. Thanks for the analysis! I always assumed it was the transmit that ate the power, simply because you need `x` amount of energy to broadcast the signal out. But I can absolutely see how it's the circuitry associated with getting a signal back into digital that could be costly instead

TIL :)

polyfractal··on Rust on RTL8710 running FreeRTOS
Ah, yeah, I can see how that would have helped tremendously. Thanks for the tip! :)

I cringed when I saw this at the top of HN because I knew the shame that is my soldering skill would be seen by a few hundred people :)

polyfractal··on Rust on RTL8710 running FreeRTOS
Most people use these little things for sensor/data loggers (weather stations, power monitoring, indoor temperature, etc) or little widgets that need connectivity and can be tethered to a power outlet (small display showing the weather outside, etc)

The specs say it has 0.9 mA light sleep, and a 10 uA deep sleep. Assuming the specs are correct (I haven't test it yet... not sure anyone else has either) you could definitely run it off a battery if you aren't waking it up too often.

The real problem with the RTL8710 (and ESP8266, and any other chip that uses WiFi) is that WiFi is very energy intensive. It takes a lot of juice to blast out a 2.4Ghz signal.

I don't know what the numbers are for the RTL8710, but the ESP8266 uses 50-170mA when receiving/transmitting data, which will drain a battery very quickly. (Source: http://bbs.espressif.com/viewtopic.php?t=133)

polyfractal··on Rust on RTL8710 running FreeRTOS
That's why I quite like the approach of using existing C tooling and SDK, then linking in "user-land" Rust. I wanted to run stuff on the RTL8710, and it seemed crazy to start rewriting all the HAL from scratch.

But it only took an afternoon to bolt Rust into the C build because Rust's FFI story is really nice (imo). So I get the best of both worlds: existing C HAL and SDK with the pleasantness and safety of Rust.*

* With the assumption/hope that the HAL isn't buggy, since Rust will rely on that to not explode :)

polyfractal··on New MacBook Pro Is Not a Laptop for Developers Anymore
This is really just a war of opinions now, but the F1 keys are indispensable to me. My fingers rest on the hotkeys for "step into", "step over", "run to breakpoint" and I can keep my eyes glued to the watch list, inspecting the variables at each step. Some times you want to quickly step into functions, other times step over, and it's just really handy to have it mapped to keys.

I'm not even a power emacs user or something (IntelliJ is my preferred IDE). YMMV of course, but I find the hotkeys super useful.

polyfractal··on Cooled Nikon D5500a Chills the Sensor for Clearer Star Photos
Ugh, yeah, backlash on mine too :( I'm actually in the middle of rebuilding my mount to help with periodic errors and backlash. Replacing a bunch of bearings, re-greasing, replacing the direct gear train with a geared-belt system, etc.

Speaking of... I need to finish that up soon before winter season starts in earnest!

polyfractal··on Cooled Nikon D5500a Chills the Sensor for Clearer Star Photos
They are usually "dumb" heaters... literally just some voltage applied to wire (you can read more about them here, along with calculation according to wire AWG and length: http://www.blackwaterskies.co.uk/2013/05/making-your-own-nic...)

A major pain point of dew-heaters is if they are too strong, they induce "tube currents". E.g. the heat from the dew-heater causes the air around the heater to start convecting, which causes ripples in the final image. It's not really visible as ripples, but a general blurring of the image. It's essentially recreating astronomical seeing conditions inside the telescope itself, which is obviously not ideal :)

I think some fancier setups will be "active" and regulate themselves based on ambient temperature, but it's a lot more common for people to over-build their heaters and then use a dimmer switch. So you make your dew-heater for the worst winter night you expect, then dim it down for the rest of the year manually.

polyfractal··on Cooled Nikon D5500a Chills the Sensor for Clearer Star Photos
In astrophotography, this is actually the opposite of what you want to do. Generally you add cooling so that you can let your sensor run for longer, so you can collect more photons without increasing the noise appreciably.

Image stacking can reduce noise afterwards, but there's no substitute for collecting more photons to increase the signal in an image... and the only way to do that is to try and clean up the noise floor (via cooling, better sensors, etc) :)

polyfractal··on Cooled Nikon D5500a Chills the Sensor for Clearer Star Photos
My astro CCD has a (slow) fan attached the peltier. The vibration isn't usually a big deal for two main reasons:

1) If your setup is sophisticated enough that fan vibration may cause an issue, you're likely already using a german-equatorial mount and some kind of guiding correction (secondary guide scope, or off-axis guider). These adjust the scope's positioning in real-time to keep on-target. So that removes any large-scale deviation that may be caused.

2a) Small-scale deviation is generally not a problem, since most setups are likely to be limited by the resolution of your entire optical train. For example, my 800mm newtonian combined with a CCD with 7.2mm pixels means I have a resolution of ~2.01 arc-seconds. Assuming perfect guiding, my scope can tolerate any vibration as long as my target stays within ~2 arc-seconds. *

2b) In reality, most locations are limited by seeing conditions (e.g. how turbulent the air is), which averages 1-3 arc-seconds in non-mountain regions. Also the calibration of your mount (periodic errors, guiding errors, etc) are almost certainly a greater concern than the vibration added from the peltier.

That's from an amateur's perspective. Obviously high-end setups will start to worry about things like the fan's vibration, but for someone with a backyard setup (doubly so for someone using a consumer DSLR instead of dedicated CCD), there are bigger causes of inaccuracy :)

* This is a bit of a simplification, since things get a bit more complicated due to FWHM, wavelength, etc.

polyfractal··on Cooled Nikon D5500a Chills the Sensor for Clearer Star Photos
These are often called "dew heaters", and are really quite simple. It's usually nichrome wire (e.g. what you see in a toaster), or sometimes a bunch of resistors. The tiny amount of heat generated by these straps are enough to raise the optical port a degree or two above the dew point.

My QHY8 (a dedicated astro CCD) for example has a poor/old design, where the CCD compartment is not air-tight. This allows humid air to get inside, which can then fog up the optical glass due to the peltier cooling the sensor down.

The fix is a small ring that screws into the port, and raises the temperature just enough to combat dew. You could also wrap a dew heater strap around the part of the optical train at that point for a similar effect.

Dew (and frost) are the astrophotographer's great, persistent enemy and not just on the CCD. You'll also have dew problems on the telescope itself. For example, my newtonian sometimes has dew problems on the secondary mirror, occasionally on the main mirror, and always on my guide scope.

Most people just create some DIY dew heater straps with nichrome wire... it's super simple and effective.

polyfractal··on The way ahead
The number of jobs wouldn't remain static. The number of jobs would naturally increase to support the increased density of people. Also, some (hopefully large) fraction of the newly unemployed will find employment elsewhere. Few people get fired from their only job and they say "welp, guess I'm unemployed for life".

Also, 1000 of those jobs are presumably lost because the new workers are willing to work at a lower rate. That leads to two situations:

- The product/service they are creating will be cheaper (e.g. cheaper commodities out of China, cheaper fruit harvesting by migrant workers, etc). The average person spends less of their paycheck on these purchases, which means they obtain more value for less money. Or purchase more things using the same amount of money as before.

- The owner of the business pockets more profit by employing cheaper labor but keeping prices the same. This segues into the idea of "trickle down" or "supply side" economy, where the owner employs more people, expands business, invests more capital etc because they are now spending less on salaries. Not saying I agree with this analysis, but it's at least one viewpoint :)

polyfractal··on The way ahead
Interesting! I'll give this a read-through tonight, thanks for the link :)
polyfractal··on The way ahead
> These illegal immigrants take jobs away from Americans.

Eh, this argument gets trotted out a lot, but it isn't exactly clear-cut. The economy isn't a zero-sum game.

Sure, illegal immigrants do show up and undercut some jobs. Some percentage of people will find themselves working at a lower wage, or lose their job and need to find a new one.

But plenty of other people will find their business increased, higher wages, more profit, etc. All these immigrants require services and commodities too, and have to buy them from somewhere. They need to buy groceries, get hair-cuts, purchase mattresses, buy cars. Illegal or not, they contribute to the economy too.

Planet Money did a good piece on the cuban migrations to Miami in the 80's. It was the perfect microcosm to study the phenomenon: many immigrants, contained geographical region, etc.

http://www.npr.org/2015/10/01/444912593/when-cuban-migrants-...

Money quote at the top of the episode:

    SMITH: So 80,000 refugees came to Miami, and there was no effect on the economy?

    CARD: You couldn't detect any strong evidence of an effect one way or the other.

    SMITH: No effect, not on wages, not on unemployment rates. Card says this is 
    because there is not a fixed number of jobs in an economy. When a bunch of new 
    people come, yes, they get jobs. But they also start buying stuff, getting haircuts, 
    going to the grocery store, which means you need more barbers and more grocers. That 
    creates more jobs.
polyfractal··on A Review of Time Series Databases
Well, for one thing, this isn't even attempting an objective comparison. The article basically grabs whatever third party benchmark numbers are available and pretends all the metrics are comparable. In many cases, the external benchmarks are testing entirely different things, so it's meaningless to give those numbers in a "review" of all the options.

It's really just a "top ten list according to my arbitrary thoughts", which is fine. But it's not really a useful comparison at all.

polyfractal··on Java garbage collection can be really slow
Yep, just more recent versions, and it's been fixed too. But if you watch the bugs that keep popping up for G1 you see stuff like this fairly regularly.

Of course, that's a totally unfair comparison: CMS has had a decade of bug squashing...I'm sure it had equally scary bugs when it was new. But that's the point. Don't use new, shiny GC's because they are still squishing bugs :)

(Sorry, preaching to the choir, I just get frustrated by everyone claiming G1 will solve all their problems without investigating potential downsides)

polyfractal··on Java garbage collection can be really slow
Just a note, G1 probably still isn't ready for rock-solid production usage. E.g. bugs like this are still cropping up: https://bugs.openjdk.java.net/browse/JDK-8148175

That's a pretty scary bug. Who knows how stuff like that will trash your data if you aren't properly checksumming everything.

CMS and other GCs have the advantage of years of bug-squashing and tuning. G1 is exciting, but I wouldn't personally use it on anything important for quite some time.

polyfractal··on Elasticsearch: 10,000ft view
This isn't true, just fyi. Lucene actually relies on the OS' filesystem cache heavily. A Lucene index (e.g. an Elasticsearch shard) is composed of many small "segments". Each segment is an immutable file, which allows the OS to aggressively cache them.

But if your index is larger than available memory (very common), the OS will naturally start paging the segments on/off disk as required.

That's the root of the "give no more than 50% of your memory to ES" advice, since the other 50% is needed by the OS FS cache for Lucene segments

Source: I'm an Elasticsearch dev :)

polyfractal··on How we get high availability with Elasticsearch and Ruby on Rails
Hey, ES dev here. :)

The bulk API mainly helps by amortizing various overheads across many documents at once. There isn't anything "special" about the bulk indexing...it doesn't side-step the normal indexing pathway to directly dump the data directly onto disk, for example.

What happens is that the bulk request arrives at a node (which we'll call the coordinating node now, since it is coordinating this request). The coordinator will then create "mini-bulk" requests which are fired off to individual nodes who need to perform the actual indexing operations. If your bulk touches five different shards around the cluster, the coordinating node will construct five mini-bulks.

Bulk requests have an (annoying) newline-delimited format. This allows the coordinator to extract until the first newline, parse the JSON and identify the action (index, delete, update) and destination (index/type/id). Since the actual document is irrelevant to the coordinator, it can slice the buffer until the next newline straight into the "mini-bulk" for the destination node. This allows the coordinator to avoid parsing the document's JSON, which could be quite large (think 15mb PDFs, or docs with 5k fields).

Once the coordinator is done assembling the mini-bulks, it sends them to the various nodes around the cluster and waits for responses to come back. Finally, the coordinator merges the responses and sends a response to the client.

So a bulk reduces overhead by amortizing the two network hops (one to coordinator, one to node) over thousands of documents. There are also side benefits like allowing concurrent bulks to share translog fsyncs, giving lucene larger indexing buffers to work with (helps create larger segments for less churn), less context switching, etc.

Generally, smaller documents gain more benefit from bulk, since more of the time is dominated by overhead. Super large documents, or documents with very complex analysis chains are less likely to see a huge improvement, since the latency there is dominated by IO or CPU. But you'll still see an improvement due to fsyncs, context switching, giving lucene batches, etc.

Hope that helps! Lemme know if you have questions :)

polyfractal··on Aldehyde-Stabilized Cryopreservation Procedure Wins Brain Preservation Prize
I mean, it's not like it's a novel procedure or anything. This is basically how all brains are sectioned for immunohistochemistry.

A quick search turned up this protocol, labeled 2006: http://sydney.edu.au/medicine/pharmacology/CRGweb/internal/l...

I don't know when it was first used, it's one of those protocols that every lab has sitting in an ancient three-ring binder. The procedure is essentially the same everywhere, with minor variations depending on the tissue you're working with, the stains, etc:

1. Knock the animal out somehow (usually isoflurane or similar)

2. Perfuse with Phosphate-buffered saline (PBS) followed by 2-5% Paraformaldehyde (PFA). You can also use glutaraldehyde, which is better for EM, while PFA is usually better for histochemistry

3. Rinse in PBS for a while

4. Drop the brains into sucrose solutions, let them sit there until they sink. Usually labs will have a few sucrose baths they like to use (e.g. start in 10%, then switch to 30%). Sucrose is the cryoprotectant here

5. Dunk in liquid nitrogen, coat with OCT, mount on cryostat and start sectioning

6. Go about your business staining, etc

The only novel thing here, really, is that they perfused the cryoprotectant instead of just letting the brains sit in it for a few days. Letting a rabbit brain soak up sucrose likely takes longer than a mouse, so perfusing would definitely speed up that step.

But it's a rather moot point, since fixed brains can chill in refrigerated PBS for a month or two. There's no rush once it's fixed ... that's the point of fixing. I'm with the other folks, this was really just a grab at some money imo. And fancy headlines. There is nothing interesting here.

Credentials: worked in neuroscience wet-lab for 5 years.

polyfractal··on The brain functional connectome is robustly altered by lack of sleep
For better or worse, 'connectome' is a legit term used in the field. It's relatively newish (quickly skimming the literature, first mention was in a 2005 article). It follows the naming convention setup by 'genome', and includes many variants:

- genome (set of dna material in a cell)

- exome (set of exonic dna material)

- transcriptome (set of all messenger RNA)

- proteome (set of proteins in a cell)

- interactome (set of all interactions in a cell -- protein, small molecular, etc)

- metabolome (set of all small molecular compounds / interactions in a sample)

- connectome (set of all connections in the brain -- e.g. a wiring diagram)

etc etc

polyfractal··on Writing an OS in Rust
Agreed, that's why I personally like the rump kernel idea. Pick and choose the various NetBSD drivers that you need, automatically gain battle-tested drivers for a wide variety of devices. Bonus points that they are POSIX-compliant which helps with porting code.
polyfractal··on Writing an OS in Rust
Well, that's how all the NetBSD rump drivers work. IIUC, a while back they refactored all the drivers to interact with the NetBSD kernel through the Rump interface. Which means that all the drivers can work in a traditional monolithic kernel, or can be extracted and used piecemeal in your own kernel, or compiled directly into the application as a unikernel. Checkout http://rumpkernel.org/ for more info.

I dunno about performance impact, but I bet it is fairly negligible in the grand scheme of things. In the rump kernel case, these shims really don't do anything, they just pass the call through. Think of it as an API facade. In a hobby OS it might be heavier, if your OS doesn't have a 1:1 mapping of the POSIX/linux syscall to an equivalent.

Also, we virtualize this stuff all the time in cloud environments. Your java app uses the JVM to execute a linux syscall which the kernel translates into a Xen hypercall which Xen uses to call a native driver which talks to the disk, etc etc. You obviously do pay a performance penalty for stacking more and more layers, but it isn't as bad as you'd think (or as good as you hope, take your pick).

But the point is that layering abstractions like this is very much alive and tolerated today in moderately high performance systems :)

polyfractal··on Writing an OS in Rust
You can do what Rump kernels do: write a shim layer. The linux/netbsd drivers think they are talking to their host kernel, when in reality they are talking to a shim that translates linux syscalls into the equivalent "RustOS" syscalls.

Or you could just implement the linux syscalls directly in the kernel, but that seems a bit self-defeating if you want to explore new ideas.

polyfractal··on Writing an OS in Rust
If I understand correctly, Phil started writing his series first. That tutorial prompted several people to start working on their own hobby OS, including Steve's and another one here: http://www.randomhacks.net/bare-metal-rust/. I think Redox was already underway when Phil started writing, but I may be mixing up my timelines.

Edit: There is also http://www.alexeyshmalko.com/2015/bkernel-a-rust-operating-s...

Phil has stated his series is basically for fun and learning. I imagine Steve's and Eric's are similar. You don't necessarily want to "combine effort" with someone when you are exploring ideas on your own.

polyfractal··on Coffee drinking linked to lower mortality risk again
Oops, sorry, you're right. It was very early this morning and pre-coffee when I wrote that, was paraphrasing colloquially instead of technically (and not thinking) :)
polyfractal··on Coffee drinking linked to lower mortality risk again
> Some even say cholestrol is not bad

The main change recently has been an update to the ACC/AHA LDL guidelines about LDL targets. Previously, there were hard targets that the doctor was trying to reach, in particular the 70mg/dl target was considered "optimal" and doctors strived to get their patients down to that.

In reality, it's become clear that there is no clinical evidence that an LDL that low is required. Certainly decreasing it from a high level (150+) has been shown to be a good idea (in most cases...it's complicated). But once you've decreased a patients LDL to a lower level, the clinical benefit of hitting 70 is nebulous.

So the new recommendations have dropped many of the hard targets, and recommend a more case-by-case evaluation. E.g. if your patient has a high LDL and you put them on a statin, they start exercising, eating better, and levels come down to 80mg/dl ... well, that's probably fine. They are in good shape, monitor and back off the statins.

A major reason for the change is because you'd see people on statins and other cholesterol meds for years. These drugs are very safe and low side-effect, and when combined with hard targets, doctors just "leave" patients on statins forever. But despite being safe, you shouldn't be on a chronic medication and there are other risks. So the new guidelines are trying to encourage doctors to use statins more sparingly.

Some more reading on the new guidelines:

- http://emorymedicinemagazine.emory.edu/issues/2014/spring/fe... - http://www.medscape.com/viewarticle/814152

polyfractal··on Coffee drinking linked to lower mortality risk again
It's very common to remove smokers from studies like this (anything looking at mortality). Smoking increases your chance of so many health issues: heart disease, lung cancer, COPD, high blood pressure, stroke, aortic aneurysm, general infection due to chronic inflammation, etc etc. It's well documented and pretty unambiguous. If you smoke, your risk of all the above increases dramatically. Which means as a researcher you can't leave these people in a study looking at mortality rates since they would confound the results too much.

Basically, the risk of confounding your results with smoking-related mortality is a bigger problem than biasing your population with fewer people who consume addictive substances.

Source: I'm an ex-molecular biologist, my significant other is a PA.

polyfractal··on Making Popcorn: Adding a Disk to a Rust Rumprun Unikernel
Author here. My goal is to (eventually) host a toy key:value store on top of a unikernel. So the KV store would need to persist data to a writable file system. It's great when you don't need to alter state and the unikernel can be immutable (baking config into code ala Mirage, etc)...but something like a KV store can't get away with that.

But, the KV store + unikernel is mostly for fun, so may not be the most practical of real-world ideas anyway :)

polyfractal··on Nim binary size from 160 KB to 150 Bytes
Oh, sorry, I should have been clearer: I wasn't trying to disparage Nim at all (it's on my list of languages to play with). I was just clearing up some points about Rust :)

Edit:

> Well I was not talking about iterating through a list, but rather maintaining arbitrary indexes to a mutable list. Eg, a Sprite which contains a index to a Texture array. In that scenario it's just as easy to miscalculate and crash your program via a bounds-checking error as it is to crash by nil-deref.

The solution here is to just use a reference instead of an arbitrary index. If you hand out references you can lean on the compiler to enforce memory safety -- the compiler won't let you access data that is no longer alive, won't let you accidentally share across thread boundaries if you don't explicitly want that, etc. And if that was a shared mutable list, it's doubly important to let the compiler help you reason about it, since shared, mutable state is the main source of data races.

This is one of those cases where leveraging the compiler allows you to write better, safer code.

← PreviousPage 2 of 30Next →