-
Notifications
You must be signed in to change notification settings - Fork 97
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
Bound the length of nls completions #2073
Conversation
|
Branch | 2073/merge |
Testbed | ubuntu-latest |
⚠️ WARNING: The following Measure does not have a Threshold. Without a Threshold, no Alerts will ever be generated!Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholds
CLI flag.
Click to view all benchmark results
Benchmark | Latency | nanoseconds (ns) |
---|---|---|
fibonacci 10 | 📈 view plot | 487,290.00 |
foldl arrays 50 | 📈 view plot | 1,768,000.00 |
foldl arrays 500 | 📈 view plot | 6,859,700.00 |
foldr strings 50 | 📈 view plot | 7,212,800.00 |
foldr strings 500 | 📈 view plot | 62,931,000.00 |
generate normal 250 | 📈 view plot | 48,366,000.00 |
generate normal 50 | 📈 view plot | 2,135,300.00 |
generate normal unchecked 1000 | 📈 view plot | 3,373,100.00 |
generate normal unchecked 200 | 📈 view plot | 770,260.00 |
pidigits 100 | 📈 view plot | 3,200,300.00 |
pipe normal 20 | 📈 view plot | 1,512,700.00 |
pipe normal 200 | 📈 view plot | 10,392,000.00 |
product 30 | 📈 view plot | 838,970.00 |
scalar 10 | 📈 view plot | 1,542,500.00 |
sum 30 | 📈 view plot | 842,330.00 |
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.
I agree that I don't see a much better way to do it, without butchering the actual pretty-printing code. I also think that the NickelAllocatorExt
becomes useless - it's was done only because we wanted to monkey-patch the external type BoxAllocator
, but now we can just implement the methods directly on our own type.
Ok, the new version gets rid of the I couldn't figure out the purpose of the |
6e9eb84
to
2cbdc83
Compare
When there's a big contract, the completions can be very large. This can slow down nls substantially, with most of the time being spent in pretty-printing. The current
PrettyPrintCap
mechanism isn't useful here, because it does all the slow pretty-printing first and then truncates the output.This PR adds a crude mechanism to bound the size of pretty prints. With this change, completion in the tf-ncl example is instant. There are probably other places that truncated pretty-printing could be used in nls.
I'm not completely happy with how this implementation threads the bounds through, but I couldn't figure out how else to do it:
BoundedTerm<T: Pretty>(T, SizeBounds)
to wrap the things that are actually getting pretty-printed, but it requires lots of changes to the pretty-printer to explicitly pass that state around everywhereDocAllocator
don't allow this: since the lifetime of the allocator leaks into the returnedDocBuilder
, you can't format children using a local allocator.The current approach with interior mutability was from me trying to work around the second issue.
I also wonder if
NickelAllocatorExt
needs to be a trait. Maybe we can just useBoundedAllocator
(possibly renamed) concretely everywhere?