At least for me. I think I have learned a lot a bout the language, but still so thing did not come up easily – recent example was a generic map, that can use both owned values or references as keys. So basically COW of the type is used as key. So here is the result, which took me while to put together:
Continue reading Sometime it’s tricky to get Rust generics rightCategory Archives: Programming
Are you dead?
Not yet. However I did not publish much in last 9 month or so due to several reasons- and covid was not the least significant one. I started couple of interesting things, but was lazy and demotivated to sum them up even in small article. I also changed my job few months back, which kept me quite busy, but positive impact was I’m waking up from lethargy caused by covid and past job.
So I’ll try to quickly summarize past year or so in here, it’ll be nothing special, just to have things accounted:
Continue reading Are you dead?What happened to audioserve in past year
Not much, but definitely it’s not dead. Actually I’m quite happy with current functionality and do not need more (actually there are couple of things that would be nice to have like shared bookmarks and read/finished audiobook attribute, but these will probably require to go beyond it’s simplistic design) and I’m using it every day. But some coding was done during past year and some small improvements were implemented.
Continue reading What happened to audioserve in past yearCan Hashmap Be An Obstacle on Road to Performance
I’m still playing with small exercises, one interesting is “alphametics” (it’s available on exercism). Exercise goal is to evaluate if an expression like “SEND + MORE == MONEY”, when letters are replaced uniquely with numbers, is valid equation (more details in link above). As I have written in previous article, I try to think about performance and this exercise was quite interesting from that perspective.
Continue reading Can Hashmap Be An Obstacle on Road to PerformanceClone or Reference Count – Which One Is Faster
While I was updating audioserve I hit one part of code, when I was passing a not so big structure (containing data for authentication) to asynchronous task (in tokio multi-threaded executor), as task might run potentially in different thread it has to have static lifetime. Easiest solution was to clone the structure and move it to thread (which was original solution). But during refactoring I realized that reference count – Arc
type could be better solution – it can save a small piece of memory (Arc is 8 bytes), but also it could perform better (or could not?). To check my later assumption I’ve run couple of of tests.
Hyper and TLS
For audioserve update I wanted use new hyper
with tokio-tls
. Actually it required a bit of documentation reading, but finally turned our quite straightforward.
Migrating Tokio and Futures – What to Look for
I’ve finally found courage to look after migrating audioserve to new hyper and tokio and futures crates. As new futures (0.3) are significantly different from previous version, mainly due to support of async/await keywords, I was expecting significant effort, so I was kind of delaying it. Now when it’s almost done, I’d like to reflect a bit on the effort. Firstly – it was not as bad as expected (although after updating cargo dependencies I’ve got about a hundred of errors). Secondly – there are some patterns to follow in migration, which I’ve like to describe further in the article.
Continue reading Migrating Tokio and Futures – What to Look forPerformance Should Matter
As I did not have much time to focus on larger programming projects recently I’ve done several exercises on exercism Rust track. It was quite fun and I hope learned a bit. But I found one issue there – when looking at solutions of others, some of them, even when code look very nice and has stars from other users, is performing very badly. I consider this as quite bad practice – if one chooses a “Systems Programming Language” as Rust he should think about performance and understand implications of:
a) general algorithm complexity
So chosen solution should try to use sound algorithm, with complexity close to best possible
b) using complex fancy functional constructs
Rust is advertising “zero cost abstractions”, however while it works in many cases it has to be used with caution – you have to use a bit of common sense.
First Impressions about New Rust Async
Just recently async
and await
made it to stable version of Rust. futures
library 0.3 is also out and rest of other important libraries is following – for me tokio
and hyper
are particularly interesting. tokio
is now in alpha stage supporting new futures, so I decided it’s about a time to give it a try. Some time ago I’ve rewritten ptunnel in Rust using 0.1 version of tokio
and futures
. So here are my first experiences with new libraries and upgrade.
Audioserve new features
I have been working on some new features in audioserve and they are now available in latest releases. In this article I’d like to talk little bit about them and probably later also provide new demo videos, as there has been many changes from last demos.
Summary of new features:
- Single file audiobooks (m4b) support
- Alternative subfolders sorting (recent, alphabetical) and most recent folders list
- Folders download in web client
- Easier deployment with smaller docker image or static binary
- Server config file
- Playback sharing/synchronization between clients
See below for details.