Frustrated and exhausted at being asked "why?"

When my coworker asks me "why" something for which I'm responsible went wrong, particularly coworkers who are in a different field of expertise, I feel frustrated because, in order to help them understand why things are not so simple as they would like, I have to give them a ton of context and explanation, and it's exhausting.

On other occasions, when my wife asks me why I didn't wear clothes that she would prefer I wear, I feel frustrated, again because I feel like I need to replicate the web of thoughts in my mind in a way that justifies what I wear such that she'll trust my fashion decisions, and it's exhausting.

When I feel frustrated and exhausted, I become irritable, and I don't want to be that way with people. What can I do to overcome this?

reddit.com
u/Sad-Background-2429 — 1 day ago
▲ 3 r/asm

Help me optimize a simple x64 program

Hi there, I'm learning the Intel x64 ISA by doing some Project Euler problems. The first problem is to compute the sum of all the positive integers less than 1000 that are divisible by 3 or 5. I know that there is a closed-form expression for this problem that can be computed without loops or tests. My goal isn't to improve my solution to the problem, but to optimize the solution that I have, using what I learn about x64 optimizations. The code in file p1.s is below.

	bits 64			; Enable 64-bit instructions.
	default rel		; Declare that the program can be dynamically relocated.
	global main		; The entry point main must be exported.
	extern printf		; We must import the symbols of libc that we need.
	section .data

	CLOCK_MONOTONIC_RAW equ 4
	CLOCK_REALTIME equ 0
fmt:
	db "%d", 9, "%lu", 10, 0

	section .text

main:
	push rbp
	mov rbp, rsp
	sub rsp, 32 		; Allocate space for two timeval_t structures

	mov rax, 228                ; Call the clock_gettime() syscall
	mov rdi, CLOCK_MONOTONIC_RAW     ; Argument 1: Clock ID (0)
	lea rsi, [rbp-16]
	syscall

	xor rsi, rsi		; The sum starts at zero. ESI is also the second parameter of printf().
	mov ecx, 999		; The countdown starts at 999.

.L1:
	xor edx, edx		; Set the dividend EDX:EAX to the current count.
	mov eax, ecx
	mov ebx, 3		; Is the count divisible by 3?
	div ebx
	cmp edx, 0
	je .L2			; Add it if so.

	xor edx, edx		; Set the dividend EDX:EAX to the current count.
	mov eax, ecx
	mov ebx, 5		; Is the count divisible by 5?
	div ebx
	cmp edx, 0
	jne .L3			; Add it if so.

.L2:
	add esi, ecx

.L3:
	loop .L1		; Decrement the count and loop until the count is zero.

	push rsi
	mov rax, 228                ; Call the clock_gettime() syscall
	mov rdi, CLOCK_MONOTONIC_RAW     ; Argument 1: Clock ID (0)
	lea rsi, [rbp-32]                ; Argument 2: Pointer to the timespec struct on stack
	syscall
	pop rsi

	mov rdx, qword [rbp-24]
	sub rdx, qword [rbp-8]

	lea rdi, [fmt]		; Printf's first parameter is the format string. ESI holds the second parameter.
	xor rax, rax		; In the x64 ABI, since printf() is a variadic function, we must zero out EAX before calling.
	call printf wrt ..plt	; We must also call with-regards-to the PLT, which accounts for the fact that printf is dynamically loaded.

	add rsp, 32
	pop rbp
	
	xor rax, rax
	ret

I compiled this way:

nasm -f elf64 -g -o p1.o p1.s
cc -o p1 p1.o -ansi -pedantic -Wall -g

I then ran the program and cachegrind and saw this:

