-
Notifications
You must be signed in to change notification settings - Fork 588
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
Implement extend
for cached_test_function_ir
#4159
Conversation
otherwise looks awesome! Might be easiest to split out the explain mode changes to a separate PR; we could probably merge the rest today if so. |
buf_attempt_fixed = bytearray(buffer)
buf_attempt_fixed[start:end] = [
self.random.randint(0, 255) for _ in range(end - start)
]
result = self.engine.cached_test_function(
buf_attempt_fixed, extend=BUFFER_SIZE - len(buf_attempt_fixed) and now we're replacing start:end with the same number-and-type-and-kwargs of random nodes. |
Right, yeah, I think "n bytes when serialized" might be the easiest way to get a nice notion of IR size for overruns. It was, yep. Even with type-matching though it's much less likely that we can successfully 'slip' between different valid node types if there's some variation there... maybe we just don't worry about that for now though, and leave better-generation on the todo list. |
ah yup, serialized size is probably good enough for now (and maybe ever). I think that after #4086 the 'slipping' is roughly fine - we don't throw away misalignments anymore. It's not as efficient in clock cycles (due to ir -> buffer -> ir), but I think we accept the hit and just try to move off bytes asap. |
OK, I've scoped down this PR. I think we're reaching a critical juncture here where it's important to get the ir semantics right, but there are spurious potential problems caused by the interaction of the ir and buffer semantics - such as disagreements on when something is an overrun. Hopefully we (I) can blaze through the changes and minimize impact. (to be clear, I think I've avoided any consumer-facing problems, but it does make me nervous.) |
explain
phase to the typed choice sequenceextend
for cached_test_function_ir
@@ -671,3 +673,75 @@ def move(self, src: bytes, dest: bytes, value: bytes) -> None: | |||
|
|||
def delete(self, key: bytes, value: bytes) -> None: | |||
raise RuntimeError(self._read_only_message) | |||
|
|||
|
|||
def ir_to_bytes(ir: Iterable[IRType], /) -> bytes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is lifted from your branch, with two fixes:
- surrogatepass instead of surrogateescape (I don't recall my at-the-time justification of this, but if you run your test case for long enough you will get an error with surrogateescape)
- correct interpretation for negative ints? I think this also is caught by the test case if run for long enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - onwards!
Implement
extend
forcached_test_function_ir
, and use ir serialization for a notion of size.previous description
Closes . #3864.
This is really two PRs:
extend: int = 0
forcached_test_function_ir
explain
to the irIn implementing
extend
for the ir, we have to choose a notion of "size" for the ir. I've chosenlen(nodes)
for now. We'll probably want to use something more intelligent in the future, such that 1k booleans is smaller than 1k strings each with 10 characters.Inquisitor migration was a relatively straightforward lifting of blocks to nodes. I haven't thought too carefully about whether the transformation was correct (for some explain-phase-specific-reason) outside of "tests pass", so that may be worth a think on review.
Likely easiest to review by commit (except there is an "oops, all fixes" grab bag commit at the end).