Repository navigation
Further optimize string table parsing - #37
Merged
Merged
Conversation
…ng every single byte for a null terminator manually
Contributor
|
For these kind of reworks, is there any chance you can supply before/after benchmarks? This one is relatively minor so seems fine to merge as-is, I think, but it'd be good to know what "significantly speeds up" means going forward. Reading a string from the string table when actually reading records seems like the logical next step to me personally, but would indeed require larger reworks/additional testing especially given string table reading wonkiness on WDCx variants. |
Contributor
Author
|
I absolutely can. I want to do this especially when coming back to unboxing value type fields as this is the greatest remaining bottleneck. Also I want to expand dbcd with async workflows so we can squeeze even more out of the parsing speed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that we have gotten rid of .NET Standard 2.1, we can fully embrace the juiciness of .NET span features.
We start off by further optimizing the string table parsing.
Prior to this change, we had to scan every single byte of the string table buffer for null terminators. Naturally this is very slow.
.NET has solved this problem already by introducing Span.IndexOf. This is a SIMD optimized way to search for a specific byte so we are now processing multiple bytes with a single call which significantly speeds up the parsing of large string tables.
there are further ways to improve this which would require larger refactors:
instead of pre-processing a string table, we could just read a string straight from the buffer when parsing a record (I did this in my inhouse dbc parser implementation: https://github.com/Ovahlord/CataCraft/blob/master/src/CataCraft.DBC/WDBCReader.cs#L202)
OR we could use the stream directly and use _reader.TryReadTo(out ReadOnlySequence value, 0) which would allow us to dodge reading the string table to a buffer