HackerTrans
TopNewTrendsCommentsPastAskShowJobs

tijsvd

no profile record

Submissions

Show HN: fcode is a binary rust-serde format that supports schema evolution

crates.io
14 points·by tijsvd·5 ปีที่แล้ว·2 comments

comments

tijsvd
·3 เดือนที่ผ่านมา·discuss
From what I understand in the follow up: postgres uses shared memory for buffers. This shared memory is read by a new connection while locked.

In postgres, connections are handled with a process fork, not a new thread. If such a fork first reads memory, even if it already exists, that causes a minor page fault, which goes back to the kernel so it can update memory mapping tables.

The operation under lock is only a few instructions, but if it takes longer than expected, then that causes lock contention. Regression in the kernel handling minor faults?

The whole thing is then made worse because it's a spinlock, causing all waiting processes to contend over the cpus which adds to kernel processing.

Mitigated by using huge pages, which dramatically reduces the number of mapping entries and faults. I reckon that it could also be mitigated in postgres by pre-faulting all shared memory early?
tijsvd
·ปีที่แล้ว·discuss
TLDR is that the full correct explanation is not simple. The Wikipedia article on lift makes a good effort.

https://en.m.wikipedia.org/wiki/Lift_(force)
tijsvd
·2 ปีที่แล้ว·discuss
Of course you don't need a calendar library to measure 30 seconds. That's not the use case.

Try adding one year to a timestamp because you're tracking someone's birthday. Or add one week because of running a backup schedule.
tijsvd
·3 ปีที่แล้ว·discuss
Everything that's visible to the compiler is subject to automatic inlining. That is all code in the current crate (compilation unit), all concrete instantiations of generics (regardless where defined), and all functions marked inline (regardless which crate).

Stdlib containers are all in the generics category.
tijsvd
·3 ปีที่แล้ว·discuss
> Get this, say a project takes a year to complete. The concept is saying a 10x engineer can do this in about month.

The true 10x engineer looks at the project, sees the inherent needless complexity, goes back to the sponsor and uses his business knowledge to renegotiate the specs. Leading to a reduced scope with 98% of the business value and 10% of the work.
tijsvd
·3 ปีที่แล้ว·discuss
Would it not be feasible to turn electron inside out, and have chromium as a library, with bindings for various languages?
tijsvd
·3 ปีที่แล้ว·discuss
Never combine new tech with new functionality. If you want to learn new tech, use it to rewrite an old project that was due anyway. If you want to build new functionality, use tech that you know.

This has nothing to do with Rust. I've seen the exact same thing happening with golang in a C++ only environment. Long project, took forever, failed slowly, took a week to rewrite in C++.
tijsvd
·3 ปีที่แล้ว·discuss
You get the same with e.g. tokio::spawn, which runs the future concurrently and returns something that you can await and get the future's output. Or you can forget that something and the future will still run to completion.

Directly awaiting a future gives you more control, in a sense, as you can defer things until they're actually needed.
tijsvd
·3 ปีที่แล้ว·discuss
Then the app relies purely on the ssl cert of the server, for mitm mitigation. This way, the qr can contain a signed reply to the code, which adds a layer.
tijsvd
·4 ปีที่แล้ว·discuss
Apart from CGAT being a 2-bit alphabet, changing the alphabet does not change the information density. Expect that this kind of transformation has no impact on the compressed result, with most general purpose algorithms.
tijsvd
·4 ปีที่แล้ว·discuss
First, this is about data access and not programming.

Second, that quote is from a time when compiler optimizations did not exist, and the programmer was supposed to use all kinds of clever tricks to speed up code (what today you get for free with -O3). That kind of optimization is the context of the quote, and it's hardly ever appropriate to just throw into some discussion about optimization.
tijsvd
·4 ปีที่แล้ว·discuss
It's the field of information theory.

https://en.m.wikipedia.org/wiki/Information_theory
tijsvd
·4 ปีที่แล้ว·discuss
Take incrementing int32. Extend to 64 bits. Multiply by large prime number (e.g. fnv32 prime). Mod 1 million. Add 1 million. End up with random looking, 7 digits, nicely sequenced, 32 bit integers. Write an exhaustive test to verify.

When near 1 million users (yagni), reset sequence and do the same with 10 million (or one billion).

Doesn't solve the upside of 128-bit random numbers (ala uuid): the ability to generate remotely and expect no collision.
tijsvd
·4 ปีที่แล้ว·discuss
What do you use then that has the same order as rows becoming visible?

We use an auto-increment id, and lock inserts on the related account (which always limits the scope of the query).

The only other (stateless) way I can think of is to somehow fiddle with transaction numbers linked to commit order.
tijsvd
·5 ปีที่แล้ว·discuss
The callback is really hard to implement without allocating memory for each wakeup. The poll mechanism can simply leave the task in place. I suspect the poll thing is also easier to generate.
tijsvd
·5 ปีที่แล้ว·discuss
I was generally OK with the speed of Prost, and making it faster was not the goal really. The goal was to make the generated code more Rust-friendly.

It is probably faster due to straightforward decoding, no tag switch. At the cost of not being able to reorder fields or remove in the middle.

With protobuf implementations, one always goes from schema to generated code, which means certain choices can not be handled without further markup:

- what to do with unknown enum values

- which fields become Option

- which string or bytes fields should be by-ref rather than by-value

- derive of other traits

I guess the alternative could have been to build all that into Prost, but that seemed unreasonable. I see this more as a replacement of bincode than as a replacement of Prost.
tijsvd
·5 ปีที่แล้ว·discuss
Thanks for that link. The article links to another article with more background:

https://blog.cloudflare.com/lavarand-in-production-the-nitty...

Which answers all your questions. Tl;dr: the lava feed is only an additional entropy source, it's not like they generate keys directly from the video feed.
tijsvd
·5 ปีที่แล้ว·discuss
Does Rust's `:b` formatter always print leading zeroes? Otherwise the code will not only be inefficient, but wrong for half the input space.

Or perhaps that was the original goal, to find the most significant one and the 41 bits that trail it...
tijsvd
·5 ปีที่แล้ว·discuss
IIRC (many years since I used windows), the New context menu on windows is fed from a directory with templates, and you can add to it.