==132149== Cachegrind, a high-precision tracing profiler
==132149== Copyright (C) 2002-2024, and GNU GPL'd, by Nicholas Nethercote et al.
==132149== Using Valgrind-3.25.1 and LibVEX; rerun with -h for copyright info
==132149== Command: ./p1
==132149== 
--132149-- warning: L3 cache found, using its data for the LL simulation.
233168	418070
==132149== 
==132149== I refs:        133,262
==132149== I1  misses:      1,275
==132149== LLi misses:      1,253
==132149== I1  miss rate:    0.96%
==132149== LLi miss rate:    0.94%
==132149== 
==132149== D refs:         40,123  (28,356 rd   + 11,767 wr)
==132149== D1  misses:      1,591  ( 1,220 rd   +    371 wr)
==132149== LLd misses:      1,353  ( 1,011 rd   +    342 wr)
==132149== D1  miss rate:     4.0% (   4.3%     +    3.2%  )
==132149== LLd miss rate:     3.4% (   3.6%     +    2.9%  )
==132149== 
==132149== LL refs:         2,866  ( 2,495 rd   +    371 wr)
==132149== LL misses:       2,606  ( 2,264 rd   +    342 wr)
==132149== LL miss rate:      1.5% (   1.4%     +    2.9%  )

For such a small program, I was surprised that there are any cache misses. I tried applying align 16 to align the starts of loops, but it yielded no decrease in cache misses; it only increased the number of instructions.

Can you recommend any ways to optimize the code here?

reddit.com
u/Sad-Background-2429 — 2 days ago

Help me optimize a simple x64 program

Hi there, I'm learning the Intel x64 ISA by doing some Project Euler problems. The first problem is to compute the sum of all the positive integers less than 1000 that are divisible by 3 or 5. I know that there is a closed-form expression for this problem that can be computed without loops or tests. My goal isn't to improve my solution to the problem, but to optimize the solution that I have, using what I learn about x64 optimizations. The code in file p1.s is below.

	bits 64			; Enable 64-bit instructions.
	default rel		; Declare that the program can be dynamically relocated.
	global main		; The entry point main must be exported.
	extern printf		; We must import the symbols of libc that we need.
	section .data

	CLOCK_MONOTONIC_RAW equ 4
	CLOCK_REALTIME equ 0
fmt:
	db "%d", 9, "%lu", 10, 0

	section .text

main:
	push rbp
	mov rbp, rsp
	sub rsp, 32 		; Allocate space for two timeval_t structures

	mov rax, 228                ; Call the clock_gettime() syscall
	mov rdi, CLOCK_MONOTONIC_RAW     ; Argument 1: Clock ID (0)
	lea rsi, [rbp-16]
	syscall

	xor rsi, rsi		; The sum starts at zero. ESI is also the second parameter of printf().
	mov ecx, 999		; The countdown starts at 999.

.L1:
	xor edx, edx		; Set the dividend EDX:EAX to the current count.
	mov eax, ecx
	mov ebx, 3		; Is the count divisible by 3?
	div ebx
	cmp edx, 0
	je .L2			; Add it if so.

	xor edx, edx		; Set the dividend EDX:EAX to the current count.
	mov eax, ecx
	mov ebx, 5		; Is the count divisible by 5?
	div ebx
	cmp edx, 0
	jne .L3			; Add it if so.

.L2:
	add esi, ecx

.L3:
	loop .L1		; Decrement the count and loop until the count is zero.

	push rsi
	mov rax, 228                ; Call the clock_gettime() syscall
	mov rdi, CLOCK_MONOTONIC_RAW     ; Argument 1: Clock ID (0)
	lea rsi, [rbp-32]                ; Argument 2: Pointer to the timespec struct on stack
	syscall
	pop rsi

	mov rdx, qword [rbp-24]
	sub rdx, qword [rbp-8]

	lea rdi, [fmt]		; Printf's first parameter is the format string. ESI holds the second parameter.
	xor rax, rax		; In the x64 ABI, since printf() is a variadic function, we must zero out EAX before calling.
	call printf wrt ..plt	; We must also call with-regards-to the PLT, which accounts for the fact that printf is dynamically loaded.

	add rsp, 32
	pop rbp
	
	xor rax, rax
	ret

I compiled this way:

nasm -f elf64 -g -o p1.o p1.s
cc -o p1 p1.o -ansi -pedantic -Wall -g

I then ran the program and cachegrind and saw this:

