Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.

Various fixes and improvements#1

Open
philipcmonk wants to merge 1 commit intoashelkovnykov:masterfrom
philipcmonk:philip/fixes
Open

Various fixes and improvements#1
philipcmonk wants to merge 1 commit intoashelkovnykov:masterfrom
philipcmonk:philip/fixes

Conversation

@philipcmonk
Copy link

These are mostly small bugs I ran into when trying to run this in zorp-corp/sword#33. They should mostly be self-explanatory, but I'm happy to explain any of them or go over this synchronously.

The changes I made beyond bug fixes are:

  • Added pma_in_arena(void*) so the copying code knows whether it needs to copy a noun out.
  • Added root to the metadata to record where the most recent root is, which will generally be the arvo state, bytecode cache, and anything else that needs to be persisted. You need this so that when you load, you know where to get started. There are a few possible variations, for example we could put the event number and epoch number inside the root as well.
  • Made pma_load return the epoch number, event number, and root. Right now it returns these as a struct, but out parameters plus an error code return could be preferable.

These are mostly small bugs I ran into when trying to run this in
zorp-corp/sword#33.  They should mostly be self-explanatory, but I'm
happy to explain any of them or go over this synchronously.

The changes I made beyond bug fixes are:

- Added `pma_in_arena(void*)` so the copying code knows whether it needs
  to copy a noun out.
- Added `root` to the metadata to record where the most recent root is,
  which will generally be the arvo state, bytecode cache, and anything
  else that needs to be persisted. You need this so that when you load,
  you know where to get started. There are a few possible variations,
  for example we could put the event number and epoch number inside the
  root as well.
- Made pma_load return the epoch number, event number, and root. Right
  now it returns these as a struct, but out parameters plus an error
  code return could be preferable.

// TODO: macros for dealing with cache?
// Pop page off queue
uint16_t head = _pma_state->metadata.dpage_cache->head;
Copy link
Owner

Choose a reason for hiding this comment

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

Do you recall the reason for moving this declaration down? It's not used between the location in the original code and the location in this PR.

_pma_state->metadata.dpage_cache->size -= 1;
_pma_state->metadata.dpage_cache->head = ((head + 1) % PMA_DPAGE_CACHE_SIZE);

_pma_state->metadata.dpage_cache->head = (_pma_state->metadata.dpage_cache->head + 1) % PMA_DPAGE_CACHE_SIZE;
Copy link
Owner

Choose a reason for hiding this comment

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

Do you recall the reasoning for this change? What's wrong with using head?

// If pages available in cache...
if (size) {
// Use a page from the cache and record that it was used afterwards
uint16_t head = _pma_state->metadata.dpage_cache->head;
Copy link
Owner

Choose a reason for hiding this comment

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

Same as above

@ashelkovnykov
Copy link
Owner

This PR now exists just for posterity - this work is being continued here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants