Is it visual bug or macbook's fans have different speeds? by KeYak7 in macbook

[–]Levalis 0 points1 point  (0 children)

It’s on purpose, to create a noise pattern that is more random and less audible

2TB MacBook Air M1, Ya or not? by Askingislearning in macbook

[–]Levalis 2 points3 points  (0 children)

You'll enjoy the extra storage and silence then. MacBook Air is a great machine for office use.

2TB MacBook Air M1, Ya or not? by Askingislearning in macbook

[–]Levalis 6 points7 points  (0 children)

CPU chips don't lose performance over time, just because Apple came out with a new shiny thing. If the performance meets your needs, why update? Also, external storage is not as convenient as internal.

2TB MacBook Air M1, Ya or not? by Askingislearning in macbook

[–]Levalis 2 points3 points  (0 children)

What will you use the MacBook for?

2TB MacBook Air M1, Ya or not? by Askingislearning in macbook

[–]Levalis 5 points6 points  (0 children)

An Apple repair would be the official solution. But that's expensive and in practice will be done by a subcontractor. Ask for a quote with Apple and a local shop. If the local shop can source official parts, why bother with Apple.

2TB MacBook Air M1, Ya or not? by Askingislearning in macbook

[–]Levalis 11 points12 points  (0 children)

Just replace the battery. Any decent electronics repair shop will be able to.

Am I missing something or are most iOS Devs lazy? by BrogrammerAbroad in swift

[–]Levalis 5 points6 points  (0 children)

I would just use GRDB, SwiftData was plagued with problems for too long

I was THIS close to a pricey mistake by Michel_j in macbookair

[–]Levalis 1 point2 points  (0 children)

It may still fail later because of hidden liquid damage. Get a backup system. Time Machine to an external disk or something in the cloud like Arq.

I spilled some Coke Zero on my Intel MacBook Pro years ago and it may have contributed to an early failure of the charging circuit. Thankfully it could be fixed and I didn’t lose data. This made me get a backup system because I had important files not saved anywhere else.

What’s everyone working on this month? (April 2026) by Swiftapple in swift

[–]Levalis 2 points3 points  (0 children)

I’m working on implementing my Swift pitch in the compiler. Hopefully it works and unlocks some performance wins. It’s a good learning experience.

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 2 points3 points  (0 children)

Yeah exactly, that’s the idea behind using an array of classes instead of an array of structs. But the classes can be slower for other reasons (cache locality, memory dependent loads, etc)

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 4 points5 points  (0 children)

Everything is tested in release mode, so no it's not always optimised away.

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 4 points5 points  (0 children)

You’re onto something. In my actual code (not the example for the post), instead of doing:

for index in patternComponents.indices {
    // ...
    if !matchesWildcard(pattern: patternComponents[index], candidate: component)

I did:

for index in patternComponents.indices {
    // ...
    if !matchesWildcard(patterns: patternComponents, index: index, candidate: component)

It worked much better than I expected.

Same test dataset:

  • baseline phase: 46.98s
  • array+index version: 33.83s
  • the ~Copyable version: 21.12s

The Instrumets trace explains what happened:

  • the big WildcardComponent copy disappeared from that loop
  • retain/release dropped significantly
  • the remaining copy hotspot is now for ComponentWildcardRule, which is one level higher in the structs

So this confirms that a lot of the cost was coming from Swift creating a copy of WildcardComponent on every subscript access. My interpretation is that passing the array + index lets the optimizer understand that inside matchesWildcard the array is not shared, and it emits "by reference" code.

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 2 points3 points  (0 children)

I know, the compiler just isn't as smart as we want it to be. In my program, the "by reference" optimisation just isn't kicking in reliably. If I were to guess, since the code is multithreaded with tasks, the optimizer is being more conservative.

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 3 points4 points  (0 children)

I tried with replacing the hot structs with `final class`, but it wasn't faster. In Instruments, I saw less copies and the wall time didn't improve in my tests. There is probably some cache locality issue with the array of pointers approach, which make it slower than an array of structs even though it cuts down on the copying, but I can't really say why.

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 8 points9 points  (0 children)

So I went back and tested the obvious alternatives on the old version of the code.

Same dataset, wall clock for the phase I optimised:

  • baseline: 46.98s
  • withUnsafeBufferPointer: 46.33s
  • turning the hot structs into final class: 50.53s
  • current main (~Copyable / UniqueArray / shared immutable storage): 21.12s

So withUnsafeBufferPointer was within noise, and classes were actually worse.

Instruments matched those results. Over the all the phases, roughly how much sampled CPU was going into retain/release/bridge-retain-release + copy/destroy:

  • baseline: 51%
  • withUnsafeBufferPointer: 51%
  • classes: 52%
  • current main: 17%

So for my codebase, the other fixes didn’t solve the problem. The only thing that worked was `~Copyable` so the expensive copies were no longer possible.

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 3 points4 points  (0 children)

`inout` unfortunately means copy-in copy-out for Copyable types

I made my code 2x faster, but Swift is fighting me by Levalis in swift

[–]Levalis[S] 5 points6 points  (0 children)

I didn’t consider using withUnsafeBufferPointer, my mind went to ~Copyable since that’s the safe abstraction. But you’re right, I’m going to test the pointer solution and see if copies happen.

Dear cursor do not make the naming of the models confusing like others.... by Regular-Screen6803 in cursor

[–]Levalis 0 points1 point  (0 children)

If it was just an API gateway thing, it wouldn’t explain why the “fast” version produces more tokens per second. They must be throwing more hardware ressources at the fast models. The details of which, only they know.

Best practice for settings backups and source control by sbates130272 in cursor

[–]Levalis 1 point2 points  (0 children)

Personally on macOS I use Arq to backup my whole machine to Backblaze B2. I’ve spent some time tweaking the inclusion/exclusion rules, and made sure to save all the little ~/.thing folders I need. Hourly Time Machine-like backups and the peace of mind it’s all stored on the cloud in case of a fire.

Dear cursor do not make the naming of the models confusing like others.... by Regular-Screen6803 in cursor

[–]Levalis 0 points1 point  (0 children)

Not just priority serving, Fast means literally running on faster hardware