Cross Compile to PinePhone Part One

Cross Compile to PinePhone Part One Click Here For Part two Click Here for Part three PinePhone has been out for over one year now. In the last year, KDE plasma mobile saw rapid progress. We’ve developed almost all utility apps you’d have on iOS and Android. And actions like flashlight, screen capture also get added to top panel. What’s more, the launch screen and app drawer only get better. ...

September 19, 2021

Ruby Ractor and Parallelism in Interpreted Languages

Ruby Ractor and Parallelism in Interpreted Languages Ractor One of the major feature of Ruby 3.0 is the introduction of ‘ractor’. Ractor is a new concurrent abstraction for Ruby. Unlike Ruby threads, ractors can run in parallel. Due to the Ruby Global Virtual Machine Lock(GVL), even each Ruby thread is mapped to native thread, there can only be one active thread running. But after the introduction of ractor, there can be multiple GVL, each ractor has one. That’s why ractors can have parallel execution. ...

September 12, 2021

Ruby Meta Programming Performance

Ruby meta programming performance In 2015, Pragtob wrote a blog post about Ruby meta programming. Well, you may wonder why I’m talking about a blog that wrote five years ago while the computer science is progressing at ever-increasing speed. I searched for it, because in work we were hit by this problem. In work we use Cocoapods to manage dependency. In a project with few pods you won’t notice the speed of Cocoapods. But what if, let’s say, 600+ pods? It can take half a minute just for Cocoapods to generate XCode Project files! We managed to narrow down the performance issue to this very Ruby file. On the surface, it’s pretty harmless. There is a helper method that can generate other methods using meta programming, saving the hassle to manually write things like sorting results, memorizing… However, there are also some methods that merely return a constant string but also use this helper. Methods defined using define_method have small overhead, but when the method get called tens of thousands of times, the overhead is big enough to use some monkey patching to optimize it. I monkey patched those methods that use define_method but simply return a constant string. Re-define those methods with plain def resulted in a 5s optimization. 5s may not sound like much, but in programming world, it’s like 3 years! ...

September 5, 2021

Quirks of Downloading

Quirks of Downloading Motivation These days, we don’t actually care about the internals or details of network downloading. Most of the time, we click a link on the browser and wait for the progress bar to finish. If we feel the downloading is taking too long, usually Ethernet speed gets the blame. However, we never thought about the protocols used underneath that progress bar. Even for programmers that actually needs to implement some sort of downloading code, there are always high level libraries for every language. Needs HTTPS? Add https:// in front of your URL, want multiple connections? Flick that switch on and the library does all the dirty work for you. ...

August 28, 2021

Btrfs Raid on ArchLinux

Btrfs Raid on Arch Linux Prologue Over the years, more and more stuff occupied in my disks. Videos, ripped music and offline Arch Linux mirror… Just to name a few. The previous storage setup is a 128 GB SSD for the system and one 1 TB HDD for storage. But since the HDD in question is a 8 years old one, feeling insecure about the data, I added another portable 1 TB hard drive to form a Raid 1 array. ...

August 21, 2021

Delete the QQmlApplicationEngine?

How I tried to delete QQmlApplicationEngine for less memory usage Qml Qml manages to separate UI and backend logic, one can adjust c++ code without breaking UI, or develop different front end without implementing same logic twice. As plasma mobile developers, we can utilize the flexibility of Qml and Kirigami framework. Making apps that look equally beautiful on mobile and desktop platform. However, the high memory usage is its major drawback. On a device like pinephone which only has 2 Gigs of ram, low memory consumption is crucial. ...

August 31, 2020

Plasmoid with C++

Plasmoid with C++ the screenshot is at the end of this post I’m developing a Plasmoid for Plasma Mobile. Called KClock-Plasmoid, as its name suggests, it’s a plasmoid for KClock. The goal is to display time, next alarm and stay at system top panel to indicate KClock is running in background. KClock side So the goal is pretty simple, and all I have to do is to find a way to share information from KClock to the plasmoid. However the solution isn’t that trivia. As it turned out, DBus is perferred for IPC(Inter-process communication). Before start working on plasmoid, I need to expose some of the class of KClock to DBus first. Since KClock is built upon Qt, I choose to using Q-DBus as it will save a lot of effort than using low level interface. Now the problem is - I don’t know how to use Q-DBus. As usual, I went to the Qt documentation and to my surprise, it spent most content to describe the concept of DBus and compared to Qt’s signal/slot machinism. Although useful as it is, lack of examples meaning I still didn’t know how I can use it in my code. Thankfully, KDE has its own tutorial about DBus and it provides multiple examples. You can find it here. ...

August 12, 2020