==132149== Cachegrind, a high-precision tracing profiler
==132149== Copyright (C) 2002-2024, and GNU GPL'd, by Nicholas Nethercote et al.
==132149== Using Valgrind-3.25.1 and LibVEX; rerun with -h for copyright info
==132149== Command: ./p1
==132149== 
--132149-- warning: L3 cache found, using its data for the LL simulation.
233168	418070
==132149== 
==132149== I refs:        133,262
==132149== I1  misses:      1,275
==132149== LLi misses:      1,253
==132149== I1  miss rate:    0.96%
==132149== LLi miss rate:    0.94%
==132149== 
==132149== D refs:         40,123  (28,356 rd   + 11,767 wr)
==132149== D1  misses:      1,591  ( 1,220 rd   +    371 wr)
==132149== LLd misses:      1,353  ( 1,011 rd   +    342 wr)
==132149== D1  miss rate:     4.0% (   4.3%     +    3.2%  )
==132149== LLd miss rate:     3.4% (   3.6%     +    2.9%  )
==132149== 
==132149== LL refs:         2,866  ( 2,495 rd   +    371 wr)
==132149== LL misses:       2,606  ( 2,264 rd   +    342 wr)
==132149== LL miss rate:      1.5% (   1.4%     +    2.9%  )

For such a small program, I was surprised that there are any cache misses. I tried applying align 16 to align the starts of loops, but it yielded no decrease in cache misses; it only increased the number of instructions.

Can you recommend any ways to optimize the code here?

reddit.com
u/Sad-Background-2429 — 3 days ago
▲ 22 r/plan9

Displacing UNIX

I'd like to wax optimistic for a moment. What technical work needs to be done to make Plan9 eligible to displace UNIX, and how can I help?

reddit.com
u/Sad-Background-2429 — 14 days ago

Inventing natural, just consequences

I would first like to thank an anonymous member here for recommending the book "No Bad Kids" by Janet Lansbury. It has helped me to understand the why and how of gentle parenting.

One thing that I struggle with is coming up with "natural" consequences that don't seem arbitrary. I do find that it helps to give clear, up-front reminders. For example, I'll tell my toddler that if he hits the wall with something he shouldn't, I'll have to take the object away; or if he's rough with his baby brother, I'll have to put him in his crib; or if he throws his fork, I'll assume that he's done with his food.

But there are many other instances where the issue isn't misuse of an object, or abuse of his baby brother. Sometimes it's refusing to cooperate, or shouting in a quiet public place when I tell him not to. I find that my go-to is to put my son in his crib, but this doesn't always feel like a natural or obvious consequence of his actions, and sometimes it's not even an option (e.g. in public).

Can you share how you come up with consequences that are natural and just?

reddit.com
u/Sad-Background-2429 — 16 days ago

IA64 Instruction Encoding

I’m preparing to write a compiler backend for the first time, and need to understand how x86_64 instructions are encoded. I’ve written a few simple programs with x86_64 assembly language but I’m not deeply familiar with the architecture. I assume that the x86_64 manual is the definitive guide, but it’s very long, dry, and covers a lot of details about “real mode” and backward compatibility that I frankly don’t understand. Explanations or pointers to good resources are much appreciated.

Edit: Changed IA64 to x86_64

reddit.com
u/Sad-Background-2429 — 19 days ago
▲ 360 r/yoga

[COMP] Why is my down-dog so cringe?

I could use some help. I knew my downward-dog wasn't great but seeing a photo confirmed it. When my wife does this pose, it looks very natural. Her legs, torso, and arms are all aligned, and make a triangle with the floor. How can I achieve that?

u/Sad-Background-2429 — 25 days ago

Smalltalk in the large

How do large teams work on a Smalltalk codebase if everything is contained in a compiled image? How do code reviews work if there are no diffs? How are builds made to be repeatable? How does one deploy a Smalltalk application without dragging in all of the rest of the system, most of which might go unused?

reddit.com
u/Sad-Background-2429 — 30 days ago
▲ 1 r/latin

Latin dictionary for macOS

I like the macOS dictionary program and would like to add a Latin dictionary to it. While the format for the macOS dictionary program is documented, I haven't seen anyone make a Latin dictionary.

