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

[client] Cache preventing current cell from evaluating #202

Open
myyong opened this issue Jul 2, 2019 · 2 comments
Open

[client] Cache preventing current cell from evaluating #202

myyong opened this issue Jul 2, 2019 · 2 comments
Assignees
Labels

Comments

@myyong
Copy link
Collaborator

myyong commented Jul 2, 2019

When Radka makes a change to previous cells, she cannot force-evaluate current cell because it refers to cache.

@myyong myyong added the type-bug label Jul 2, 2019
@myyong myyong self-assigned this Jul 2, 2019
@tpetricek
Copy link
Collaborator

Ah! This is because of the way we calculate hashes for cells. We are a bit inconsistent, actually.

In javascript.ts we have:

let allHash = Md5.hashStr(antecedents.map(a => a.hash).join("-") + source)

This concatenates all hashes of all dependencies and also the source code and hashes that. This is perfect, because if source code or dependency changes, we get a new hash - so changing some code that this cell depends on would also invalidate the cache.

In external.ts we have the same in bind when constructing node:

let allHash = Md5.hashStr(antecedents.map(a => a.hash).join("-") + exBlock.source)

However, we use wrong hash in the evaluate operation. In line 199 we have:

let hash = Md5.hashStr(src)

// And we use this hash later in:
let body = {"code": strippedSrc,
      "hash": hash,
      "files" : importedFiles,
      "frames": importedFrames}

This only hashes the current source code, so if an antecedent changes, we will use wrong cached result.

We should not be computing hash in evaluate at all - we already computed (a correct) one when doing bind so we can just use that - this should be accessible in externalNode.hash.

TLDR - replacing hash on line 227 with externalNode.hash should fix the issue!

@tpetricek
Copy link
Collaborator

This should now be fixed - can we close this @myyong ?

@tpetricek tpetricek changed the title Cache preventing current cell from evaluating [client] Cache preventing current cell from evaluating Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants