-
Notifications
You must be signed in to change notification settings - Fork 829
fix: message templates alignment compliance #2064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: message templates alignment compliance #2064
Conversation
Thanks for checking this out, @Insomniak47 👍 It seems like the change should be reasonable and safe to make. Is there any reason we couldn't switch to using It looks like you may have branched off of |
I think we could tryparse the whole thing but I don't think that we can use the output because
Yeah for sure, I'll rebase onto dev. I noticed this when I was putting the PR up then I got distracted 😄 |
58e3f4a
to
7b5313d
Compare
Alrighty, I've moved to just the parsing, I added an additional check to make sure that '+' also isn't at the beginning + a test for it. I've also rebased on dev. In really heavy alignment based workflows this might end up a little faster which would be neat. Looks like it allocates one additional few bytes in gen0 in the alloc benches in specific cases. I'm assuming that's because Edit: Looks like it gets rid of any Gen1's now though so might have just shifted it in some cases
|
Looks good! Are those final After numbers from the same benchmarking setup as the Before series? Looks like some unexpected regressions, guessing it's a benchmarking issue rather than a real regression but just keen to double-check :) |
The last numbers I posted in #2064 (comment) are against dev not main. The dev allocations numbers are the same (no regressions) and the perf is == or better I'll post an updated before/after this evening The ones that are in there now:
|
Before -> On dev
After -> This PR
So no regression in mem usage, no perf regression generally |
Thank you, @Insomniak47 👍 |
Happy to help! |
Based on our conversation in messagetemplates/grammar#6
This brings alignment parsing in line with the message-templates spec which specifies:
Alignment := -?[0-9]+
. I've benchmarked it locally on my laptop and desktop - these are my results from my laptop. Performance ends up the same in all current benchmarks and I'd expect that in alignment heavy workloads it'd be the sameish, maybe betterThe method is a bit of a misnomer that I've introduced
IsValidAlignment
because it really only checks that it doesn't contain any invalid characters in slots but-
for example would pass. Not worrisome because we parse it right afterwards but might be a better name.I tried both benchmarks with AggressiveInlining but the compiler was smart enough to do it already so there was no perf change. Below are the benchmarks before and after. All of the memory benchmarks are approximately the same & def within the distributions noise in general while the parsing seems to be very similar as well which I'd expect given there's no alignment in the default parsing.
Before
Allocations
Parsing
After
Allocations
Parsing