When making networking requests that don’t need to be executed sequentially, making them in parallel can reduce the overall time. Previously, we used DispatchGroup
, adding tasks with enter
, and signaling completion with leave
, then handling everything in notify
once all were complete.
DispatchGroup Parallel Code
func requestLegacyParallel() {
let group = DispatchGroup()
var results = [Bool]()
let startTime = Date()
print("Start (DispatchGroup)")
for _ in 0..<3 {
group.enter()
Task {
let result = await self.networking()
results.append(result)
group.leave()
}
}
group.notify(queue: .main) {
let endTime = Date()
let duration = endTime.timeIntervalSince(startTime)
print("End (DispatchGroup): Duration \(duration) seconds")
print("Results: \(results)")
}
}
Swift Concurrency Sequential Code Example
func requestConcurrency() {
Task {
let startTime = Date()
print("Start (Sequential)")
let a1 = await self.networking()
let a2 = await self.networking()
let a3 = await self.networking()
let result = [a1, a2, a3]
let endTime = Date()
let duration = endTime.timeIntervalSince(startTime)
print("End: Duration \(duration) seconds")
print("Results: \(results)")
}
}
Swift Concurrency Parallel Code Example
func requestConcurrencyParallel() {
Task {
let startTime = Date()
print("Start (Parallel)")
async let a1 = self.networking()
async let a2 = self.networking()
async let a3 = self.networking()
let results = await (a1, a2, a3)
let endTime = Date()
let duration = endTime.timeIntervalSince(startTime)
print("End (Parallel): Duration \(duration) seconds")
print("Results: \(results)")
}
}
When comparing the elapsed time, both the DispatchGroup and async let
approaches naturally result in faster execution compared to sequential requests. Since Apple recommends using Concurrency, we should use async let
for parallel execution.
I spent some time reviewing SQL query syntax.
There were some confusing parts regarding aggregate functions in the SELECT statement, but understanding that multiple datasets are merged into a single dataset helped clarify the concept.
Even if you combine multiple tables, the result is always a single table.
Keywords: SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, JOIN ~ ON, LEFT JOIN ~ ON, Count(), AVG(), MIN(), MAX()
Obsidian is an app used to write and manage notes using markdown syntax. Initially, I thought I could only use it locally or with a paid sync option, but after doing some research, I found that remote sync can be set up for free using various cloud services like GitHub, Dropbox, and Google Drive.
First, I completely removed my previous Obsidian setup.
How to Completely Remove It
# Search the entire system starting from root
# -iname "*obsidian*" searches for files/folders containing "obsidian", case-insensitive
# 2>/dev/null suppresses permission error messages
$ sudo find / -iname "*obsidian*" 2>/dev/null
# -iname "obs*" searches for names starting with "obs", case-insensitive
$ sudo find / -iname "*obs*" 2>/dev/null
I then integrated GitHub using the Git plugin, and Dropbox using the Remotely Save plugin.
Although the paid Obsidian Sync is more stable and setting up plugins each time is a bit of a hassle, I’ll reconsider the paid option once I become more familiar with Obsidian.
On a side note, I noticed that the cache size on my Mac seemed to be increasing, so I plan to look into that further.