@jhpratt@mastodon.social avatar

jhpratt

@jhpratt@mastodon.social

Contributor to Rust's compiler and standard library. Maintainer of Rust crates including time, deranged, powerfmt, num_threads, and num-conv. Third degree black belt in American Kenpo ๐Ÿฅ‹

jhpratt on most platforms

This profile is from a federated server and may be incomplete. Browse more on the original instance.

jhpratt, to rust
@jhpratt@mastodon.social avatar

Hit an edge case in the #Rust compiler that appears to be quadratic at best and potentially exponential. Trivial to make happen with real-world code. Investigating...

#RustLang #programming

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber Me too! I'm going to use the self-profile feature to try to determine where time is being spent. Creating a minimal reproduction may be tricky, as the underlying library is relatively intertwined.

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber Oh, I forgot to mention. This happens with cargo check, so it is unquestionably rustc and not LLVM.

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber

Discarding the smallest checks as insignificant, it's certainly exponential. Best fit is an exponent of 1.27749 ร— the number of methods chained; correlation is 0.992.

A chain of 11 methods took 7m51s to type check, and I didn't dare to try 12 (which was my original code).

typeck: 28.941%
normalize_canonicalized_projection_ty 26.938%
type_op_prove_predicate 25.097%
codegen_select_candidate 12.080%
LLVM_passes 5.534%

Any tips on creating a minimal example for an issue?

jhpratt,
@jhpratt@mastodon.social avatar

@ekuber @predrag Very much so โ€” every part of the API is based around trait impls. Stubbing bodies is a good starting place.

jhpratt, to rust
@jhpratt@mastodon.social avatar

Now that it's public, I can say that I will be speaking (again) at in Montrรฉal! Catch me there or online in September.

jhpratt, to firefox
@jhpratt@mastodon.social avatar

I like , but it is definitely trailing behind other browsers. PWAs, WebUSB, stacked/grouped tabs, and far more are present in a number of browsers and are all incredibly useful. Firefox has none of these. I thought translation was an extension because FF communication is crap.

I refuse to use Chrome out of principle, and Vivaldi is the only browser that even seems remotely what I want. But whenever I've tried it, I quickly ran into trivial, obvious bugs that I had reported years prior.

jhpratt,
@jhpratt@mastodon.social avatar
jhpratt, to rust
@jhpratt@mastodon.social avatar

Preview of what I have been working on recently. The core of this crate is a mere two traits. The crate will ship with a number of parsers and combinators, none of which rely on anything not exposed to downstream users.

I've attached a real-world situation, taken verbatim from the test suite. Parsing integers isn't as efficient as it could be yet, as it's using a naรฏve method.

Parsing in general compiles to be extremely efficient, and using it is ergonomic.

pub trait Combinator<'input, P> where P: ByteParser<'input>, { type NewParser: ByteParser<'input>; fn apply_to(self, parser: P) -> Self::NewParser; }
#[test] fn parse_date() -> parcom::Result<()> { let parser = ascii::int:: .limit_length(4) .and(verbatim(b"-").discard()) .and(ascii::int::.limit_length(2)) .and(verbatim(b"-").discard()) .and(ascii::int::.limit_length(2)); let (seq!(year, _, month, _, day), remaining) = parser.parse("2021-07-04")?.into_parts(); assert!(remaining.is_empty()); assert_eq!(year, 2021); assert_eq!(month, 7); assert_eq!(day, 4); Ok(()) }

jhpratt, to rust
@jhpratt@mastodon.social avatar

So now that -Zcheck-cfg is stabilized and enabled by default, there's no way to tell the compiler about custom cfgs other than a build script?

I routinely use a custom cfg for rustdoc so that I can use nightly features when publishing (both with docs.rs and CI). #[cfg(coverage)] is also used in some places.

Apparently spurious warnings are extremely wide-spread, so I'm not clear on why this was stabilized with such a glaring hole in it.

jhpratt, to rust
@jhpratt@mastodon.social avatar

In , how can I leverage the type system to enforce that one object originates from another? Even requiring the lifetime be exact ('a: 'b and 'b: 'a) wouldn't work.

Basically, I have struct Bytes&lt;'a&gt;(&amp;'a [u8]); and want to prevent someone from creating an arbitrary value that can be swapped in for the correct one. Yet at the same time it is essential that arbitrary values can be created.

Basically I'm trying to enforce my own version of provenanceโ€ฆ