I'm tempted to try to adapt the lexicon from Whitaker's Words for the macOS dictionary but before I do, is there any technical (linguistic) reason why this effort might not be feasible?

reddit.com
u/Sad-Background-2429 — 1 month ago

How to dispel toddler tension

I have two boys, a toddler and a newborn. The toddler is sometimes sweet with the newborn and sometimes rude and rough with him. My wife and I have noticed that the combination of toddler behaviour and fear for our newborn’s safety is keeping us constantly on edge, and that’s causing us to be more easily frustrated with one another. We’re not as patient or sweet with each other as we were before we had children. I’d like to know if there are strategies we can use to cut the tension and keep things under control so that we can be more loving with one another.

reddit.com
u/Sad-Background-2429 — 2 months ago

How to read equations

I just wanted to share something that has helped me in my study of math: learn to read equations both forwards and backwards.

For example, if y = x^2 + 5, then you can replace any y you see with x^2 + 5. But you can also substitute any x^2+5 you see with a y.

The reason is that, at least in all the cases I know of, the = symbol signifies *identity*. The expression x=42 says that the symbol x and the “symbol” 42 refer to the same object: the number 42.

This may seem obvious and pedantic, but somewhere early on in my education I missed this step in logic, and was reading equations only left-to-right, and I think it impeded my understanding for many years.

reddit.com
u/Sad-Background-2429 — 2 months ago
▲ 4 r/latin

Parsing a sentence from Fabulae Syrae

I'm struggling to parse the last sentence of this passage in Luigi Miraglia's "Fabulae Syrae," part of a retelling of the myth of Atalanta:

Ita loquebatur, nec intellegebat se illum puerum iam amare coepisse. Ei igitur persuadere conabatur, ne temerarius esset neve vitam amitteret. Cives vero et ipse Atalantae pater cursus qui solebant fieri poscebant, neque moram patiebantur.

Here is my attempt at a translation of the passage:

Thus she spoke, but she didn't understand that she had already begun to love that boy. She tried therefore to persuade him lest he be rash and throw his life away. But the people, and even Atalanta's father, demanded that the race proceed as they were accustomed, and they didn't suffer delay.

I find myself tripping over the qui solebant piece of the last sentence. To what is qui referring, and who or what is the subject of solebant?

reddit.com
u/Sad-Background-2429 — 2 months ago
▲ 8 r/yoga

What comes after sun salutation?

I don’t know much about yoga. I started doing sun salutations in the morning as a simple way to improve my strength and mobility, and while I’m certain there’s more I need to do to master them, I’m curious to know what comes after, as the sun salutation sequence isn’t very long. There appear to be many styles of yoga and I’m not sure where to go from here.

reddit.com
u/Sad-Background-2429 — 2 months ago

Getting into embedded systems programming

I'm considering whether embedded systems programming would be an option for me to grow into, but

  • I've never taken a physics course
  • I don't know anything about electrical engineering
  • I only know basic calculus and a bit of linear algebra

Is lacking these skills an impediment to learning embedded systems programming?

reddit.com
u/Sad-Background-2429 — 2 months ago

How do you stay motivated in this career?

I’ve worked as a programmer for over a decade. I got into it because I was fascinated by computers and could make good money. Now, the mystery is gone, it’s all just a matter of details, and it’s just a job. I have no desire to build anything with computers, so I have no motivation to learn the math that I would need to advance in my career, to stay ahead of AI. And many mechanical engineers can program well enough that I see little to differentiate myself. Do any of you feel like this? How do you stay motivated to perform?

reddit.com
u/Sad-Background-2429 — 2 months ago

Book Hoarding

I've long considered it a mark of culture for one to have a large library in their home, and I've always enjoyed looking at the books on people's shelves.

But after several hours looking at r/BookshelvesDetective, I realized that we're all buying many of the same books.

There is charm in having a personal library, but I recognize now that buying books for private use has some disadvantages:

  • It's expensive
  • It increases waste in the long run
  • People who can't afford them but would otherwise read them miss out

It seems like it would be wiser to borrow books from a library, and if we can't find a book in the library, to donate it to the library after we've read it.

I recognize that this is not very deep, but for a bibliophile like myself it is a novel idea.

