Skip to content
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

Introduce Blink-To-Append-Only Memoization and Apply to TableLoggers #4880

Merged
merged 5 commits into from
Nov 24, 2023

Conversation

nbauernfeind
Copy link
Member

The primary purpose is to make PerformanceQueries work as intended (best-effort w.r.t. memory usage when not in use) according to existing documentation.

@nbauernfeind nbauernfeind added query engine core Core development tasks DocumentationNeeded ReleaseNotesNeeded Release notes are needed labels Nov 22, 2023
@nbauernfeind nbauernfeind added this to the November 2023 milestone Nov 22, 2023
@nbauernfeind nbauernfeind self-assigned this Nov 22, 2023
Comment on lines 62 to 90
}
}
final QueryTable coalesced = (QueryTable) blinkTable.coalesce();

private static Table internalBlinkToAppendOnly(final Table blinkTable, long sizeLimit) {
return QueryPerformanceRecorder.withNugget("blinkToAppendOnly", () -> {
if (!isBlink(blinkTable)) {
if (!isBlink(coalesced)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the order has changed here - coalescing first then checking blink. Does it make more sense to keep the check first?

More generally, are we really using coalesce() b/c we need to make sure manage livenessscope stack stuff? If so, are we maybe abusing coalesce in this context b/c we already know a blinktable is coalesced? (And maybe, we should have a more appropriate method on Table for this situation?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It would not be inappropriate to do the check before coalescing.
  • It's better to do the coalesce inside of the withUpdateGraph(), although that should be managed internally anyway.
  • The coalesce() is very much "belt and suspenders" hypothetical correctness in this case, as there are no uncoalesced blink tables in use.
  • What more appropriate method do you have in mind?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. That is my mistake. I needed the QueryTable to invoke getResult and I got the order wrong.

Copy link
Member

@rcaudy rcaudy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looking good. I wish you had separated out some of the refactoring to its own commit.

@@ -116,7 +116,7 @@ default boolean snapshotNeeded() {
*/
class Result<T extends DynamicNode & NotificationStepReceiver> {
public final T resultNode;
public final TableUpdateListener resultListener; // may be null if parent is non-ticking
public final TableUpdateListener resultListener; // may be null if parent or result are non-refreshing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we anticipate a non-refreshing result from a refreshing parent? snapshot(). Any others?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you had in mind. I think this comment should be revised, but I can accept that there's a case for no listener.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case .. the append-only table could hit its size limit during initialization. Maybe this is an over optimization, but it does allow the result to be static. I can't think of anything other than a snapshot.

nbauernfeind and others added 2 commits November 22, 2023 16:06
Co-authored-by: Ryan Caudy <rcaudy@gmail.com>
Copy link
Member

@rcaudy rcaudy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Comment on lines +27 to +32
public static final Object DEFAULT_MEMO_KEY = new Object() {
@Override
public String toString() {
return "DEFAULT_MEMOIZATION_KEY";
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just be

new String("DEFAULT_MEMOIZATION_KEY");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a fan of how it's setup here w/ Object; even though unlikely, a string-based memo-key is "public" and the user can just use the same string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's an argument for using object identity when comparing memo keys. Also, why is it bad if the user really wants to explicitly use our default memo key? It's public here, for some reason, although I'd think it could be private.

Copy link
Member

@devinrsmith devinrsmith Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see it's explicitly public. That said, I still think it makes sense as object. (Only way to get default memo is to explicitly use this key.)

I don't think we'd want to use object identity for all memo, otherwise it wouldn't be obvious how one achieves memo over API today.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I'm convinced enough. We stick to Object equality, keep this default as an Object so it will rely on reference equality, and maybe make it private (but I'm ambivalent about that).

rcaudy
rcaudy previously approved these changes Nov 24, 2023
@nbauernfeind nbauernfeind merged commit 8cfe8a8 into deephaven:main Nov 24, 2023
12 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2023
@deephaven-internal
Copy link
Contributor

Labels indicate documentation is required. Issues for documentation have been opened:

How-to: https://github.com/deephaven/deephaven.io/issues/3488
Reference: https://github.com/deephaven/deephaven.io/issues/3487

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core Core development tasks DocumentationNeeded query engine ReleaseNotesNeeded Release notes are needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants