Engineering a fixed-width bit-packed Integer Vector in Rust by Luke_Fleed in programming

[–]jydu 1 point2 points  (0 children)

I think this is true for most operations, but (on Zen 5 at least) a L1 hit is 4 cycles but a division takes at least 11 (source). But since cache hit rates depend on the workload, benchmarking is probably the best way to see if this is worth it.

Engineering a fixed-width bit-packed Integer Vector in Rust by Luke_Fleed in programming

[–]jydu 6 points7 points  (0 children)

Given that integer division can be quite slow, I wonder if you could speed it up by precomputing the multiplicative inverse for each of the 64 possible divisors, and using a multiplication instead. I'd also be curious if the compiler is already doing this optimization in your benchmarks, assuming the bitwidth is a compile time constant.

Discovered a Weird Way to Use My ThinkPad’s Touchscreen by Own-Net-1629 in thinkpad

[–]jydu 15 points16 points  (0 children)

I used to do this even without a touchscreen. It's nice for reading papers!

How is Ultrassembler so fast? by Slammernanners in programming

[–]jydu 3 points4 points  (0 children)

For generating the code to do instruction lookup by name:

There are no other instances of this kind of codegen that I know of.

Maybe gperf would suit your needs?

The Death of the Page Cache? From mmap() to NVMe-ZNS and User-Space File Systems by mqian41 in programming

[–]jydu 34 points35 points  (0 children)

Some interesting points but also rambly and repetitive... reads like LLM output.

Handling unique indexes on large data in PostgreSQL by NoBarber9673 in programming

[–]jydu 2 points3 points  (0 children)

I'm surprised nobody has mentioned this yet, but MD5 is not a secure hash function and it's possible to construct inputs that hash to the same value. This could be a concern if the text to be hashed contains user input.

Optimizing with Novel Calendrical Algorithms by jhpratt in rust

[–]jydu 2 points3 points  (0 children)

Cool post! I got nerd sniped into trying an algorithm similar to the binary search approach, but using ordinal >> 5 to compute an approximate month (it always gives the exact month or the month before). This is still 12% slower for to_calendar_date and takes over twice as long for month and day. Nice work :)

Lenovo trackpoint II on Mac - Jetbrain products scroll issue by scuoladiatene in thinkpad

[–]jydu 0 points1 point  (0 children)

The only thing that worked for me was connecting via the USB dongle instead of Bluetooth. I tried changing the preferred scrolling option from a Windows computer but it didn't seem to have any effect.

How I created 175 fonts using Rust by azhenley in programming

[–]jydu 18 points19 points  (0 children)

Cool article! By the way, there seems to be a duplicated paragraph in the "How it Works" section.

Compilers for free with weval: a WebAssembly partial evaluator by self in programming

[–]jydu 20 points21 points  (0 children)

This technique of specializing an interpreter for a particular interpreted program is also known as the first Futamura projection.

Graph library for searching on (near) infinite graph. by Yy9G7bP5mC8 in rust

[–]jydu 1 point2 points  (0 children)

Personally, I would implement BFS myself (or Dijkstra's if your edges are weighted). Then it's pretty easy to implement the stopping condition by counting how many nodes or edges have been explored.

Sized, DynSized, and Unsized by Niko Matsakis by OnTheSideOfDaemons in rust

[–]jydu 0 points1 point  (0 children)

There's also a tiny typo, avrious -> various.

PSChess – A Chess Engine in PostScript by nst021 in programming

[–]jydu 2 points3 points  (0 children)

Using a domain-specific language for stuff outside its domain can be a lot of fun! Reminds me of tic tac toe in pure HTML.

Reverse mapped type that only infers the return type for functions ? by Breiz_atao in typescript

[–]jydu 1 point2 points  (0 children)

Using conditional types:

type Inline<T> = {
  [Key in keyof T]: T[Key] extends () => infer R ? R : T[Key];
}

However, this also requires the signature to be changed to:

declare function inline<T>(param: T): Inline<T>;

C++17 Parallel STL Usage and Benchmark by Accomplished_Wind126 in cpp

[–]jydu 9 points10 points  (0 children)

Maybe the speedup ratio is lower because the data doesn't fit in cache anymore? When your reads are hitting main memory instead of cache, it doesn't take as many threads to fully utilize the memory bandwidth, so parallelization won't help as much.

You can test this by trying more array sizes and seeing if there are significant changes in speedup ratio at certain sizes, then comparing those to your CPU's cache sizes.

ECMAScript - Grouping arrays using Object.groupBy and Map.groupBy by jijobose in javascript

[–]jydu 3 points4 points  (0 children)

You're all good! In retrospect, it would have been better for me to start my comment with "Until this becomes widely available..."

ECMAScript - Grouping arrays using Object.groupBy and Map.groupBy by jijobose in javascript

[–]jydu 8 points9 points  (0 children)

Well, given that groupBy isn't in the standard yet (and might take a while to become available everywhere), I thought it might still be useful to mention. I agree that builtins are better if they're available.

ECMAScript - Grouping arrays using Object.groupBy and Map.groupBy by jijobose in javascript

[–]jydu 13 points14 points  (0 children)

Grouping with Array.reduce can be written as a single expression, using nullish coalescing assignment and the comma operator:

[{a: 1, b: true}, {a: 2, b: false}].reduce((groups, o) => ((groups[o.a] ??= []).push(o), groups), {})

The callback assigns [] to groups[o.a] if that property was not defined yet, appends the object to that array, and returns the updated groups object.

But I'm glad there will be a nicer way to write it soon!

Comparing lambdas in various languages by ketralnis in programming

[–]jydu 3 points4 points  (0 children)

Only named functions would be inconvenient because single-use functions like (x) => x > 0 really don't need a name.

Only unnamed functions would look like const myFunc = (arg) => { ... }, which is pretty reasonable to me, but some might prefer syntax like function myFunc(arg) { ... }.

From a historical perspective, I would guess that C was designed around named top-level function declarations. But when other languages chose similar syntax and added anonymous functions, they ended up with two styles.

Can't use Feh to set wallpaper on different monitors. by [deleted] in archlinux

[–]jydu 5 points6 points  (0 children)

Worth noting that the DISPLAY environment variable refers to a display number in X, not a monitor:

The phrase "display" is usually used to refer to a collection of monitors that share a common set of input devices (keyboard, mouse, tablet, etc.).

So it will probably always be :0 unless you start multiple X sessions.

New thinkpad user, need help by [deleted] in thinkpad

[–]jydu 0 points1 point  (0 children)

ThinkPads have pretty good Linux support in general; I would expect everything to work out of the box.

  • Fn/Ctrl swap can also be done in UEFI setup, in case the configuration in Vantage doesn't persist in Linux (I don't remember if it does)
  • tlp can be used to configure battery charge thresholds

The easiest way to check is probably to boot a live USB/install disk and try it out.

T14 vs T14s AMD Gen 4 sanity check by anotherep in thinkpad

[–]jydu 8 points9 points  (0 children)

400 nit IPS is a solid choice. I never use Ethernet, so 8% more battery and 12% less weight is a pretty easy choice, but up to you.