reddit.com
u/Sad-Background-2429 — 2 months ago

I’m sure that many people will find nothing new in what I share here, but for traditional Catholics like me who want to love Vatican II but hate the degeneracy it seems to have invited, perhaps it will be of some value.

I noticed that after coming to the Church, I had become angry: angry toward the world filled with degeneracy and gender confusion; toward Vatican II for breaking with tradition and past teaching; toward the post-conciliar popes for kissing the Quran and worshipping idols and humiliating ecumenical “dialogues”; toward the boomers for igniting the sexual revolution and institutionalizing marxism and feminism.

Since Christ is the prince of peace, I had to admit that this anger I feel can’t be from God. Up to now, all I’ve wanted to hear is for a pope to assert that the Church is the one true Church that Christ founded, and that anyone outside of it is damned.

But when I ask myself how I would like to be treated if I were muslim, for example, in an age where Christendom is dead and society is so pluralistic, I don’t think I would want to be aggressively condemned to hell by a stranger, especially if I feel that I’m doing my best to live a moral life. Gentleness is needed in our time.

So for a newfound appreciation for charity, I tried to open my heart to Vatican II and what the church is teaching today, but I immediately noticed that if I would try to assimilate a document like Nostra Aetate, I immediately began to feel indifferent toward any religion, including my own. There are elements of truth in every religion, right? So why bother worrying about which one is true?

I felt that, if I cling to the tridentine view of the Church, I have much-needed clarity but a kind of stubborn charity that behaves as if the Church still enjoys the temporal authority she once did in the age of Christendom. If I give my heart to Vatican II, I have genuine charity but much ambiguity, and having to choose between these two world views was tearing me apart.

But last night I had a stroke of insight, which is this: Vatican II is above all an act of charity, a love letter to humankind in our “apostolic” time. Being a “pastoral” council, it is of a different *order* than prior councils: previous councils are on the order of Doctrine, but Vatican II is on the order of Charity. This is the source of the confusion, and why so many traditionalists believe that Vatican II has changed Church teaching: they are comparing councils of different orders, like comparing apples and oranges.

Any apparent contradiction in doctrine between a council in the order of Charity (i.e. Vatican II) and a council in the order of Doctrine is resolved by favouring the teaching from the latter. In questions of charity, councils in the order of Charity like Vatican II take precedence.

I am, of course, not the magisterium, so this is just my opinion, but this view is helping me to understand how to embrace Vatican II without sacrificing the doctrine of the pre-conciliar Church.

reddit.com
u/Sad-Background-2429 — 2 months ago
▲ 2 r/webdev

I know C/C++, HTML, CSS 2.0, and JavaScript. I used to build web 1.0 websites but things have changed a lot. I’d like to learn how to build nice-looking front-ends for the modern web, but all the webpacking and transpiling seems like a mess to me. What would be the most direct way to get something nice-looking given my skillset?

reddit.com
u/Sad-Background-2429 — 2 months ago

In cases where my 2-year-old son refuses to go where I want him to go (e.g. to his highchair), the gentle parenting strategy of offering a choice works well (“Do you want to climb in your highchair or do you want daddy to help you into your highchair?”).

However, in cases where, for example, my son has thrown all of his crayons on the floor, my wife will ask him to pick them up and he will refuse. My wife has tried timeouts as punishment, with the expectation that he would eventually learn he needs to pick up the crayons, but he continues to refuse.

Can you recommend a gentle parenting strategy for a case like this?

reddit.com
u/Sad-Background-2429 — 2 months ago

In cases where my 2-year-old son refuses to go where I want him to go (e.g. to his highchair), the gentle parenting strategy of offering a choice works well (“Do you want to climb in your highchair or do you want daddy to help you into your highchair?”).

However, in cases where, for example, my son has thrown all of his crayons on the floor, my wife will ask him to pick them up and he will refuse. My wife has tried timeouts as punishment, with the expectation that he would eventually learn he needs to pick up the crayons, but he continues to refuse.

Can you recommend a gentle parenting strategy for a case like this?

reddit.com
u/Sad-Background-2429 — 2 months ago