jhpratt,
@jhpratt@mastodon.social avatar

I believe I've done it. After a few attempts, I was able to enforce provenance while minimally affecting the API.

Implementing a trait now has a trivial amount of overhead, while end users will see no difference whatsoever from what I wanted.

To those wondering, I ended up using the closure hack along with forcing invariance. GhostCell, while neat, only appears to work within a single function.

Should I write something up about this? It's an interesting problem.

jhpratt,
@jhpratt@mastodon.social avatar

Note that there would be one reason that I might want to hold out on doing a write-up, but I'll know for sure if it would be a concern in a couple days.

jhpratt, to random
@jhpratt@mastodon.social avatar

Yet another round of layoffs at Tesla, and this time I'm part of it.

If anyone is aware of full time work that I may be interested in, let me know! I'm located in the US (upstate NY specifically) and an open to relocation, though I would prefer remote.

jhpratt, to random
@jhpratt@mastodon.social avatar

As of today, Donald Trump is a convicted criminal.

jhpratt,
@jhpratt@mastodon.social avatar

@underlap The contempt of court was criminal, not civil.

"The Court finds Defendant in criminal contempt for willfully disobeying a lawful mandate
of this Court in violation of Judiciary Law Section 750(3) on nine separate occasions."

https://www.nycourts.gov/LegacyPDFS/press/PDFs/D.O.motion4contempt-FINAL.pdf

ekuber, to rust
@ekuber@hachyderm.io avatar

Somewhat cursed idea: "attributes at a distance"

#![attr(target = crate::foo::Bar)]

mod foo {  
 struct Bar;  
}  

What would you use this for?

jhpratt,
@jhpratt@mastodon.social avatar

@ekuber Allowing something deprecated is an obvious situation to me

jhpratt,
@jhpratt@mastodon.social avatar

@ekuber Ah, I misunderstood what was being suggested. I have no idea why you'd want that ๐Ÿ˜…

jhpratt, to random
@jhpratt@mastodon.social avatar

What happened with is precisely why I ceased support of serde versions that had pre-compiled binaries included. It doesn't matter how trustworthy someone seems or how long they've been maintaining a project.

I caught flak from a number of people, including one person (in person, and respectfully!) saying that I was "policing the ecosystem". Which...yes, that's the point. Unknown, unverified binaries being executed is unacceptable and dangerous until proven safe, not the other way around.

jhpratt, to rust
@jhpratt@mastodon.social avatar

Looking back at some of the crates that I've published as spin-offs from time:

  • deranged (range-bounded integers)
  • num-conv (avoiding as casts)
  • num_threads (thread count for current process)
  • powerfmt (making it easier to implement Display while following formatting flags)
  • standback (backporting the standard library to older compilers)

Only standback is no longer maintained, as I don't need it any more. All the others are maintained, with num_threads having a co-maintainer.

jhpratt,
@jhpratt@mastodon.social avatar

Check out the crates! No published crates other than my own and forks have any as a dependency, despite all of them being useful! There are two other spin-off crates in progress, bringing the total to seven crates that aren't an integral part of time.

jhpratt, to rust
@jhpratt@mastodon.social avatar

For those that wanted a comparison between the time and chrono crates, here's an excellent overview of some differences between the crates:

https://users.rust-lang.org/t/the-state-of-time-in-rust-leaps-and-bounds/107620?u=jhpratt

jhpratt, to rust
@jhpratt@mastodon.social avatar

Anyone down for writing up a comparison between time and chrono? I'm not aware of a full comparison anywhere, and it's far from a priority for me. I can check the accuracy of anything on time's end of things.

If you're interested, please respond here or https://github.com/time-rs/time/issues/308.

jhpratt, to rust
@jhpratt@mastodon.social avatar
jhpratt,
@jhpratt@mastodon.social avatar

My talk specifically:

https://youtu.be/vPOlYFs6Bs0

  • All
  • Subscribed
  • Moderated
  • Favorites
  • โ€ข
  • provamag3
  • khanakhh
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • ethstaker
  • Youngstown
  • mdbf
  • slotface
  • everett
  • rosin
  • ngwrru68w68
  • kavyap
  • thenastyranch
  • JUstTest
  • cubers
  • tacticalgear
  • osvaldo12
  • GTA5RPClips
  • cisconetworking
  • modclub
  • Durango
  • Leos
  • normalnudes
  • megavids
  • tester
  • anitta
  • lostlight
  • All magazines